-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Error out consul connect envoy
if agent explicitly disabled grpc
#15794
Conversation
6765016
to
1a8accb
Compare
command/connect/envoy/envoy.go
Outdated
c.UI.Error(fmt.Sprintf("Error connecting to Consul agent: %s", err)) | ||
return g, fmt.Errorf("Could not look up xDS port: %w", err) |
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'm unsure if the return was missed here or we intentionally went on to default to 8502
. It looks safe to error here since if the call to Agent.Self
doesn't yield any port, we probably don't want the command to continue.
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.
It can't error out because typically agent:read
is not granted to sidecars, which is required for /v1/agent/self
. The existing code did the agent self lookup as an UX optimization.
Instead you could pick whichever port we already calculated and do a super simple net.Dial
with a short timeout and see if the port is even open instead, which wouldn't even need ACL tokens.
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.
Yeah, I'm not sure why it never errored-out before. I assume it was to enable some backwards compatibility with old APIs that didn't include the port. I don't honestly know the history on this particular area of code, aside from the recent changes I made. I'll have to think about it quite a bit, because there might be some situation where the API is not available, but gRPC is.
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.
Nevermind. RB already answered the question.
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.
@rboyer I ended up logging and defaulting only if it's an ACL perm denied and otherwise erroring out.
1a8accb
to
1a5a2fb
Compare
1bd5e3e
to
fff2726
Compare
WantArgs: BootstrapTplArgs{ | ||
ProxyCluster: "test-proxy", | ||
ProxyID: "test-proxy", | ||
// We don't know this til after the lookup so it will be empty in the | ||
// initial args call we are testing here. | ||
ProxySourceService: "", | ||
// Should resolve IP, note this might not resolve the same way | ||
// everywhere which might make this test brittle but not sure what else | ||
// to do. | ||
GRPC: GRPC{ | ||
AgentAddress: "127.0.0.1", | ||
AgentPort: "8502", | ||
}, | ||
}, |
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.
WantArgs is never evaluated if WantErr exists so I removed it
962dd94
to
7957ace
Compare
7957ace
to
59ea55b
Compare
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.
👍
f77c705
to
6df7ad4
Compare
Co-authored-by: Paul Glass <pglass@hashicorp.com>
6df7ad4
to
1788be7
Compare
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Description
Error out if no grpc ports are returned by
/v1/agent/self
instead of defaulting to 8502.Update tests to reflect Consul's new default behavior to enable grpc TLS (#15302)
Testing & Reproduction steps
PR Checklist