consul-templaterb 1.27.2 → 1.28.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a67e2df58bcd5c322789984815ff60bd95e50fc047cb20c929a67ca29c07f553
4
- data.tar.gz: c4df4357ae2852ad487eb90336a0d2d7d380767d51d05e02e7b452d29acda9c7
3
+ metadata.gz: c15ee78520048d7d091882b9d3b1d43b4cc5f5658cf39d782f06e1dc617d8cd9
4
+ data.tar.gz: 6f77a9daab557420f2640a314a97f78af68e26fec91c1a66f3ee575d9bf150f8
5
5
  SHA512:
6
- metadata.gz: 723beb9fca614d1675e50cc1516f37c4aad93815a1725abcdecb33c8bf0aa5e399449f8c3826a14eac8705aa8cb354aa1034796cf68b46304624f958c1b2ba90
7
- data.tar.gz: 379cb1ca86d8edc44c68694f70b6bd7c1373b8b707f26bef3459379554f94fa12f27653354dc52647eadbd2cf5b0df7cec7f01bcb457e7ed159b7396709ce00d
6
+ metadata.gz: 8c2b374a9400061f3ffd673e418771bb5685ec3d13a631c3839660121d86575be1fbbd1cd99f7ee1a4ddedf850ec72fa984ca084575da587b7a239d2e4654b2e
7
+ data.tar.gz: '0933c0a2f1f58c617c184679ab68c1e90d55f1d9ab796e45336ddbbf49ae2fd73cf1aafbfea6e921254a520c8be3e5f0f380cfbdacd694ba2de6c5f8e4f5a074'
@@ -10,7 +10,7 @@ Metrics/AbcSize:
10
10
  Max: 87
11
11
 
12
12
  Metrics/BlockLength:
13
- Max: 182
13
+ Max: 188
14
14
 
15
15
  Metrics/BlockNesting:
16
16
  Max: 4
@@ -2,6 +2,19 @@
2
2
 
3
3
  ## (UNRELEASED)
4
4
 
5
+ ## 1.28.0 (Sept 25, 2020)
6
+
7
+ NEW FEATURES:
8
+
9
+ * Added `-W` or `--wait-between-reload-signal` to avoid sending too many signals
10
+ to a process executed. This avoids for instance reloading too much a HAProxy configuration
11
+ without having to play with `-w` as described in [#69](https://github.com/criteo/consul-templaterb/issues/69)
12
+
13
+ BUGFIX:
14
+
15
+ * Removed warnings at runtime with Ruby 2.7+
16
+ * Minor JS fix in Consul-UI (Added missing unused parameter to function `serviceTitleGenerator`)
17
+
5
18
  ## 1.27.2 (Sept 4, 2020)
6
19
 
7
20
  IMPROVEMENTS:
data/README.md CHANGED
@@ -165,9 +165,19 @@ USAGE: consul-templaterb [[options]]
165
165
  -f, --[no-]fail-fast If consul/vault endpoints fail at startup, fail immediately
166
166
  -g, --no-gzip-compression Disable GZIP compression in HTTP requests
167
167
  -c, --consul-addr=<address> Address of Consul, eg: http://localhost:8500
168
+ --consul-cert-chain=<path/to/cert_chain>
169
+ Path to Consul TLS client certificate chain to use
170
+ --consul-private-key=<path/to/private_key>
171
+ Path to Consul TLS client private key to use
172
+ --skip-consul-verify-tls Skip verifying Consul TLS via certificate authority (DANGEROUS)
168
173
  -l, --log-level=<log_level> Log level, default=info, any of none|error|info|debug
169
174
  --consul-token=<token> Use a token to connect to Consul
170
175
  -V, --vault-addr=<address> Address of Vault, eg: http://localhost:8200
176
+ --vault-cert-chain=<path/to/cert_chain>
177
+ Path to Vault TLS client certificate chain to use
178
+ --vault-private-key=<path/to/private_key>
179
+ Path to Vault TLS client private key to use
180
+ --skip-vault-verify-tls Skip verifying Vault TLS via certificate authority (DANGEROUS)
171
181
  --vault-token=<token> Token used to authenticate against vault.
172
182
  --[no-]vault-renew Control auto-renewal of the Vault token. Default: activated
173
183
  --vault-retry, --vault-retry-attempts [RETRIES]
@@ -178,10 +188,11 @@ USAGE: consul-templaterb [[options]]
178
188
  -r, --retry-delay=<min_duration> Min Retry delay on Error/Missing Consul Index
179
189
  -k, --hot-reload=<behavior> Control hot reload behaviour, one of :[die (kill daemon on hot reload failure), keep (on error, keep running), disable (hot reload disabled)]
180
190
  -K, --sig-term=kill_signal Signal to send to next --exec command on kill, default=TERM
191
+ -M, --debug-memory-usage Display messages when RAM grows
181
192
  -T, --trim-mode=trim_mode ERB Trim mode to use (- by default)
182
193
  -R, --sig-reload=reload_signal Signal to send to next --exec command on reload (NONE supported), default=HUP
183
- -M, --debug-memory-usage Display messages when RAM grows
184
- -e, --exec=<command> Execute the following command
194
+ -W, --wait-signal=min_duration Wait at least n seconds before each reload signal being sent to next --exec process
195
+ -e, --exec=<command> Execute the following command in as a subprocess when all templates are ready
185
196
  -d, --debug-network-usage Debug the network usage
186
197
  -t erb_file:[output]:[command]:[params_file],
187
198
  --template Add a erb template, its output and optional reload command
@@ -235,7 +246,11 @@ nor write the file.
235
246
  Signals can be customized per process. Two signals are supported with options `--sig-reload` and
236
247
  `--sig-term`. When the option is added, the next `--exec` options to start a process will use the
237
248
  given signal. By default, HUP will be sent to reload events (you can use NONE to avoid sending any
238
- reload signal), TERM will be used when leaving consul-templaterb.
249
+ reload signal), TERM will be used when leaving consul-templaterb. A minimum duration between reload
250
+ signals can be specified for each sub process by prepending `--wait-signal=min_duration` to `--exec`
251
+ command.
252
+ In such case, the signal will be sent every `min_duration` as a maximum (very useful for templates
253
+ changing a lot, but you don't want to trigger too many reloads, for instance for a load-balancer).
239
254
 
240
255
  ### Bandwidth limitation
241
256
 
@@ -94,6 +94,7 @@ consul_engine = Consul::Async::ConsulTemplateEngine.new
94
94
  @programs = {}
95
95
  cur_sig_reload = 'HUP'.freeze
96
96
  cur_sig_term = 'TERM'.freeze
97
+ cur_min_duration_between_signals = 1
97
98
 
98
99
  optparse = OptionParser.new do |opts|
99
100
  opts.banner = usage_text
@@ -215,6 +216,10 @@ optparse = OptionParser.new do |opts|
215
216
  cur_sig_term = compute_signal(sig, nil)
216
217
  end
217
218
 
219
+ opts.on('-M', '--debug-memory-usage', 'Display messages when RAM grows') do
220
+ consul_engine.debug_memory = true
221
+ end
222
+
218
223
  opts.on('-T', '--trim-mode=trim_mode', String,
219
224
  "ERB Trim mode to use (#{options[:erb][:trim_mode]} by default)") do |trim_mode|
220
225
  options[:erb][:trim_mode] = trim_mode
@@ -225,25 +230,36 @@ optparse = OptionParser.new do |opts|
225
230
  cur_sig_reload = compute_signal(sig, 'NONE')
226
231
  end
227
232
 
228
- opts.on('-M', '--debug-memory-usage', 'Display messages when RAM grows') do
229
- consul_engine.debug_memory = true
233
+ opts.on('-W', '--wait-signal=min_duration', Float, 'Wait at least n seconds before each reload signal being sent to next --exec process') do |min_duration|
234
+ raise "-wait-between-reload-signal=#{min_duration} must be greater than 0" unless min_duration.positive?
235
+
236
+ cur_min_duration_between_signals = min_duration
230
237
  end
231
238
 
232
- opts.on('-e', '--exec=<command>', String, 'Execute the following command') do |cmd|
239
+ opts.on('-e', '--exec=<command>', String, 'Execute the following command in as a subprocess when all templates are ready') do |cmd|
233
240
  sig_reload = cur_sig_reload
234
241
  sig_term = cur_sig_term
242
+ sig_min_interval = cur_min_duration_between_signals
235
243
  consul_engine.add_template_callback do |all_ready, template_manager, results|
236
244
  if all_ready
237
245
  modified = results.any?(&:modified)
238
246
  if @programs[cmd].nil?
239
- warn "[EXEC] Starting process: #{cmd}... on_reload=#{sig_reload || 'NONE'} on_term=#{sig_term}"
247
+ warn "[EXEC] Starting process: #{cmd}... on_reload=#{sig_reload || 'NONE'} on_term=#{sig_term}, delay between reloads=#{sig_min_interval}s"
240
248
  @programs[cmd] = Consul::Async::ProcessHandler.new(cmd, sig_reload: sig_reload, sig_term: sig_term)
241
249
  @programs[cmd].start
242
250
  else
251
+
243
252
  # At least one template has been modified
244
- @programs[cmd].reload if modified
253
+ process_to_reload = @programs[cmd]
254
+ if modified && !process_to_reload.reload_scheduled
255
+ process_to_reload.reload_scheduled = true
256
+ now = Time.now
257
+ delay = sig_min_interval - (now - @programs[cmd].last_signal_sent)
258
+ delay = 0 if delay.negative?
259
+ EventMachine.add_timer(delay) { process_to_reload.reload }
260
+ end
245
261
  begin
246
- @programs[cmd].process_status
262
+ process_to_reload.process_status
247
263
  rescue Consul::Async::ProcessDoesNotExist => e
248
264
  warn "[FATAL] The process is dead, aborting run: #{e.inspect}"
249
265
  template_manager.terminate
@@ -59,7 +59,7 @@ module Consul
59
59
  return false unless new_template != @template
60
60
 
61
61
  # We render to ensure the template is valid
62
- render(new_template, current_template_info)
62
+ render(new_template, current_template_info: current_template_info)
63
63
  @template = new_template.freeze
64
64
  true
65
65
  end
@@ -7,7 +7,8 @@ module Consul
7
7
  # Handle the full lifecycle of a process and allows to forward
8
8
  # Posix signals to child process when needed.
9
9
  class ProcessHandler
10
- attr_reader :command, :sig_reload, :sig_term, :pid, :exit_status
10
+ attr_reader :command, :sig_reload, :sig_term, :pid, :exit_status, :last_signal_sent, :reload_scheduled
11
+ attr_writer :reload_scheduled
11
12
  def initialize(command, sig_reload: 'HUP', sig_term: 'TERM')
12
13
  raise 'empty sig_term is not supported' unless sig_term
13
14
 
@@ -16,18 +17,23 @@ module Consul
16
17
  @sig_term = sig_term
17
18
  @pid = nil
18
19
  @exit_status = nil
20
+ @last_signal_sent = Time.now
21
+ @reload_scheduled = false
19
22
  end
20
23
 
21
24
  def start
22
25
  return pid unless pid.nil?
23
26
 
24
27
  @pid = Process.spawn(command)
28
+ @last_signal_sent = Time.now
25
29
  end
26
30
 
27
31
  def reload
28
32
  return if sig_reload.nil?
29
33
 
34
+ @last_signal_sent = Time.now
30
35
  warn "Sending SIG #{sig_reload} to #{pid}..."
36
+ @reload_scheduled = false
31
37
  begin
32
38
  Process.kill(sig_reload, pid)
33
39
  rescue Errno::ESRCH => e
@@ -1,5 +1,5 @@
1
1
  module Consul
2
2
  module Async
3
- VERSION = '1.27.2'.freeze
3
+ VERSION = '1.28.0'.freeze
4
4
  end
5
5
  end
@@ -304,7 +304,7 @@ class ServiceMainSelector extends MainSelector {
304
304
  element.setAttribute("class", "list-group-item service-instance");
305
305
  var state = nodeState(instance.checks);
306
306
  element.appendChild(weightsGenerator(instance.weights, state));
307
- element.appendChild(serviceTitleGenerator(instance));
307
+ element.appendChild(serviceTitleGenerator(instance, serviceName));
308
308
  var node_info = this.nodes[instance.name];
309
309
  if (node_info != null) {
310
310
  node_info = node_info.meta;
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: consul-templaterb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.27.2
4
+ version: 1.28.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - SRE Core Services
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-04 00:00:00.000000000 Z
11
+ date: 2020-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: em-http-request