Skip to content

Commit

Permalink
rename som variable
Browse files Browse the repository at this point in the history
Signed-off-by: chenfengyu <yuxubst@126.com>
  • Loading branch information
ycfnana committed Jun 28, 2023
1 parent 097ad3d commit 69ff3ff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions cmd/scheduler/app/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
10 changes: 5 additions & 5 deletions pkg/scheduler/api/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 69ff3ff

Please sign in to comment.