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

Return the behaviour of a new default GRPC client instantiation for every request #3130

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions conformance/utils/grpc/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,9 @@ func validateExpectedResponse(t *testing.T, expected ExpectedResponse) {
func MakeRequestAndExpectEventuallyConsistentResponse(t *testing.T, c Client, timeoutConfig config.TimeoutConfig, gwAddr string, expected ExpectedResponse) {
t.Helper()
validateExpectedResponse(t, expected)
if c == nil {
c = &DefaultClient{Conn: nil}
}
defer c.Close()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While the change does help address the immediate concern, it does seem to reveal a flaw here -- I would expect the client to only be closed by MakeRequestAndExpectEventuallyConsistentResponse() when it was instantiated within MakeRequestAndExpectEventuallyConsistentResponse() itself.

When a non-nil client is passed to the MakeRequestAndExpectEventuallyConsistentResponse(), this function should not own the lifecycle the passed-clients lifecycle.

An implication of this would be that the Client interface should not have the Close function.

Copy link
Contributor Author

@ciarams87 ciarams87 Jun 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review @gauravkghildiyal!

When a non-nil client is passed to the MakeRequestAndExpectEventuallyConsistentResponse(), this function should not own the lifecycle the passed-clients lifecycle.
An implication of this would be that the Client interface should not have the Close function.

That makes a lot of sense to me, but I'm not entirely sure that should be addressed in this PR - the scope here is only to return the DefaultClient behaviour to how it was before. I'd like to defer to @snehachhabria as the original author of #3095 as to the decisions made in this respect.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gauravkghildiyal what you suggested should be done and can be handled in a separate PR. Once this PR is merged, I can handle the suggested changes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sendRPC := func(elapsed time.Duration) bool {
resp, err := c.SendRPC(t, gwAddr, expected, timeoutConfig.MaxTimeToConsistency-elapsed)
Expand Down
3 changes: 0 additions & 3 deletions conformance/utils/suite/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,6 @@ func NewConformanceTestSuite(options ConformanceOptions) (*ConformanceTestSuite,
}

grpcClient := options.GRPCClient
if grpcClient == nil {
grpcClient = &grpc.DefaultClient{Conn: nil}
}

installedCRDs := &apiextensionsv1.CustomResourceDefinitionList{}
err := options.Client.List(context.TODO(), installedCRDs)
Expand Down