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

Upgrade nomad api package to support unix domain sockets. Fixes #3 #4

Merged
merged 6 commits into from
Aug 15, 2024

Conversation

apollo13
Copy link
Contributor

No description provided.

@apollo13 apollo13 marked this pull request as draft August 14, 2024 20:12
@apollo13
Copy link
Contributor Author

apollo13 commented Aug 14, 2024

Mhm, there appears to be an issue with the upgrade, the API cannot reach the testservers :/ I am getting:

2024/08/14 22:23:27 [ERROR] plugin/nomad: getClient failed querying self endpoint: Get "http://127.0.0.1:40221/v1/agent/self": dial tcp 127.0.0.1:40221: connect: connection refused
2024/08/14 22:23:27 [ERROR] plugin/nomad: getClient failed querying self endpoint: Get "http://127.0.0.1:40221/v1/agent/self": dial tcp 127.0.0.1:40221: connect: connection refused
2024/08/14 22:23:27 [ERROR] plugin/nomad: getClient failed querying self endpoint: Get "http://127.0.0.1:40221/v1/agent/self": dial tcp 127.0.0.1:40221: connect: connection refused
2024/08/14 22:23:27 [ERROR] plugin/nomad: getClient failed querying self endpoint: Get "http://127.0.0.1:40221/v1/agent/self": dial tcp 127.0.0.1:40221: connect: connection refused
2024/08/14 22:23:27 [ERROR] plugin/nomad: getClient failed querying self endpoint: Get "http://127.0.0.1:40221/v1/agent/self": dial tcp 127.0.0.1:40221: connect: connection refused
2024/08/14 22:23:27 [ERROR] plugin/nomad: getClient failed querying self endpoint: Get "http://127.0.0.1:40221/v1/agent/self": dial tcp 127.0.0.1:40221: connect: connection refused
2024/08/14 22:23:27 [ERROR] plugin/nomad: getClient failed querying self endpoint: Get "http://127.0.0.1:40221/v1/agent/self": dial tcp 127.0.0.1:40221: connect: connection refused
2024/08/14 22:23:27 [ERROR] plugin/nomad: getClient failed querying self endpoint: Get "http://127.0.0.1:40221/v1/agent/self": dial tcp 127.0.0.1:40221: connect: connection refused
2024/08/14 22:23:27 [ERROR] plugin/nomad: getClient failed querying self endpoint: Get "http://127.0.0.1:40221/v1/agent/self": dial tcp 127.0.0.1:40221: connect: connection refused
2024/08/14 22:23:27 [ERROR] plugin/nomad: getClient failed querying self endpoint: Get "http://127.0.0.1:40221/v1/agent/self": dial tcp 127.0.0.1:40221: connect: connection refused
2024/08/14 22:23:27 [ERROR] plugin/nomad: getClient failed querying self endpoint: Get "http://127.0.0.1:40221/v1/agent/self": dial tcp 127.0.0.1:40221: connect: connection refused
2024/08/14 22:23:27 [ERROR] plugin/nomad: getClient failed querying self endpoint: Get "http://127.0.0.1:40221/v1/agent/self": dial tcp 127.0.0.1:40221: connect: connection refused
2024/08/14 22:23:27 [ERROR] plugin/nomad: getClient failed querying self endpoint: Get "http://127.0.0.1:40221/v1/agent/self": dial tcp 127.0.0.1:40221: connect: connection refused
2024/08/14 22:23:27 [ERROR] plugin/nomad: getClient failed querying self endpoint: Get "http://127.0.0.1:40221/v1/agent/self": dial tcp 127.0.0.1:40221: connect: connection refused
2024/08/14 22:23:27 [ERROR] plugin/nomad: getClient failed querying self endpoint: Get "http://127.0.0.1:40221/v1/agent/self": dial tcp 127.0.0.1:40221: connect: connection refused
2024/08/14 22:23:27 [ERROR] plugin/nomad: getClient failed querying self endpoint: Get "http://127.0.0.1:40221/v1/agent/self": dial tcp 127.0.0.1:40221: connect: connection refused
2024/08/14 22:23:27 [ERROR] plugin/nomad: getClient failed querying self endpoint: Get "http://127.0.0.1:40221/v1/agent/self": dial tcp 127.0.0.1:40221: connect: connection refused
2024/08/14 22:23:27 [ERROR] plugin/nomad: getClient failed querying self endpoint: Get "http://127.0.0.1:40221/v1/agent/self": dial tcp 127.0.0.1:40221: connect: connection refused
2024/08/14 22:23:27 [ERROR] plugin/nomad: getClient failed querying self endpoint: Get "http://127.0.0.1:40221/v1/agent/self": dial tcp 127.0.0.1:40221: connect: connection refused
2024/08/14 22:23:27 [ERROR] plugin/nomad: getClient failed querying self endpoint: Get "http://127.0.0.1:40221/v1/agent/self": dial tcp 127.0.0.1:40221: connect: connection refused
2024/08/14 22:23:27 [ERROR] plugin/nomad: getClient failed querying self endpoint: Get "http://127.0.0.1:40221/v1/agent/self": dial tcp 127.0.0.1:40221: connect: connection refused
--- FAIL: TestNomad (0.01s)
    /home/florian/sources/coredns-nomad/nomad_test.go:154: Expected client2
    /home/florian/sources/coredns-nomad/nomad_test.go:175: Test 0: answer for "example.default.service.nomad." contained 0 results, 1 expected
    /home/florian/sources/coredns-nomad/nomad_test.go:175: Test 1: answer for "fakeipv6.default.service.nomad." contained 0 results, 1 expected
    /home/florian/sources/coredns-nomad/nomad_test.go:175: Test 2: answer for "multi.default.service.nomad." contained 0 results, 3 expected
    /home/florian/sources/coredns-nomad/nomad_test.go:175: Test 3: rcode is "NOERROR", expected "NXDOMAIN"
    /home/florian/sources/coredns-nomad/nomad_test.go:175: Test 4: answer for "example.default.service.nomad." contained 0 results, 1 expected
FAIL
FAIL	github.com/ituoga/coredns-nomad	0.020s
FAIL

any idea what that might be @blinkinglight ?

Nomad config objects cannot get reused any longer because of the
internal state saved in the `url` member.
@apollo13 apollo13 marked this pull request as ready for review August 14, 2024 20:51
@apollo13
Copy link
Contributor Author

Okay, I got this fixed. It is kinda unfortunate that the nomad API is kinda broken here. But essentially NewClient mutates the passed Config and as such should not be reused.

@apollo13
Copy link
Contributor Author

I have added a few further improvements:

  • If only a single client is configured don't bother checking the agent/self endpoint on every getClient -- there is no point in it anyways.
  • If no addresses are configured at all, create a client solely based on DefaultConfig.

@blinkinglight blinkinglight merged commit 1ee763b into ituoga:main Aug 15, 2024
1 check passed
@henrikjohansen
Copy link

👋 Thank you - it works brilliantly 👍

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.

3 participants