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

gin: do not use gin context after returning response #3398

Merged
merged 1 commit into from
Jan 10, 2025
Merged
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
5 changes: 2 additions & 3 deletions pkg/apiserver/controllers/v1/decisions.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,6 @@
func (c *Controller) StreamDecision(gctx *gin.Context) {
var err error

ctx := gctx.Request.Context()

streamStartTime := time.Now().UTC()

bouncerInfo, err := getBouncerFromContext(gctx)
Expand Down Expand Up @@ -426,7 +424,8 @@

if err == nil {
// Only update the last pull time if no error occurred when sending the decisions to avoid missing decisions
if err := c.DBClient.UpdateBouncerLastPull(ctx, streamStartTime, bouncerInfo.ID); err != nil {
// Do not reuse the context provided by gin because we already have sent the response to the client, so there's a chance for it to already be canceled
if err := c.DBClient.UpdateBouncerLastPull(context.Background(), streamStartTime, bouncerInfo.ID); err != nil {

Check warning on line 428 in pkg/apiserver/controllers/v1/decisions.go

View check run for this annotation

Codecov / codecov/patch

pkg/apiserver/controllers/v1/decisions.go#L427-L428

Added lines #L427 - L428 were not covered by tests
log.Errorf("unable to update bouncer '%s' pull: %v", bouncerInfo.Name, err)
}
}
Expand Down
Loading