Skip to content

Commit

Permalink
config: use URL method to get Nomad address for plugins
Browse files Browse the repository at this point in the history
For #944 we fixed the Nomad API package so that it no longer mutated the private
`url` field if previously set, which allowed reusing an `api.Config` object
between clients when a unix domain socket was in use.

However, the autoscaler plugins for Nomad strategy and target don't use the
`api.Config` object we parse directly and instead get a map of string->string
derived from that config so it can be passed over the go-plugin interface. This
mapping did not account for the `Address` field being mutated when unix domain
sockets are in use, so the bug was not actually fixed.

Update the mapping to use the safe `URL()` method on the config, rather than
reading the `Address` field.

Fixes: #955
Ref: hashicorp/nomad#23785
  • Loading branch information
tgross committed Sep 5, 2024
1 parent b7ded59 commit 4d068d3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion sdk/helper/nomad/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func MergeMapWithAgentConfig(m map[string]string, cfg *api.Config) {
}

if cfg.Address != "" && m[configKeyNomadAddress] == "" {
m[configKeyNomadAddress] = cfg.Address
m[configKeyNomadAddress] = cfg.URL().String()
}
if cfg.Region != "" && m[configKeyNomadRegion] == "" {
m[configKeyNomadRegion] = cfg.Region
Expand Down

0 comments on commit 4d068d3

Please sign in to comment.