Skip to content

Commit

Permalink
Pass the user specified token to consul maintenance primitive
Browse files Browse the repository at this point in the history
Otherwise we use the "globally configured" token, that may change at
any point in the chef run (because of diplomat model).
Let's specify the token when requested. i.e. all checks calls.

If an incorrect token is used, it may lacks permission to detect the
node/service maintenance.

Change-Id: I00b6a512e487151931d9b811eaead162b4ddde57
  • Loading branch information
Annih committed Jun 4, 2024
1 parent 4be96ef commit 7bdc0ae
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libraries/primitive_consul_maintenance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def maintenance?
# we observed in very rare cases that maintenance status could be not up to date
# for ~5s after a restart
results = 3.times.map do
checks = Diplomat::Agent.checks
checks = Diplomat::Agent.checks(token: @options[:consul_token])
maint_status = checks.dig(@maintenance_key, 'Status')
sleep(@options[:check_interval])
maint_status == 'critical' && !checks.dig(@maintenance_key, 'Notes').nil?
Expand All @@ -40,7 +40,7 @@ def maintenance?

# @return [String, nil] reason of the maintenance, if any. Nil otherwise
def maintenance_reason
checks = Diplomat::Agent.checks
checks = Diplomat::Agent.checks(token: @options[:consul_token])
checks.dig(@maintenance_key, 'Notes')
end

Expand Down

0 comments on commit 7bdc0ae

Please sign in to comment.