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

Fix race condition in timeoutHandler.ServeHTTP #7138

Conversation

JRBANCEL
Copy link
Contributor

@JRBANCEL JRBANCEL commented Mar 4, 2020

Proposed Changes

  • If a panic happens in the inner handler after a timeout, panicChan will be closed because ServeHTTP would have returned and called defer close(panicChan). Then, the write to the closed panicChan will panic. A channel should always be closed in the sending goroutine if there is a single sender.
  • Simplified the code by using a single channel

/assign @markusthoemmes
/assign @vagababov

@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Mar 4, 2020
@knative-prow-robot knative-prow-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Mar 4, 2020
Copy link
Contributor

@knative-prow-robot knative-prow-robot left a comment

Choose a reason for hiding this comment

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

@JRBANCEL: 0 warnings.

In response to this:

Proposed Changes

  • If a panic happens in the inner handler after a timeout, panicChan will be closed because ServeHTTP would have returned and called defer close(panicChan). Then, the write to the closed panicChan will panic. A channel should always be closed in the sending goroutine if there is a single sender.
  • Simplified the code by using a single channel

/assign @markusthoemmes
/assign @vagababov

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@knative-test-reporter-robot

The following jobs failed:

Test name Triggers Retries
pull-knative-serving-unit-tests 0/3

Failed non-flaky tests preventing automatic retry of pull-knative-serving-unit-tests:

pkg/reconciler/autoscaling/kpa.TestControllerSynchronizesCreatesAndDeletes

@JRBANCEL JRBANCEL force-pushed the fix-race-condition-timeout-handler branch 2 times, most recently from 7d0a738 to 2487038 Compare March 4, 2020 19:27
@JRBANCEL JRBANCEL force-pushed the fix-race-condition-timeout-handler branch from 2487038 to 1c4382b Compare March 4, 2020 19:35
@knative-metrics-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-knative-serving-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/queue/timeout.go 90.9% 90.7% -0.2

Copy link
Contributor

@vagababov vagababov left a comment

Choose a reason for hiding this comment

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

/lgtm

pkg/queue/timeout.go Outdated Show resolved Hide resolved
pkg/queue/timeout.go Outdated Show resolved Hide resolved
pkg/queue/timeout.go Outdated Show resolved Hide resolved
@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 4, 2020
@vagababov
Copy link
Contributor

/approve

@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JRBANCEL, vagababov

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 4, 2020
@knative-prow-robot knative-prow-robot merged commit 1cab811 into knative:master Mar 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/networking cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants