Avoid race in subsequent changes to the same controller #2220
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
/kind bug
What this PR does / why we need it:
One of the test runs has failed with
This has failed on o.cancel = nil in
perf-tests/clusterloader2/pkg/measurement/common/wait_for_controlled_pods.go
Lines 710 to 713 in 19927c1
The cancel is being set in
perf-tests/clusterloader2/pkg/measurement/common/wait_for_controlled_pods.go
Lines 615 to 621 in 83e45df
The problem is that the setting it happens asynchronously (in the separate goroutine) and when the function finishes there is potential race between calling o.cancel and o.SetCancel.
If the object is being changed between o.SetCancel is called, then the attempt to replace it (and Stop previous instance) will fail as here.
The idea for fix is to:
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
/assign @tosi3k