Merge pull request #111816 from kidddddddddddddddddddddd/feat/FlushAndExit

replace os.Exit with FlushAndExit
This commit is contained in:
Kubernetes Prow Robot 2022-08-23 19:01:19 -07:00 committed by GitHub
commit 84f9aaaf5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,7 +18,6 @@ package cache
import ( import (
"fmt" "fmt"
"os"
"sync" "sync"
"time" "time"
@ -544,7 +543,7 @@ func (cache *cacheImpl) UpdatePod(oldPod, newPod *v1.Pod) error {
if currState.pod.Spec.NodeName != newPod.Spec.NodeName { if currState.pod.Spec.NodeName != newPod.Spec.NodeName {
klog.ErrorS(nil, "Pod updated on a different node than previously added to", "pod", klog.KObj(oldPod)) klog.ErrorS(nil, "Pod updated on a different node than previously added to", "pod", klog.KObj(oldPod))
klog.ErrorS(nil, "scheduler cache is corrupted and can badly affect scheduling decisions") klog.ErrorS(nil, "scheduler cache is corrupted and can badly affect scheduling decisions")
os.Exit(1) klog.FlushAndExit(klog.ExitFlushTimeout, 1)
} }
return cache.updatePod(oldPod, newPod) return cache.updatePod(oldPod, newPod)
} }
@ -570,7 +569,7 @@ func (cache *cacheImpl) RemovePod(pod *v1.Pod) error {
// An empty NodeName is possible when the scheduler misses a Delete // An empty NodeName is possible when the scheduler misses a Delete
// event and it gets the last known state from the informer cache. // event and it gets the last known state from the informer cache.
klog.ErrorS(nil, "scheduler cache is corrupted and can badly affect scheduling decisions") klog.ErrorS(nil, "scheduler cache is corrupted and can badly affect scheduling decisions")
os.Exit(1) klog.FlushAndExit(klog.ExitFlushTimeout, 1)
} }
} }
return cache.removePod(currState.pod) return cache.removePod(currState.pod)
@ -748,7 +747,7 @@ func (cache *cacheImpl) cleanupAssumedPods(now time.Time) {
ps, ok := cache.podStates[key] ps, ok := cache.podStates[key]
if !ok { if !ok {
klog.ErrorS(nil, "Key found in assumed set but not in podStates, potentially a logical error") klog.ErrorS(nil, "Key found in assumed set but not in podStates, potentially a logical error")
os.Exit(1) klog.FlushAndExit(klog.ExitFlushTimeout, 1)
} }
if !ps.bindingFinished { if !ps.bindingFinished {
klog.V(5).InfoS("Could not expire cache for pod as binding is still in progress", klog.V(5).InfoS("Could not expire cache for pod as binding is still in progress",