-
Notifications
You must be signed in to change notification settings - Fork 16
Integrate consul-server-connection-manager library #449
Conversation
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.
making progress.
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.
More comments, maybe we can pair tomorrow on this.
8e02541
to
6defaa5
Compare
So I went ahead and validated this with the following agentless configurations that pretty much exercise the majority auth method + tls configuration for the discovery library: internal server Despite the introduction of all the more flaky unit tests due to the upstream issues with the manager library use of the grpc |
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.
Minor notes/questions but mostly LGTM!
AuthConfig: AuthConfig{ | ||
Method: "nonexistent", | ||
Token: "token", | ||
}, | ||
isTest: true, | ||
})) | ||
require.Contains(t, buffer.String(), "error logging into consul") | ||
require.Contains(t, buffer.String(), "no such file or directory") |
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.
This seems like a weird error, is it because we're expecting a file path for the bearer token or something? Should we add a test for if it's present but invalid, and/or is there an actual implementation issue here where setting the Token
field in an AuthConfig
isn't handled properly?
} | ||
|
||
func TestRunExecLoginSuccessRegistrationFail(t *testing.T) { | ||
t.Parallel() |
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 assuming this was needed because of the un-threadsafe behavior of how consul-server-connection-manager is registering the gRPC load balancer? Refs hashicorp/consul-server-connection-manager#25
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.
👍
if !c.config.PlainText { | ||
config.TLS = c.config.TLS | ||
} |
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 was curious about the best way to check for whether TLS should be used for these gRPC connections - this approach seems reasonable, in
I took a different approach more similar to internal/commands/server/server.go
and internal/commands/exec/exec.go
though, checking
if consulAPITLSConfig.CAFile != "" || len(consulAPITLSConfig.CAPem) > 0
It looks like consul-dataplane is asking for an explicit -tls-disabled
configuration https://github.com/hashicorp/consul-dataplane/#configuration-reference
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, so Consul Dataplane uses that to see whether or not it should set a TLS
parameter in the underlying library that we share usage of. We're doing the same with a PlainText
option to the struct. For our codebase we have knowledge of the scheme we're trying to use to connect, so I just used that -- if we're over http
we use plain text, if https
use TLS.
internal/testing/e2e/consul.go
Outdated
@@ -531,12 +534,12 @@ func CreateConsulACLPolicy(ctx context.Context, cfg *envconf.Config) (context.Co | |||
return ctx, nil | |||
} | |||
env := consulEnvironment.(*consulTestEnvironment) | |||
token, _, err := env.consulClient.ACL().Bootstrap() | |||
token, _, err := env.consulClient.Internal().ACL().Bootstrap() |
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.
Could we add a ACL()
method to the client wrapper since we plan to remove the Internal()
catch-all soon?
// this should go away once we implement auth in the server bootup | ||
consulClient.AddHeader("x-consul-token", ConsulInitialManagementToken(ctx)) | ||
consulClient.Internal().AddHeader("x-consul-token", ConsulInitialManagementToken(ctx)) |
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.
Is this still needed at all now that we're using the consul-server-connection-manager integrated login flow?
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.
Yes, this is the client that gets passed around with the root auth token in our tests so that we can actually check what's in Consul.
gwTesting "github.com/hashicorp/consul-api-gateway/internal/testing" | ||
) | ||
|
||
func TestRunExecLoginError(t *testing.T) { | ||
t.Parallel() | ||
type testDPServer struct{} |
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.
Do we not actually need to mock the WatchServers
method anywhere? Are we only exercising that in e2e tests?
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.
No, we don't -- this is just a gRPC server that stubs out the endpoints. So the library actually hits this and issues real API calls against this. It's almost like using httptest
.
0ea29e6
to
ad01725
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.
LGTM -- We'll want to hammer this some more with the helm changes to make sure we have all of our myriad of configurations fully vetted and documented.
Changes proposed in this PR:
How I've tested this PR:
How I expect reviewers to test this PR:
Checklist: