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

Wait for RPC handlers to drain before checking subscription state #4771

Merged
merged 2 commits into from
Jan 3, 2024

Conversation

azdagron
Copy link
Member

@azdagron azdagron commented Jan 3, 2024

The Workload API handler tests assert that cache subscriptions are properly closed. To test for this, they wait until the gRPC server is done serving (e.g. GracefulStop) and then check the state of returned subscriptions.

Unfortunately, if a streaming RPC is cancelled on the client side (e.g. context cancellation), it can result in the RPC to "complete" on the server side before the actual handler implementation has returned. This became more apparent with a recent gRPC change (see #4746) which has caused CI/CD failures.

To mitigate this, this change updates the tests to use a stats handler to track how many RPCs are still "open" and waits for all RPCs to close before checking the subscription handler.

Signed-off-by: Andrew Harding <azdagron@gmail.com>
)
workloadPB.RegisterSpiffeWorkloadAPIServer(server, handler)
addr := spiretest.ServeGRPCServerOnTempUDSSocket(t, server)
t.Cleanup(func() { server.Stop() })
Copy link
Member Author

Choose a reason for hiding this comment

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

This is already done by spiretest.ServeGRPCServerOnTempUDSSocket and is redundant.

@MarcosDY MarcosDY merged commit dedb0c1 into spiffe:main Jan 3, 2024
32 checks passed
@MarcosDY MarcosDY added this to the 1.9.0 milestone Jan 3, 2024
@azdagron azdagron deleted the wait-for-rpcs-before-checking branch January 3, 2024 16:40
sriyer pushed a commit to spire-vault/spire that referenced this pull request Feb 23, 2024
Signed-off-by: Andrew Harding <azdagron@gmail.com>
rushi47 pushed a commit to rushi47/spire that referenced this pull request Apr 11, 2024
Signed-off-by: Andrew Harding <azdagron@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants