diff --git a/cmd/scheduler/app/options/options.go b/cmd/scheduler/app/options/options.go index db669ea4bc..a0b5926777 100644 --- a/cmd/scheduler/app/options/options.go +++ b/cmd/scheduler/app/options/options.go @@ -43,7 +43,7 @@ const ( defaultPercentageOfNodesToFind = 100 defaultLockObjectNamespace = "volcano-system" defaultGracePeriodSeconds = 30 - defaultGracePeriodFactor = 1.1 + defaultGracePeriodSecondsWait = 3 ) // ServerOption is the main context object for the controller manager. @@ -135,7 +135,7 @@ func (s *ServerOption) AddFlags(fs *pflag.FlagSet) { fs.BoolVar(&s.EnableCacheDumper, "cache-dumper", true, "Enable the cache dumper, it's true by default") fs.Int64Var(&s.GracePeriodSeconds, "grace-period", defaultGracePeriodSeconds, "the default second grace period seconds from pod") - fs.Int64Var(&s.GracePeriodSecondsWait, "grace-period-wait", defaultGracePeriodFactor, "wait time from pod send sig kill to delete pod") + fs.Int64Var(&s.GracePeriodSecondsWait, "grace-period-wait", defaultGracePeriodSecondsWait, "wait time from pod send sig kill to delete pod") } // CheckOptionOrDie check lock-object-namespace when LeaderElection is enabled. diff --git a/pkg/scheduler/api/helpers.go b/pkg/scheduler/api/helpers.go index 3ca103adab..fb2c26aa2b 100644 --- a/pkg/scheduler/api/helpers.go +++ b/pkg/scheduler/api/helpers.go @@ -36,16 +36,16 @@ func PodKey(pod *v1.Pod) TaskID { func getTaskStatus(pod *v1.Pod) TaskStatus { opts := options.ServerOpts - gracePeriodSeconds := opts.GracePeriodSeconds + waitTime := opts.GracePeriodSeconds if pod.Spec.TerminationGracePeriodSeconds != nil { // default grace period - gracePeriodSeconds = *pod.Spec.TerminationGracePeriodSeconds + waitTime = *pod.Spec.TerminationGracePeriodSeconds } - gracePeriodSeconds += opts.GracePeriodSecondsWait + waitTime += opts.GracePeriodSecondsWait switch pod.Status.Phase { case v1.PodRunning: if pod.DeletionTimestamp != nil && - time.Now().Unix()-pod.DeletionTimestamp.Unix() <= gracePeriodSeconds { + time.Now().Unix()-pod.DeletionTimestamp.Unix() <= waitTime { return Releasing } else if pod.DeletionTimestamp != nil { return ReleasingFailed @@ -54,7 +54,7 @@ func getTaskStatus(pod *v1.Pod) TaskStatus { return Running case v1.PodPending: if pod.DeletionTimestamp != nil && - time.Now().Unix()-pod.DeletionTimestamp.Unix() <= gracePeriodSeconds { + time.Now().Unix()-pod.DeletionTimestamp.Unix() <= waitTime { return Releasing } else if pod.DeletionTimestamp != nil { return ReleasingFailed