From 89b8304fb5bcd0665e1bfe26339555e7b1ce27cf Mon Sep 17 00:00:00 2001 From: Craig Condit Date: Fri, 26 Jul 2024 13:36:57 -0500 Subject: [PATCH] [YUNIKORN-2771] Optimization: Mark placeholder pods for non-graceful termination (#883) Update the Kubernetes pod spec for placeholder pods to set TerminationGracePeriodSeconds to 0. This allows the pods to be removed immediately when terminated. Closes: #883 --- .golangci.yml | 2 +- Makefile | 5 +---- pkg/cache/placeholder.go | 16 +++++++++------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 179df3820..9819f608c 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -34,7 +34,7 @@ linters-settings: goimports: local-prefixes: github.com/apache/yunikorn govet: - check-shadowing: true + shadow: true goconst: min-occurrences: 5 funlen: diff --git a/Makefile b/Makefile index 030a68b1c..8d02acc9e 100644 --- a/Makefile +++ b/Makefile @@ -288,10 +288,7 @@ $(GINKGO_BIN): .PHONY: lint lint: $(GOLANGCI_LINT_BIN) @echo "running golangci-lint" - @git symbolic-ref -q HEAD && REV="origin/HEAD" || REV="HEAD^" ; \ - headSHA=$$(git rev-parse --short=12 $${REV}) ; \ - echo "checking against commit sha $${headSHA}" ; \ - "${GOLANGCI_LINT_BIN}" run + @"${GOLANGCI_LINT_BIN}" run # Check scripts .PHONY: check_scripts diff --git a/pkg/cache/placeholder.go b/pkg/cache/placeholder.go index 8235bf11c..d259b5622 100644 --- a/pkg/cache/placeholder.go +++ b/pkg/cache/placeholder.go @@ -85,6 +85,7 @@ func newPlaceholder(placeholderName string, app *Application, taskGroup TaskGrou // prepare the resource lists requests := GetPlaceholderResourceRequests(taskGroup.MinResource) + var zeroSeconds int64 = 0 placeholderPod := &v1.Pod{ ObjectMeta: metav1.ObjectMeta{ Name: placeholderName, @@ -113,13 +114,14 @@ func newPlaceholder(placeholderName string, app *Application, taskGroup TaskGrou }, }, }, - RestartPolicy: constants.PlaceholderPodRestartPolicy, - SchedulerName: constants.SchedulerName, - NodeSelector: taskGroup.NodeSelector, - Tolerations: taskGroup.Tolerations, - Affinity: taskGroup.Affinity, - TopologySpreadConstraints: taskGroup.TopologySpreadConstraints, - PriorityClassName: priorityClassName, + RestartPolicy: constants.PlaceholderPodRestartPolicy, + SchedulerName: constants.SchedulerName, + NodeSelector: taskGroup.NodeSelector, + Tolerations: taskGroup.Tolerations, + Affinity: taskGroup.Affinity, + TopologySpreadConstraints: taskGroup.TopologySpreadConstraints, + PriorityClassName: priorityClassName, + TerminationGracePeriodSeconds: &zeroSeconds, }, }