config_o_mat 0.5.8 → 0.5.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f230957ea0207b297e312345111dda19349194b5fd4731a4a90eb5ef185dd599
4
- data.tar.gz: 1dba9c32e8a41d4bdb4f0257c286209a6759ec191d7520959ff1748e40329b8e
3
+ metadata.gz: 696068a23afd014f18fc1a68b693f903ddc20924b8c72e121791a0d3e596cfae
4
+ data.tar.gz: 61c15620de248bde6221f32241291538d1775a5b36c03f47ae5ae1f1a7fdb379
5
5
  SHA512:
6
- metadata.gz: ce2b20c6942f83a13d1c672f2b6beb4fe3b45f7a08bff3f3dfbce20c6a1b9f8878cf883739a1b41e0b0e84ade645bafdb30f88e001fd9252348ab3775bedfdc5
7
- data.tar.gz: f12fee67d7c16366c059816b94ed244ea98a0b018265c2f26dfe680f7ecb8fc57758e0c9d22f8cac7f2b1852ceeb7ead3d68ae27aac3d6734689dcbfc98ea075
6
+ metadata.gz: 800fe380aa5597db8391093ec6b67d1c9a04789b133c15fe2fc1a95f8274197e0df3b4852e489ff700e5dd3254293d2ffd56179e1d9c127371cab5290b04d33b
7
+ data.tar.gz: c5ffbed894b7fdd48930bc9b6337a584fef51726b5d2504259adf5f9d6fd0a90dbb5a5abd5a718490bb9c440a0541af2a210778f4986ae65dbefa9c1a75b9283
data/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ ## 0.5.10
2
+
3
+ BUG FIXES:
4
+
5
+ * A running configurator no longer exits when a refresh fails (an AppConfig throttle or 5xx with no S3 fallback, or a
6
+ secrets load failure). It logs `refresh_failed` at `error` and tries again after `refresh_interval`. A failure on
7
+ first run still exits.
8
+
9
+ ## 0.5.9
10
+
11
+ BUG FIXES:
12
+
13
+ * A running configurator that fails to parse or render a new AppConfig profile version logs `profile_render_failed` at
14
+ `error`, with `application`, `environment`, `appconfig_profile`, `profile` and `profile_version`, then exits as
15
+ before. It's logged only while a new version is being applied, not on a first run, and never for facter or S3
16
+ fallback profiles.
17
+ * Templates are written only once all of them render, so a failure leaves every output file as it was.
18
+
1
19
  ## 0.5.8
2
20
 
3
21
  BUG FIXES:
data/CLAUDE.md CHANGED
@@ -107,9 +107,13 @@ Services can use different restart strategies:
107
107
 
108
108
  The Configurator VM includes retry logic:
109
109
  - On first run, any operation failure causes the VM to fail immediately
110
- - After first run, failures trigger retry with exponential backoff
110
+ - After first run, a failed profile apply retries with exponential backoff; a failed refresh logs `refresh_failed` and
111
+ waits for the next `refresh_interval`
111
112
  - Configurable via `retry_count` and `retry_wait` in config files
112
113
  - Failed profile refreshes can roll back to previous working version
114
+ - A render failure while applying a new AppConfig version logs `profile_render_failed` (application, environment,
115
+ appconfig_profile, profile, profile_version) before the VM errors. Not logged on first run, or for facter or S3
116
+ fallback profiles
113
117
 
114
118
  ### Secrets Integration
115
119
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- config_o_mat (0.5.8)
4
+ config_o_mat (0.5.10)
5
5
  aws-sdk-appconfig (~> 1.18)
6
6
  aws-sdk-s3 (~> 1.114)
7
7
  aws-sdk-secretsmanager (~> 1.57)
@@ -18,25 +18,26 @@ require 'lifecycle_vm/cond_base'
18
18
 
19
19
  module ConfigOMat
20
20
  module Cond
21
- class RetriesLeft < LifecycleVM::CondBase
21
+ class RecoveryAction < LifecycleVM::CondBase
22
22
  reads :error_op, :retries_left, :applying_profile
23
23
 
24
+ # @return [:retry, :resume, :fail]
24
25
  def call
25
- logger&.error(:retry_from_failure, state: error_op.state_name, op: error_op.op.name, errors: error_op.errors)
26
-
27
- # If we aren't currently applying a profile then there's nothing for us to retry.
26
+ # After first run, only a refresh fails with no profile being applied. The next refresh tries again.
28
27
  if applying_profile.nil?
29
- logger&.error(:cannot_retry, reason: 'not applying profile')
30
- return false
28
+ logger&.error(:refresh_failed, state: error_op.state_name, op: error_op.op.name, errors: error_op.errors)
29
+ return :resume
31
30
  end
32
31
 
32
+ logger&.error(:retry_from_failure, state: error_op.state_name, op: error_op.op.name, errors: error_op.errors)
33
+
33
34
  # If we're out of retries, well, no more retrying
34
35
  if retries_left.zero?
35
36
  logger&.error(:cannot_retry, reason: 'out of retries')
36
- return false
37
+ return :fail
37
38
  end
38
39
 
39
- true
40
+ :retry
40
41
  end
41
42
  end
42
43
  end
@@ -20,47 +20,70 @@ module ConfigOMat
20
20
  module Op
21
21
  class GenerateAllTemplates < LifecycleVM::OpBase
22
22
  reads :template_defs, :dependencies, :applied_profiles, :applying_profile, :generated_templates,
23
- :compiled_templates, :runtime_directory
23
+ :compiled_templates, :runtime_directory, :profile_defs
24
24
 
25
25
  writes :generated_templates, :services_to_reload
26
26
 
27
27
  def call
28
- # By doing the error check here instead of in StageOneProfile we ensure that the applying_profile
29
- # gets set in memory, even if errored, which simplifies the retry logic.
30
- error applying_profile.name, applying_profile.errors if applying_profile&.errors?
31
-
32
- return if errors?
33
-
34
- profiles = applied_profiles
35
- profiles[applying_profile.name] = applying_profile if applying_profile
36
28
  self.services_to_reload = []
37
29
 
38
- template_defs.each do |(key, templ_def)|
39
- compiled_template = compiled_templates[key]
30
+ failures = {}
31
+ # Checked here rather than in StageOneProfile so a profile that failed to parse is still the
32
+ # applying_profile, which simplifies the retry logic.
33
+ failures[applying_profile.name] = applying_profile.errors if applying_profile&.errors?
40
34
 
41
- begin
42
- rendered = compiled_template.render(profiles)
43
- rescue StandardError => e
44
- error key, e
45
- next
46
- end
35
+ rendered = failures.empty? ? render_all(failures) : {}
47
36
 
48
- generated = GeneratedTemplate.new(rendered)
37
+ unless failures.empty?
38
+ log_render_failure(failures) if applying_profile
39
+ failures.each { |(key, err)| error key, err }
40
+ return
41
+ end
42
+
43
+ # Only write once every template has rendered, so a failure leaves all output as it was.
44
+ rendered.each do |(key, contents)|
45
+ generated = GeneratedTemplate.new(contents)
46
+ next if generated_templates[key] == generated
49
47
 
50
- if generated_templates[key] != generated
51
- destination_file = File.join(runtime_directory, templ_def.dst)
52
- logger&.notice(:template_update, template: key, file: destination_file, digest: generated.digest)
48
+ destination_file = File.join(runtime_directory, template_defs[key].dst)
49
+ logger&.notice(:template_update, template: key, file: destination_file, digest: generated.digest)
53
50
 
54
- generated_templates[key] = generated
55
- File.open(destination_file, 'w') { |f| f.write(rendered) }
56
- dependencies[key]&.each { |service| services_to_reload << service }
57
- end
51
+ generated_templates[key] = generated
52
+ File.open(destination_file, 'w') { |f| f.write(contents) }
53
+ dependencies[key]&.each { |service| services_to_reload << service }
58
54
  end
59
55
 
60
56
  services_to_reload.uniq!
61
57
 
62
58
  logger&.notice(:scheduled_restarts, services: services_to_reload)
63
59
  end
60
+
61
+ private
62
+
63
+ def render_all(failures)
64
+ profiles = applied_profiles
65
+ profiles[applying_profile.name] = applying_profile if applying_profile
66
+
67
+ template_defs.each_key.with_object({}) do |key, rendered|
68
+ rendered[key] = compiled_templates[key].render(profiles)
69
+ rescue StandardError => e
70
+ failures[key] = e
71
+ end
72
+ end
73
+
74
+ # Only AppConfig-served versions log it: facter and S3-fallback failures can't be fixed by rolling back a
75
+ # deployment, so they must never trip the rollback alarm.
76
+ def log_render_failure(failures)
77
+ definition = profile_defs&.fetch(applying_profile.name, nil)
78
+ return unless definition.is_a?(ConfigOMat::Profile) && !applying_profile.fallback?
79
+
80
+ logger&.error(
81
+ :profile_render_failed,
82
+ application: definition.application, environment: definition.environment,
83
+ appconfig_profile: definition.profile, profile: applying_profile.name,
84
+ profile_version: applying_profile.version, errors: failures.transform_values(&:to_s)
85
+ )
86
+ end
64
87
  end
65
88
  end
66
89
  end
@@ -24,7 +24,7 @@ module ConfigOMat
24
24
  PAUSE_INTERVAL = 1
25
25
 
26
26
  reads :last_refresh_time, :refresh_interval, :run_count, :retry_count, :gc_stat, :gc_compact
27
- writes :next_state, :run_count, :retries_left
27
+ writes :next_state, :run_count, :retries_left, :last_refresh_time
28
28
 
29
29
  def call
30
30
  self.run_count += 1
@@ -47,8 +47,11 @@ module ConfigOMat
47
47
  # I'm calling Kernel.sleep directly so that tests can easily stub it out.
48
48
  Kernel.sleep PAUSE_INTERVAL
49
49
 
50
- if Time.now.to_i - last_refresh_time > refresh_interval
50
+ now = Time.now.to_i
51
+ if now - last_refresh_time > refresh_interval
51
52
  self.next_state = :refreshing_profiles
53
+ # Stored here too because a failed refresh doesn't write memory, and the next try should wait an interval.
54
+ self.last_refresh_time = now
52
55
  else
53
56
  self.next_state = :running
54
57
  end
@@ -107,10 +107,11 @@ module ConfigOMat
107
107
  when: {
108
108
  true => :fail,
109
109
  false => {
110
- case: Cond::RetriesLeft,
110
+ case: Cond::RecoveryAction,
111
111
  when: {
112
- true => { do: Op::WaitRetry, then: :refreshing_profile },
113
- false => :fail
112
+ retry: { do: Op::WaitRetry, then: :refreshing_profile },
113
+ resume: :running,
114
+ fail: :fail
114
115
  }
115
116
  }
116
117
  }
@@ -15,5 +15,5 @@
15
15
  # limitations under the License.
16
16
 
17
17
  module ConfigOMat
18
- VERSION = "0.5.8"
18
+ VERSION = "0.5.10"
19
19
  end
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: config_o_mat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.8
4
+ version: 0.5.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Scarborough
8
+ autorequire:
8
9
  bindir: bin
9
10
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
11
+ date: 2026-12-06 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: aws-sdk-appconfig
@@ -169,6 +170,7 @@ dependencies:
169
170
  - - "~>"
170
171
  - !ruby/object:Gem::Version
171
172
  version: '3.10'
173
+ description:
172
174
  email:
173
175
  - alex@teak.io
174
176
  executables:
@@ -200,7 +202,7 @@ files:
200
202
  - lib/config_o_mat/configurator/cond/first_run.rb
201
203
  - lib/config_o_mat/configurator/cond/next_state.rb
202
204
  - lib/config_o_mat/configurator/cond/profiles_to_apply.rb
203
- - lib/config_o_mat/configurator/cond/retries_left.rb
205
+ - lib/config_o_mat/configurator/cond/recovery_action.rb
204
206
  - lib/config_o_mat/configurator/cond/services_to_reload.rb
205
207
  - lib/config_o_mat/configurator/memory.rb
206
208
  - lib/config_o_mat/configurator/op.rb
@@ -262,6 +264,7 @@ licenses: []
262
264
  metadata:
263
265
  homepage_uri: https://github.com/GoCarrot/configurator
264
266
  source_code_uri: https://github.com/GoCarrot/configurator
267
+ post_install_message:
265
268
  rdoc_options: []
266
269
  require_paths:
267
270
  - lib
@@ -276,7 +279,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
276
279
  - !ruby/object:Gem::Version
277
280
  version: '0'
278
281
  requirements: []
279
- rubygems_version: 3.7.2
282
+ rubygems_version: 3.5.22
283
+ signing_key:
280
284
  specification_version: 4
281
285
  summary: ConfigOMat applies AWS AppConfig to Systemd services.
282
286
  test_files: []