mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
Merge pull request #114361 from kerthcet/cleanup/emit-errors-more-precise
Tune the error messages in scheduler cache
This commit is contained in:
commit
bc6afee049
21
pkg/scheduler/internal/cache/cache.go
vendored
21
pkg/scheduler/internal/cache/cache.go
vendored
@ -537,17 +537,22 @@ func (cache *cacheImpl) UpdatePod(oldPod, newPod *v1.Pod) error {
|
|||||||
defer cache.mu.Unlock()
|
defer cache.mu.Unlock()
|
||||||
|
|
||||||
currState, ok := cache.podStates[key]
|
currState, ok := cache.podStates[key]
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf("pod %v(%v) is not added to scheduler cache, so cannot be updated", key, klog.KObj(oldPod))
|
||||||
|
}
|
||||||
|
|
||||||
// An assumed pod won't have Update/Remove event. It needs to have Add event
|
// An assumed pod won't have Update/Remove event. It needs to have Add event
|
||||||
// before Update event, in which case the state would change from Assumed to Added.
|
// before Update event, in which case the state would change from Assumed to Added.
|
||||||
if ok && !cache.assumedPods.Has(key) {
|
if cache.assumedPods.Has(key) {
|
||||||
if currState.pod.Spec.NodeName != newPod.Spec.NodeName {
|
return fmt.Errorf("assumed pod %v(%v) should not be updated", key, klog.KObj(oldPod))
|
||||||
klog.ErrorS(nil, "Pod updated on a different node than previously added to", "podKey", key, "pod", klog.KObj(oldPod))
|
|
||||||
klog.ErrorS(nil, "scheduler cache is corrupted and can badly affect scheduling decisions")
|
|
||||||
klog.FlushAndExit(klog.ExitFlushTimeout, 1)
|
|
||||||
}
|
|
||||||
return cache.updatePod(oldPod, newPod)
|
|
||||||
}
|
}
|
||||||
return fmt.Errorf("pod %v(%v) is not added to scheduler cache, so cannot be updated", key, klog.KObj(oldPod))
|
|
||||||
|
if currState.pod.Spec.NodeName != newPod.Spec.NodeName {
|
||||||
|
klog.ErrorS(nil, "Pod updated on a different node than previously added to", "podKey", key, "pod", klog.KObj(oldPod))
|
||||||
|
klog.ErrorS(nil, "scheduler cache is corrupted and can badly affect scheduling decisions")
|
||||||
|
klog.FlushAndExit(klog.ExitFlushTimeout, 1)
|
||||||
|
}
|
||||||
|
return cache.updatePod(oldPod, newPod)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cache *cacheImpl) RemovePod(pod *v1.Pod) error {
|
func (cache *cacheImpl) RemovePod(pod *v1.Pod) error {
|
||||||
|
Loading…
Reference in New Issue
Block a user