mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 05:27:21 +00:00
Fix out of bounds error on non-64-bit machines
This commit is contained in:
parent
a6e351484e
commit
52abbeffe6
@ -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{}) {
|
|||||||
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{}) {
|
|||||||
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)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user