Consul tokens not cleaned up if clients restart #20184
Labels
stage/accepted
Confirmed, and intend to work on. No timeline committment though.
theme/consul
theme/service-discovery/consul
theme/workload-identity
type/bug
Nomad version
Issue
When using workload identities with Consul, the Consul ACL tokens for services are derived in an alloc runner
Prerun
hook.nomad/client/allocrunner/consul_hook.go
Lines 75 to 103 in 23e4b7c
But
SetConsulTokens()
only store then in memory.nomad/client/structs/allochook.go
Lines 61 to 71 in 23e4b7c
Since they are not persisted in any kind of durable storage, if the client restarts a new token is generated, leaving the old one behind and never cleaning it up.
Reproduction steps
Start a Consul agent with ACL enabled.
Bootstrap Consul ACL system.
Start a Nomad server with the following configuration.
Start a Nomad agent with the following configuration.
Configure Consul JWT auth method for Nomad.
Register job with Consul service.
Verify an ACL token for the service was created.
Stop Nomad client and start it again.
Verify a new Consul ACL token was created.
Stop
example
job.Verify first ACL token is left behind.
Expected Result
The first ACL token created is recovered when the client restarts.
Actual Result
A new ACL token is created, leaving the old one behind.
The text was updated successfully, but these errors were encountered: