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

xds: update nonce even if the ACK/NACK is not sent on wire #3497

Merged
merged 3 commits into from Apr 3, 2020

Conversation

menghanl
Copy link
Contributor

@menghanl menghanl commented Apr 3, 2020

This can happen when the watch is canceled while the response is on wire.

Also, tag ACK/NACK with the stream so nonce for a new stream doesn't get updated by a ACK from the previous stream.

…K is not sent on wire

This can happen when the watch is canceled while the response is on wire.
Copy link
Contributor

@easwars easwars left a comment

Choose a reason for hiding this comment

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

The changes look good apart from the nits that I have mentioned. Also, I guess this will conflict with your other xds_client refactor PR. I should be able to approve that once my last set of comments on the tests are taken care of.

callbackCh.Send(struct{}{})
})
if err := compareXDSRequest(fakeServer.XDSRequestChan, goodCDSRequest, "", ""); err != nil {
t.Fatalf("Failed to receive %s request: %v", "CDS", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Could this just be:

		t.Fatalf("Failed to receive CSD request: %v", err)

Copy link
Contributor

Choose a reason for hiding this comment

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

Or it could just be t.Fatal(err) since the compareXDSRequest() function properly annotates the error that it returns.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.


// Send a good CDS response, this function waits for the ACK with the right
// version.
nonce := sendGoodResp(t, "CDS", fakeServer, versionCDS, goodCDSResponse1, goodCDSRequest, callbackCh)
Copy link
Contributor

Choose a reason for hiding this comment

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

The helper functions in this test file seem to be a little inconsistent in the sense that some just return errors while others call t.Error/Fatal. Given that none of these functions are helpers in the true sense i.e functions whose actions do not depend on the current test, I think we should make them all just return error and return error which are complete with the information as to why the error happened, and thereby the actual test can simply call t.Fatal(err).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can either make them all return error, or make them all call t.Fatal, and mark them as helper().
I added a TODO, and will leave it for later.


// TestV2ClientAckCancelResponseRace verifies if the response and ACK request
// race with cancel (which means the ACK request will not be sent on wire,
// because there's no active watch), the version will still be updates, and the
Copy link
Contributor

Choose a reason for hiding this comment

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

s/updates/updated

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

The comment is actually not accurate. Only the nonce will be updated. The version will not if cancel happens before ACK.

Copy link
Contributor Author

@menghanl menghanl left a comment

Choose a reason for hiding this comment

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

Yes, they will have conflict.
I will merge this in first, and resolve conflicts in the refactor PR. This change needs to be cherry-picked into 1.28.1, so I will keep it small.

callbackCh.Send(struct{}{})
})
if err := compareXDSRequest(fakeServer.XDSRequestChan, goodCDSRequest, "", ""); err != nil {
t.Fatalf("Failed to receive %s request: %v", "CDS", err)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.


// Send a good CDS response, this function waits for the ACK with the right
// version.
nonce := sendGoodResp(t, "CDS", fakeServer, versionCDS, goodCDSResponse1, goodCDSRequest, callbackCh)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can either make them all return error, or make them all call t.Fatal, and mark them as helper().
I added a TODO, and will leave it for later.


// TestV2ClientAckCancelResponseRace verifies if the response and ACK request
// race with cancel (which means the ACK request will not be sent on wire,
// because there's no active watch), the version will still be updates, and the
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

The comment is actually not accurate. Only the nonce will be updated. The version will not if cancel happens before ACK.

@easwars easwars assigned menghanl and unassigned easwars Apr 3, 2020
@menghanl menghanl merged commit a9601d9 into grpc:master Apr 3, 2020
@menghanl menghanl deleted the xds_update_nonce_after_cancel branch April 3, 2020 20:10
menghanl added a commit that referenced this pull request Apr 3, 2020
This can happen when the watch is canceled while the response is on wire.

Also, tag ACK/NACK with the stream so nonce for a new stream doesn't get updated by a ACK from the previous stream.
@easwars easwars assigned menghanl and unassigned menghanl Apr 3, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants