Fix out of bounds error on non-64-bit machines

parent a6e35148
...@@ -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