Unverified Commit 85aa6d24 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #65596 from liggitt/out-of-bounds

Automatic merge from submit-queue. 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 out of bounds error on non-64-bit machines This fixes an out of bounds error when running the controllers on a 32-bit machine ``` W0628 17:52:30.171975 1 node_lifecycle_controller.go:782] Missing timestamp for Node kube-master. Assuming now as a timestamp. I0628 17:52:30.172115 1 taint_manager.go:205] Starting NoExecuteTaintManager panic: runtime error: index out of range goroutine 1740 [running]: k8s.io/kubernetes/pkg/controller/nodelifecycle/scheduler.(*NoExecuteTaintManager).Run.func1(0x165e6000, 0x8, 0x15984100) /workspace/anago-v1.11.0-rc.3.3+91e7b4fd31fcd3/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/pkg/controller/nodelifecycle/scheduler/taint_manager.go:229 +0x1f8 created by k8s.io/kubernetes/pkg/controller/nodelifecycle/scheduler.(*NoExecuteTaintManager).Run /workspace/anago-v1.11.0-rc.3.3+91e7b4fd31fcd3/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/pkg/controller/nodelifecycle/scheduler/taint_manager.go:217 +0x27c ``` See https://play.golang.org/p/rIpicHGHtiT for an example of the coercion overflow /assign @wojtek-t /kind bug ```release-note fixes an out of range panic in the NoExecuteTaintManager controller when running a non-64-bit build ```
parents 8563443a 52abbeff
...@@ -80,10 +80,10 @@ func (p *podUpdateItem) nodeName() string { ...@@ -80,10 +80,10 @@ func (p *podUpdateItem) nodeName() string {
return "" return ""
} }
func hash(val string) int { func hash(val string, max int) int {
hasher := fnv.New32a() hasher := fnv.New32a()
io.WriteString(hasher, val) io.WriteString(hasher, val)
return int(hasher.Sum32()) return int(hasher.Sum32() % uint32(max))
} }
// NoExecuteTaintManager listens to Taint/Toleration changes and is responsible for removing Pods // NoExecuteTaintManager listens to Taint/Toleration changes and is responsible for removing Pods
...@@ -221,12 +221,12 @@ func (tc *NoExecuteTaintManager) Run(stopCh <-chan struct{}) { ...@@ -221,12 +221,12 @@ func (tc *NoExecuteTaintManager) Run(stopCh <-chan struct{}) {
break break
} }
nodeUpdate := item.(*nodeUpdateItem) nodeUpdate := item.(*nodeUpdateItem)
hash := hash(nodeUpdate.name()) hash := hash(nodeUpdate.name(), workers)
select { select {
case <-stopCh: case <-stopCh:
tc.nodeUpdateQueue.Done(item) tc.nodeUpdateQueue.Done(item)
break break
case tc.nodeUpdateChannels[hash%workers] <- nodeUpdate: case tc.nodeUpdateChannels[hash] <- nodeUpdate:
} }
tc.nodeUpdateQueue.Done(item) tc.nodeUpdateQueue.Done(item)
} }
...@@ -239,12 +239,12 @@ func (tc *NoExecuteTaintManager) Run(stopCh <-chan struct{}) { ...@@ -239,12 +239,12 @@ func (tc *NoExecuteTaintManager) Run(stopCh <-chan struct{}) {
break break
} }
podUpdate := item.(*podUpdateItem) podUpdate := item.(*podUpdateItem)
hash := hash(podUpdate.nodeName()) hash := hash(podUpdate.nodeName(), workers)
select { select {
case <-stopCh: case <-stopCh:
tc.podUpdateQueue.Done(item) tc.podUpdateQueue.Done(item)
break break
case tc.podUpdateChannels[hash%workers] <- podUpdate: case tc.podUpdateChannels[hash] <- podUpdate:
} }
tc.podUpdateQueue.Done(item) tc.podUpdateQueue.Done(item)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment