mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
Merge pull request #60831 from resouer/fix-race
Automatic merge from submit-queue (batch tested with PRs 60574, 60666, 60831, 60877, 60357). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Fix data race in node lifecycle controller **What this PR does / why we need it**: Encountered this bug during fixing: https://github.com/kubernetes/kubernetes/pull/60753 There's a data race for `zoneNoExecuteTainter `. ``` --- PASS: TestTaintNodeByCondition (5.72s) PASS ================== WARNING: DATA RACE Write at 0x00c421a8d2f0 by goroutine 1472: runtime.mapassign_faststr() /usr/local/go/src/runtime/hashmap_fast.go:598 +0x0 k8s.io/kubernetes/pkg/controller/nodelifecycle.(*Controller).addPodEvictorForNewZone() /root/code/kubernetes/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/pkg/controller/nodelifecycle/node_lifecycle_controller.go:1053 +0x37d k8s.io/kubernetes/pkg/controller/nodelifecycle.(*Controller).monitorNodeStatus() Previous read at 0x00c421a8d2f0 by goroutine 1471: runtime.mapiterinit() /usr/local/go/src/runtime/hashmap.go:709 +0x0 k8s.io/kubernetes/pkg/controller/nodelifecycle.(*Controller).doNoExecuteTaintingPass() /root/code/kubernetes/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/pkg/controller/nodelifecycle/node_lifecycle_controller.go:459 +0xec k8s.io/kubernetes/pkg/controller/nodelifecycle.(*Controller).(k8s.io/kubernetes/pkg/controller/nodelifecycle.doNoExecuteTaintingPass)-fm() ``` **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes # **Special notes for your reviewer**: **Release note**: ```release-note Fix data race in node lifecycle controller ```
This commit is contained in:
commit
8c00efe653
@ -1054,6 +1054,8 @@ func (nc *Controller) ReducedQPSFunc(nodeNum int) float32 {
|
||||
|
||||
// addPodEvictorForNewZone checks if new zone appeared, and if so add new evictor.
|
||||
func (nc *Controller) addPodEvictorForNewZone(node *v1.Node) {
|
||||
nc.evictorLock.Lock()
|
||||
defer nc.evictorLock.Unlock()
|
||||
zone := utilnode.GetZoneKey(node)
|
||||
if _, found := nc.zoneStates[zone]; !found {
|
||||
nc.zoneStates[zone] = stateInitial
|
||||
|
Loading…
Reference in New Issue
Block a user