-
Notifications
You must be signed in to change notification settings - Fork 2k
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
fingerprint: update consul fingerprinter with additional attributes #10699
Conversation
…individual attributes This PR refactors the ConsulFingerprint implementation, breaking individual attributes into individual functions to make testing them easier. This is in preparation for additional extractors about to be added. Behavior should be otherwise unchanged. It adds the attribute consul.sku, which can be used to differentiate between Consul OSS vs Consul ENT.
This PR adds new probes for detecting these new Consul related attributes: Consul namespaces are a Consul enterprise feature that may be disabled depending on the enterprise license associated with the Consul servers. Having this attribute available will enable Nomad to properly decide whether to query the Consul Namespace API. Consul connect must be explicitly enabled before Connect APIs will work. Currently Nomad only checks for a minimum Consul version. Having this attribute available will enable Nomad to properly schedule Connect tasks only on nodes with a Consul agent that has Connect enabled. Consul connect requires the grpc port to be explicitly set before Connect APIs will work. Currently Nomad only checks for a minimal Consul version. Having this attribute available will enable Nomad to schedule Connect tasks only on nodes with a Consul agent that has the grpc listener enabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Thanks for splitting out the refactoring and the new work commits, too, that made it a lot easier to get my head around for review.
|
||
t.Run("grpc set", func(t *testing.T) { | ||
s, ok := fp.grpc(consulInfo{ | ||
"DebugConfig": {"GRPCPort": 8502.0}, // JSON numbers are floats |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// JSON numbers are floats
sigh 😀
@@ -1,7 +1,8 @@ | |||
package fingerprint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test refactoring you've done here is really nice 👍
// indicate the Agent is available now | ||
if f.lastState == consulUnavailable { | ||
f.logger.Info("consul agent is available") | ||
func (f *ConsulFingerprint) server(info consulInfo) (string, bool) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love how legible this entire ConsulFingerprint
becomes with these extractor functions.
This refactoring does make me realize that if Consul were to push a backwards incompatible JSON we could potentially panic Nomad when we do the type cast. Probably something for future robustness work to worry about rather than this PR though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we're actually okay (for panics) on type changes - each of these type casts is in the context of a type check which will simply become false. The attributes will end up being removed which isn't great, of course, and I'll probably have a few choice words with Consul team 😅
Co-authored-by: Tim Gross <[email protected]>
I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions. |
0479167
b3254f6
Closes #10688