mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
fix(config): a started configuration recorder keeps recording across a restart (#6938)
* fix(config): a started configuration recorder keeps recording across a restart Whether a recorder was recording, and when it last started and stopped, lived in memory while the recorder itself was persisted. After a restart with persistent storage every recorder reported recording=false, so Terraform's aws_config_configuration_recorder_status planned to start it again on every refresh, and a deployment that relies on Config looked off. The three are now persisted alongside the recorders. docs/services/config.md notes that the recording state persists. * test(config): assert recorder start and stop times survive a restart The restart test only checked recording(), so reverting either timestamp store to memory left it green. It now captures lastStartTime after the start and lastStopTime after the stop, and asserts each keeps its exact value through a reload. * test(config): restart AWS Config persistence tests through files on disk The restart tests shared one set of in-memory stores between service instances, so nothing was written or read back and a broken save or load of the recorder state stayed green. Each simulated restart now builds a fresh factory whose backends are new PersistentStorage files in a temporary directory, loaded from disk, including the restart after the recorder is deleted. * test(config): drop blank lines left at the top of the persistence tests * test(config): restart persistence tests through StorageFactories.open
This commit is contained in:
1 parent
de244061cf
commit
a5254bdc0c
3 files changed
+90
-50
No files matched your search
+13
-4
@@ -98,10 +98,13 @@ public class AwsConfigService {
|
||||
private Map<String, DeliveryChannel> deliveryChannels = new ConcurrentHashMap<>();
|
||||
private Map<String, RetentionConfiguration> retentionConfigurations = new ConcurrentHashMap<>();
|
||||
|
||||
// Transient runtime state is scoped by account and region, like the durable stores.
|
||||
private final ConcurrentHashMap<String, Boolean> recorderRunning = new ConcurrentHashMap<>();
|
||||
private final ConcurrentHashMap<String, Long> recorderLastStartTime = new ConcurrentHashMap<>();
|
||||
private final ConcurrentHashMap<String, Long> recorderLastStopTime = new ConcurrentHashMap<>();
|
||||
// Recorder runtime state is scoped by account and region, like the other stores.
|
||||
// Whether each recorder is recording, and when it last started and stopped: persisted with the
|
||||
// recorders themselves, so a restart does not silently stop recording (which Terraform's
|
||||
// aws_config_configuration_recorder_status then plans to restart on every refresh).
|
||||
private Map<String, Boolean> recorderRunning = new ConcurrentHashMap<>();
|
||||
private Map<String, Long> recorderLastStartTime = new ConcurrentHashMap<>();
|
||||
private Map<String, Long> recorderLastStopTime = new ConcurrentHashMap<>();
|
||||
|
||||
// per-rule evaluation timing is transient runtime state, keyed account + region + ruleName
|
||||
private final ConcurrentHashMap<String, Long> ruleFirstActivatedTime = new ConcurrentHashMap<>();
|
||||
@@ -136,6 +139,12 @@ public class AwsConfigService {
|
||||
new TypeReference<Map<String, Map<String, Map<String, ConfigEvaluation>>>>() {});
|
||||
this.configurationRecorders = storageBacked("config-recorders.json",
|
||||
new TypeReference<Map<String, ConfigurationRecorder>>() {});
|
||||
this.recorderRunning = storageBacked("config-recorder-running.json",
|
||||
new TypeReference<Map<String, Boolean>>() {});
|
||||
this.recorderLastStartTime = storageBacked("config-recorder-last-start.json",
|
||||
new TypeReference<Map<String, Long>>() {});
|
||||
this.recorderLastStopTime = storageBacked("config-recorder-last-stop.json",
|
||||
new TypeReference<Map<String, Long>>() {});
|
||||
this.deliveryChannels = storageBacked("config-delivery-channels.json",
|
||||
new TypeReference<Map<String, DeliveryChannel>>() {});
|
||||
this.retentionConfigurations = storageBacked("config-retention.json",
|
||||
|
||||
Reference in new issue
Block a user