Skip to content

Fix race in health state - #10781

Merged
knative-prow-robot merged 1 commit into
knative:masterfrom
julz:stateyourcase
Feb 15, 2021
Merged

knative-prow-robot merged 1 commit into
knative:masterfrom
julz:stateyourcase

Conversation

@julz

@julz julz commented Feb 15, 2021

Copy link
Copy Markdown
Contributor

The DrainHandlerFunc creates a channel on-demand when it is called, but this can theoretically occur after a drain has completed, in which case the channel will never be closed (drainFinished() just exits if drainCh is nil..), and drain will never return.

(This is super unlikely to occur in practice since drain takes some time to complete by which time we've ~always called DrainHandlerFunc, but worth fixing in case we ever make draining quicker!).

Release Note

Fixes a race in Queue Proxy drain logic that could, in a very unlikely edge case, lead to the pre-stop hook not exiting even though draining has finished

/assign @markusthoemmes @vagababov

The DrainHandlerFunc creates a channel on-demand when it is called, but
this can theoretically occur _after_ a drain has completed, in which
case the channel is never closed (drainFinished checks nil), so drain
will never return.

This commit introduces a constructor for State so we can ensure drainCh
is always set on creation, avoiding the on-demand channel creation.
@google-cla google-cla Bot added the cla: yes Indicates the PR's author has signed the CLA. label Feb 15, 2021
@knative-prow-robot knative-prow-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. area/autoscale area/networking labels Feb 15, 2021
@codecov

codecov Bot commented Feb 15, 2021

Copy link
Copy Markdown

Codecov Report

Merging #10781 (ba17883) into master (60fd6be) will decrease coverage by 0.00%.
The diff coverage is 75.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #10781      +/-   ##
==========================================
- Coverage   88.06%   88.05%   -0.01%     
==========================================
  Files         188      188              
  Lines        9062     9060       -2     
==========================================
- Hits         7980     7978       -2     
  Misses        829      829              
  Partials      253      253              
Impacted Files Coverage Δ
cmd/queue/main.go 0.51% <0.00%> (ø)
pkg/queue/health/health_state.go 100.00% <100.00%> (ø)
pkg/autoscaler/statforwarder/leases.go 76.97% <0.00%> (-1.44%) ⬇️
pkg/reconciler/configuration/configuration.go 88.28% <0.00%> (+1.56%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 60fd6be...dbf2de0. Read the comment docs.

@markusthoemmes markusthoemmes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm trying to figure out why we did this lazily 😂. Is there a version in the history where we reset and reused the state maybe?

/assign @mattmoor
Maybe you recall?

Looks sound from today's perspective though.

@knative-prow-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: julz, markusthoemmes

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

The pull request process is described here

Details 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

@mattmoor

Copy link
Copy Markdown
Contributor

/lgtm

I don't recall anything intentional. We should consider coalescing this with the Drainer in knative.dev/pkg at some point or at least identifying the motivations for divergence.

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 15, 2021
@julz

julz commented Feb 15, 2021

Copy link
Copy Markdown
Contributor Author

looks like it went in in #3347, and there was no obvious reason it couldn't be in constructor,. I guess we were trying to make zero-value work maybe 🤷

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/autoscale 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.

5 participants