Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions charts/hami/templates/scheduler/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ spec:
image: {{ include "hami.scheduler.extender.image" . }}
imagePullPolicy: {{ .Values.scheduler.extender.image.pullPolicy }}
env:
{{- if .Values.scheduler.nodeLockExpire }}
- name: HAMI_NODELOCK_EXPIRE
value: "{{ .Values.scheduler.nodeLockExpire }}"
{{- end }}
{{- if .Values.global.managedNodeSelectorEnable }}
{{- range $key, $value := .Values.global.managedNodeSelector }}
- name: NODE_SELECTOR_{{ $key | upper | replace "-" "_" }}
Expand Down
1 change: 1 addition & 0 deletions charts/hami/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ scheduler:
extraArgs:
- --debug
- -v=4
nodeLockExpire: "5m"
podAnnotations: {}
tolerations: []
#serviceAccountName: "hami-vgpu-scheduler-sa"
Expand Down
19 changes: 19 additions & 0 deletions pkg/util/nodelock/nodelock.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package nodelock
import (
"context"
"fmt"
"os"
"strings"
"sync"
"time"
Expand All @@ -43,6 +44,24 @@ var (
NodeLockTimeout time.Duration = time.Minute * 5
)

func init() {
setupNodeLockTimeout()
}

// setupNodeLockTimeout configures the node lock timeout from the environment.
func setupNodeLockTimeout() {
nodelock := os.Getenv("HAMI_NODELOCK_EXPIRE")
if nodelock != "" {
d, err := time.ParseDuration(nodelock)
if err != nil {
klog.ErrorS(err, "Failed to parse HAMI_NODELOCK_EXPIRE, using default", "duration", NodeLockTimeout)
} else {
NodeLockTimeout = d
klog.InfoS("Node lock expiration time set from environment variable", "duration", d)
}
}
}

func SetNodeLock(nodeName string, lockname string, pods *corev1.Pod) error {
lock.Lock()
defer lock.Unlock()
Expand Down