Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport of api: only set url field in config if previously unset into release/1.8.x #23787

Merged

Conversation

hc-github-team-nomad-core
Copy link
Contributor

Backport

This PR is auto-generated from #23785 to be assessed for backporting due to the inclusion of the label backport/1.8.x.

The below text is copied from the body of the original PR.


In #16872 we added support for configuring the API client with a unix domain socket. In order to set the host correctly, we parse the address before mutating the Address field in the configuration. But this prevents the configuration from being reused across multiple clients, as the next time we parse the address it will no longer be pointing to the socket. This breaks consumers like the autoscaler, which reuse the API config between plugins.

Update the NewClient constructor to only override the url field if it hasn't already been parsed. Include a test demonstrating safe reuse with a unix domain socket.

Ref: hashicorp/nomad-autoscaler#944
Ref: hashicorp/nomad-autoscaler#945


Note for reviewers: in some hypothetical "v2" of the API I'd like to have some kind of options or builder pattern for the client config where we can "consume" the config. But for the moment getting the Config to be safely reusable seems like the best approach to avoid further backwards-incompatibility.


Overview of commits

@tgross tgross merged commit 09b2447 into release/1.8.x Aug 9, 2024
20 checks passed
@tgross tgross deleted the backport/api-unix-socket-config/nicely-amazed-halibut branch August 9, 2024 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants