consul-templaterb 1.27.2 → 1.30.0
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 +4 -4
- data/CHANGELOG.md +70 -28
- data/README.md +18 -3
- data/TemplateAPI.md +1 -1
- data/bin/consul-templaterb +27 -6
- data/lib/consul/async/consul_endpoint.rb +26 -1
- data/lib/consul/async/consul_template_render.rb +1 -1
- data/lib/consul/async/process_handler.rb +7 -1
- data/lib/consul/async/version.rb +1 -1
- data/samples/consul-ui/.preferences.rb.samples +1 -0
- data/samples/consul-ui/README.md +6 -0
- data/samples/consul-ui/consul_services.json.erb +14 -1
- data/samples/consul-ui/decorators.js.erb +7 -0
- data/samples/consul-ui/js/nodes.js +1 -1
- data/samples/consul-ui/js/service.js +1 -1
- data/samples/consul-ui/js/utils.js +8 -5
- metadata +32 -49
- data/.gitignore +0 -41
- data/.rspec +0 -2
- data/.rubocop.yml +0 -57
- data/.ruby_app +0 -0
- data/.travis.yml +0 -19
- data/CODE_OF_CONDUCT.md +0 -76
- data/CONTRIBUTING.md +0 -25
- data/Dockerfile +0 -15
- data/Gemfile +0 -5
- data/INTERNALS.md +0 -49
- data/LICENSE.txt +0 -201
- data/Rakefile +0 -8
- data/consul-templaterb.gemspec +0 -42
- data/docker-nginx-conf/nginx.conf +0 -27
- data/docs/article-06_Template-based_discovery_with_consul-templaterb.md +0 -124
- data/docs/images/consul-templaterb.png +0 -0
- data/docs/images/consul-templaterb.svg +0 -3
- data/docs/images/consul-ui_001.png +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1d751a91e60648e8c967bd3401a6d1d595c01f95a4da6ca3537dad89247d2755
|
|
4
|
+
data.tar.gz: 662f076af6864fd541319e0e0ae4c41e6f09cbc96f578d700c403bd315df7420
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c58c6e86c13d2ca37bbb2d4a82aace1d39c27fe76fd4bbf43372d6131d2e14004cbe9d9b6205e40008ab4ad992a44417651aa3739709eb88881d904d3f4161ba
|
|
7
|
+
data.tar.gz: 9f0baecd48f648c0f04a49bc4366d8b85f2cf635d4bb9bd0d572dec9edf3e7fc0a3157f103ef31669cb2856827a4da4cbe73644d9071dcd4de5f3ad4d60451c6
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,48 @@
|
|
|
2
2
|
|
|
3
3
|
## (UNRELEASED)
|
|
4
4
|
|
|
5
|
+
## 1.30.0 (Dec 18, 2020)
|
|
6
|
+
|
|
7
|
+
IMPROVEMENTS:
|
|
8
|
+
|
|
9
|
+
* Allow customization to sort nodes in service view in Consul-UI ([#71](https://github.com/criteo/consul-templaterb/pull/71))
|
|
10
|
+
|
|
11
|
+
NEW FEATURES:
|
|
12
|
+
|
|
13
|
+
* Auto-detection of rate-limit on Consul Side (introduced in Consul 1.6.2+), this feature
|
|
14
|
+
will work only Consul 1.9+ (see [Consul #7527](https://github.com/hashicorp/consul/issues/7527)).
|
|
15
|
+
|
|
16
|
+
## 1.29.0 (Oct 6, 2020)
|
|
17
|
+
|
|
18
|
+
IMPROVEMENTS:
|
|
19
|
+
|
|
20
|
+
* When no template has been specified, stop early with an error message
|
|
21
|
+
|
|
22
|
+
## 1.28.2 (Oct 5, 2020)
|
|
23
|
+
|
|
24
|
+
NEW FEATURES:
|
|
25
|
+
|
|
26
|
+
* Added new decorator to compute node names in consul-ui ([#70](https://github.com/criteo/consul-templaterb/pull/70))
|
|
27
|
+
|
|
28
|
+
## 1.28.1 (Sept 30, 2020)
|
|
29
|
+
|
|
30
|
+
IMPROVEMENTS:
|
|
31
|
+
|
|
32
|
+
* Reduced size of GEM from 400k o 100k by removing not needed files
|
|
33
|
+
|
|
34
|
+
## 1.28.0 (Sept 25, 2020)
|
|
35
|
+
|
|
36
|
+
NEW FEATURES:
|
|
37
|
+
|
|
38
|
+
* Added `-W` or `--wait-between-reload-signal` to avoid sending too many signals
|
|
39
|
+
to a process executed. This avoids for instance reloading too much a HAProxy configuration
|
|
40
|
+
without having to play with `-w` as described in [#69](https://github.com/criteo/consul-templaterb/issues/69)
|
|
41
|
+
|
|
42
|
+
BUG FIXES:
|
|
43
|
+
|
|
44
|
+
* Removed warnings at runtime with Ruby 2.7+
|
|
45
|
+
* Minor JS fix in Consul-UI (Added missing unused parameter to function `serviceTitleGenerator`)
|
|
46
|
+
|
|
5
47
|
## 1.27.2 (Sept 4, 2020)
|
|
6
48
|
|
|
7
49
|
IMPROVEMENTS:
|
|
@@ -12,7 +54,7 @@ IMPROVEMENTS:
|
|
|
12
54
|
|
|
13
55
|
BUGIX:
|
|
14
56
|
|
|
15
|
-
* Fix collision in JSON queries when using payload in requests #68
|
|
57
|
+
* Fix collision in JSON queries when using payload in requests [#68](https://github.com/criteo/consul-templaterb/pull/68)
|
|
16
58
|
|
|
17
59
|
## 1.27.0 (June 5, 2020)
|
|
18
60
|
|
|
@@ -25,15 +67,15 @@ NEW FEATURES:
|
|
|
25
67
|
|
|
26
68
|
## 1.26.3 (April 15, 2020)
|
|
27
69
|
|
|
28
|
-
|
|
70
|
+
BUG FIXES:
|
|
29
71
|
|
|
30
72
|
* Removed all Criteo specific decorators from Consul-UI
|
|
31
73
|
|
|
32
74
|
## 1.26.2 (April 15, 2020)
|
|
33
75
|
|
|
34
|
-
|
|
76
|
+
BUG FIXES:
|
|
35
77
|
|
|
36
|
-
* Fixed broken Dockerfile (was missing the new `decorator.js.erb` file). Fixes #61 (Thanks to @
|
|
78
|
+
* Fixed broken Dockerfile (was missing the new `decorator.js.erb` file). Fixes #61 (Thanks to [@simongareste](https://github.com/simongareste))
|
|
37
79
|
|
|
38
80
|
NEW FEATURES:
|
|
39
81
|
|
|
@@ -41,7 +83,7 @@ NEW FEATURES:
|
|
|
41
83
|
|
|
42
84
|
## 1.26.1 (March 27, 2020)
|
|
43
85
|
|
|
44
|
-
|
|
86
|
+
BUG FIXES:
|
|
45
87
|
|
|
46
88
|
* Using `agent: http://vault_or_consul_agent:port>` was not properly taken into account in some endpoints
|
|
47
89
|
|
|
@@ -59,7 +101,7 @@ NEW FEATURES:
|
|
|
59
101
|
|
|
60
102
|
## 1.25.2 (February 29, 2020)
|
|
61
103
|
|
|
62
|
-
|
|
104
|
+
BUG FIXES:
|
|
63
105
|
|
|
64
106
|
* Update rake to 12.3.3 to fix [CVE-2020-8130](https://github.com/advisories/GHSA-jppv-gw3r-w3q8)
|
|
65
107
|
|
|
@@ -78,7 +120,7 @@ NEW FEATURES:
|
|
|
78
120
|
|
|
79
121
|
## 1.24.1 (February 19, 2020)
|
|
80
122
|
|
|
81
|
-
|
|
123
|
+
BUG FIXES:
|
|
82
124
|
|
|
83
125
|
* Properly set service meta in node meta decorator
|
|
84
126
|
|
|
@@ -95,7 +137,7 @@ NEW FEATURES:
|
|
|
95
137
|
* Implementation of #59 - implementation of `--retry` and `--vault-retry` new flags
|
|
96
138
|
Those flags work in a similar way as in consul-template: stop program after X failures
|
|
97
139
|
of consul or vault endpoints
|
|
98
|
-
* Added
|
|
140
|
+
* Added `--fail-fast` that stop the programs immediately if vault or consul are not available
|
|
99
141
|
at startup (also works with `--once`)
|
|
100
142
|
|
|
101
143
|
## 1.22.0 (January 17, 2020)
|
|
@@ -106,7 +148,7 @@ NEW FEATURES:
|
|
|
106
148
|
|
|
107
149
|
## 1.21.8 (January 2, 2020)
|
|
108
150
|
|
|
109
|
-
|
|
151
|
+
BUG FIXES:
|
|
110
152
|
|
|
111
153
|
* Escape properly metadata containing double quotes in prometheus exporter
|
|
112
154
|
|
|
@@ -120,13 +162,13 @@ IMPROVEMENTS:
|
|
|
120
162
|
|
|
121
163
|
IMPROVEMENTS:
|
|
122
164
|
|
|
123
|
-
* Added node_meta_info for serviceInstanceDecorator and serviceMetaDecorator
|
|
165
|
+
* Added `node_meta_info` for `serviceInstanceDecorator` and `serviceMetaDecorator` in Consul-UI
|
|
124
166
|
|
|
125
167
|
## 1.21.5 (December 6, 2019)
|
|
126
168
|
|
|
127
169
|
NEW FEATURES:
|
|
128
170
|
|
|
129
|
-
* Added clean() method in nodes.js to allow
|
|
171
|
+
* Added `clean()` method in nodes.js to allow new behaviors
|
|
130
172
|
|
|
131
173
|
## 1.21.4 (November 28, 2019)
|
|
132
174
|
|
|
@@ -157,7 +199,7 @@ IMPROVEMENTS:
|
|
|
157
199
|
## 1.21.0 (November 21, 2019)
|
|
158
200
|
|
|
159
201
|
* added function `templates` to list all templates being rendered
|
|
160
|
-
* added support for JS decorators in consul-ui (thanks to @Thib17)
|
|
202
|
+
* added support for JS decorators in consul-ui (thanks to [@Thib17](https://github.com/Thib17))
|
|
161
203
|
|
|
162
204
|
## 1.20.0 (October 16, 2019)
|
|
163
205
|
|
|
@@ -176,7 +218,7 @@ NEW FEATURES:
|
|
|
176
218
|
|
|
177
219
|
* Added new function `checks_for_node`
|
|
178
220
|
|
|
179
|
-
|
|
221
|
+
BUG FIXES:
|
|
180
222
|
|
|
181
223
|
* Avoid try publishing several times Gem on rubygems.org
|
|
182
224
|
|
|
@@ -198,13 +240,13 @@ IMPROVEMENTS:
|
|
|
198
240
|
|
|
199
241
|
## 1.18.3 (September 2, 2019)
|
|
200
242
|
|
|
201
|
-
|
|
243
|
+
BUG FIXES:
|
|
202
244
|
|
|
203
245
|
* When vault receives at timeout, correctly reschedule it
|
|
204
246
|
|
|
205
247
|
## 1.18.2 (August 28, 2019)
|
|
206
248
|
|
|
207
|
-
|
|
249
|
+
BUG FIXES:
|
|
208
250
|
|
|
209
251
|
* In Consul UI, showing data from KV with markup was not properly handled
|
|
210
252
|
|
|
@@ -220,7 +262,7 @@ Support any request method for remote_resource.as_json (#41)
|
|
|
220
262
|
|
|
221
263
|
## 1.18.1 (July 27, 2019)
|
|
222
264
|
|
|
223
|
-
|
|
265
|
+
BUG FIXES:
|
|
224
266
|
|
|
225
267
|
Fixed wrong lazy initialization in `remote_resource.as_json` that
|
|
226
268
|
cause too many connections to be opened.
|
|
@@ -229,13 +271,13 @@ cause too many connections to be opened.
|
|
|
229
271
|
|
|
230
272
|
NEW FEATURES:
|
|
231
273
|
|
|
232
|
-
* Support for `remote_resource` provided by @kamaradclimber
|
|
274
|
+
* Support for `remote_resource` provided by [@kamaradclimber](https://github.com/kamaradclimber)
|
|
233
275
|
* Added support for `remote_resource.as_json` to fetch JSON remote resource from a web server
|
|
234
276
|
* Added `samples/list_ruby_versions_from_rubygems.txt.erb` to demonstrate usage
|
|
235
277
|
|
|
236
278
|
## 1.17.3 (July 18, 2019)
|
|
237
279
|
|
|
238
|
-
|
|
280
|
+
BUG FIXES:
|
|
239
281
|
|
|
240
282
|
* Added gem parallel as a dependency to allow `samples/prometheus_consul_coordinates.erb`
|
|
241
283
|
to work properly
|
|
@@ -360,7 +402,7 @@ NEW FEATURES:
|
|
|
360
402
|
|
|
361
403
|
## 1.10.1 (February 28, 2019)
|
|
362
404
|
|
|
363
|
-
|
|
405
|
+
BUG FIXES:
|
|
364
406
|
|
|
365
407
|
* Ensure that timeline sort properly events when healthchecks are removed (eg: maintenance)
|
|
366
408
|
|
|
@@ -383,7 +425,7 @@ IMPROVEMENTS:
|
|
|
383
425
|
|
|
384
426
|
## 1.9.8 (January 16, 2019)
|
|
385
427
|
|
|
386
|
-
|
|
428
|
+
BUG FIXES:
|
|
387
429
|
|
|
388
430
|
* When default value was the same as real value, endpoints were always marked as
|
|
389
431
|
dirty, thus rendering of templates did never succeed.
|
|
@@ -399,7 +441,7 @@ IMPROVEMENTS:
|
|
|
399
441
|
|
|
400
442
|
## 1.9.6 (January 15, 2019)
|
|
401
443
|
|
|
402
|
-
|
|
444
|
+
BUG FIXES:
|
|
403
445
|
|
|
404
446
|
* Keep connections open properly as it increase timeouts on Consul servers on
|
|
405
447
|
very large templates
|
|
@@ -410,7 +452,7 @@ IMPROVEMENTS:
|
|
|
410
452
|
|
|
411
453
|
## 1.9.5 (January 14, 2019)
|
|
412
454
|
|
|
413
|
-
|
|
455
|
+
BUG FIXES:
|
|
414
456
|
|
|
415
457
|
* Ensure to always re-open Connection to Consul agent in case of network error
|
|
416
458
|
|
|
@@ -460,11 +502,11 @@ IMPROVEMENTS:
|
|
|
460
502
|
|
|
461
503
|
OPTIMIZATIONS:
|
|
462
504
|
|
|
463
|
-
* Better network
|
|
505
|
+
* Better network usage because of X-Consul-Index parsing bug
|
|
464
506
|
|
|
465
|
-
|
|
507
|
+
BUG FIXES:
|
|
466
508
|
|
|
467
|
-
* value.endpoint.x_consul_index now works as expected
|
|
509
|
+
* `value.endpoint.x_consul_index` now works as expected
|
|
468
510
|
|
|
469
511
|
IMPROVEMENTS:
|
|
470
512
|
|
|
@@ -504,7 +546,7 @@ NEW FEATURES:
|
|
|
504
546
|
|
|
505
547
|
## 1.8.1 (December 12, 2018)
|
|
506
548
|
|
|
507
|
-
|
|
549
|
+
BUG FIXES:
|
|
508
550
|
|
|
509
551
|
* Properly fill `template_info` strtucture when hot reload is performed so templates using
|
|
510
552
|
`template_info()` new function can behave nicely.
|
|
@@ -613,8 +655,8 @@ IMPROVEMENTS:
|
|
|
613
655
|
* [Prometheus template](samples/metrics.erb) to export easily Consul
|
|
614
656
|
informations about nodes, datacenters and all services states
|
|
615
657
|
* Code style cleanup + travis now enforces Rubocop
|
|
616
|
-
* Remove criteo references in spec files thanks to @pierrecdn
|
|
617
|
-
* Bitrate display more consistent thanks to @pierrecdn
|
|
658
|
+
* Remove criteo references in spec files thanks to [@pierrecdn](https://github.com/pierrecdn)
|
|
659
|
+
* Bitrate display more consistent thanks to [@pierrecdn](https://github.com/pierrecdn)
|
|
618
660
|
|
|
619
661
|
## 1.5.3 (September 24, 2018)
|
|
620
662
|
|
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
|
-
-
|
|
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
|
|
data/TemplateAPI.md
CHANGED
|
@@ -388,7 +388,7 @@ name or its ID. If DC is specified, will lookup for given node in another datace
|
|
|
388
388
|
|
|
389
389
|
[Find all the checks](https://www.consul.io/api/health.html#list-checks-for-service) of a given service.
|
|
390
390
|
|
|
391
|
-
##
|
|
391
|
+
## checks_in_state(check_state, dc: nil, [agent: consul_agent_address])
|
|
392
392
|
|
|
393
393
|
[Find all the checks in a given state](https://www.consul.io/api-docs/health#list-checks-in-state) in the whole cluster.
|
|
394
394
|
|
data/bin/consul-templaterb
CHANGED
|
@@ -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('-
|
|
229
|
-
|
|
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]
|
|
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
|
-
|
|
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
|
|
@@ -359,6 +375,11 @@ ARGV.each do |tpl|
|
|
|
359
375
|
consul_engine.add_template(tpl, dest)
|
|
360
376
|
end
|
|
361
377
|
|
|
378
|
+
if consul_engine.templates.count.zero?
|
|
379
|
+
puts 'You must specify at least one template as arg or using -t'
|
|
380
|
+
exit 255
|
|
381
|
+
end
|
|
382
|
+
|
|
362
383
|
template_manager = Consul::Async::EndPointsManager.new(consul_conf, vault_conf, consul_engine.templates, options[:erb][:trim_mode])
|
|
363
384
|
|
|
364
385
|
Signal.trap('USR1', 'IGNORE') unless Gem.win_platform?
|
|
@@ -225,9 +225,34 @@ module Consul
|
|
|
225
225
|
retry_in / 2 + Consul::Async::Utilities.random.rand(retry_in)
|
|
226
226
|
end
|
|
227
227
|
|
|
228
|
+
# rubocop:disable Style/ClassVars
|
|
229
|
+
def _last_429
|
|
230
|
+
@@_last_429 ||= { count: 0 }
|
|
231
|
+
end
|
|
232
|
+
# rubocop:enable Style/ClassVars
|
|
233
|
+
|
|
228
234
|
def _handle_error(http, consul_index)
|
|
229
235
|
retry_in = _compute_retry_in([600, conf.retry_duration + 2**@consecutive_errors].min)
|
|
230
|
-
|
|
236
|
+
if http.response_header.status == 429
|
|
237
|
+
_last_429
|
|
238
|
+
retry_in = 60 + Consul::Async::Utilities.random.rand(180) if retry_in < 60
|
|
239
|
+
_last_429[:time] = Time.now.utc
|
|
240
|
+
_last_429[:count] += 1
|
|
241
|
+
if (_last_429[:count] % 10) == 1
|
|
242
|
+
if _last_429[:count] == 1
|
|
243
|
+
::Consul::Async::Debug.puts_error "Rate limiting detected on Consul side (HTTP 429)!\n\n" \
|
|
244
|
+
"******************************* CONFIGURATION ISSUE DETECTED *******************************\n" \
|
|
245
|
+
"* Too many simultaneous connections for Consul agent #{conf.base_url}\n" \
|
|
246
|
+
"* You should tune 'limits.http_max_conns_per_client' to a higher value.\n" \
|
|
247
|
+
"* This program will behave badly until you change this.\n" \
|
|
248
|
+
"* See https://www.consul.io/docs/agent/options.html#http_max_conns_per_client for more info\n" \
|
|
249
|
+
"********************************************************************************************\n\n"
|
|
250
|
+
end
|
|
251
|
+
::Consul::Async::Debug.puts_error "[#{path}] Too many conns to #{conf.base_url}, errors=#{_last_429[:count]} - Retry in #{retry_in}s #{stats.body_bytes_human}"
|
|
252
|
+
end
|
|
253
|
+
else
|
|
254
|
+
::Consul::Async::Debug.puts_error "[#{path}] X-Consul-Index:#{consul_index} - #{http.error} - Retry in #{retry_in}s #{stats.body_bytes_human}"
|
|
255
|
+
end
|
|
231
256
|
@consecutive_errors += 1
|
|
232
257
|
http_result = HttpResponse.new(http)
|
|
233
258
|
EventMachine.add_timer(retry_in) do
|
|
@@ -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
|