From b5f0c34ef1d90c77c86966df290e3e33033f1e58 Mon Sep 17 00:00:00 2001 From: kidddddddddddddddddddddd <1062602710@qq.com> Date: Fri, 12 Aug 2022 17:34:13 +0800 Subject: [PATCH] replace os.Exit with FlushAndExit --- pkg/scheduler/internal/cache/cache.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pkg/scheduler/internal/cache/cache.go b/pkg/scheduler/internal/cache/cache.go index 036ab08cfbc..e31eb2822b2 100644 --- a/pkg/scheduler/internal/cache/cache.go +++ b/pkg/scheduler/internal/cache/cache.go @@ -18,7 +18,6 @@ package cache import ( "fmt" - "os" "sync" "time" @@ -544,7 +543,7 @@ func (cache *cacheImpl) UpdatePod(oldPod, newPod *v1.Pod) error { 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, "scheduler cache is corrupted and can badly affect scheduling decisions") - os.Exit(1) + klog.FlushAndExit(klog.ExitFlushTimeout, 1) } 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 // 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") - os.Exit(1) + klog.FlushAndExit(klog.ExitFlushTimeout, 1) } } return cache.removePod(currState.pod) @@ -748,7 +747,7 @@ func (cache *cacheImpl) cleanupAssumedPods(now time.Time) { ps, ok := cache.podStates[key] if !ok { 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 { klog.V(5).InfoS("Could not expire cache for pod as binding is still in progress",