From 69736c70d92aae47a907511a21a70673230f8091 Mon Sep 17 00:00:00 2001 From: qzhu Date: Sun, 18 Aug 2024 10:55:15 +0800 Subject: [PATCH 1/3] [YUNIKORN-2817] Pods should be deleted immediately when they are placeholder pods --- pkg/client/kubeclient.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/client/kubeclient.go b/pkg/client/kubeclient.go index ef8393aef..ce1d89239 100644 --- a/pkg/client/kubeclient.go +++ b/pkg/client/kubeclient.go @@ -21,6 +21,7 @@ package client import ( "context" "fmt" + "github.com/apache/yunikorn-k8shim/pkg/common/utils" "go.uber.org/zap" v1 "k8s.io/api/core/v1" @@ -139,6 +140,9 @@ func (nc SchedulerKubeClient) Create(pod *v1.Pod) (*v1.Pod, error) { func (nc SchedulerKubeClient) Delete(pod *v1.Pod) error { gracefulSeconds := int64(3) + if utils.GetPlaceholderFlagFromPodSpec(pod) { + gracefulSeconds = int64(0) + } if err := nc.clientSet.CoreV1().Pods(pod.Namespace).Delete(context.Background(), pod.Name, apis.DeleteOptions{ GracePeriodSeconds: &gracefulSeconds, }); err != nil { From 60f7c84db4aefc7228b31b3cad9bf41d02704687 Mon Sep 17 00:00:00 2001 From: qzhu Date: Sun, 18 Aug 2024 11:10:32 +0800 Subject: [PATCH 2/3] fix golint --- pkg/client/kubeclient.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/client/kubeclient.go b/pkg/client/kubeclient.go index ce1d89239..231438f0a 100644 --- a/pkg/client/kubeclient.go +++ b/pkg/client/kubeclient.go @@ -21,7 +21,6 @@ package client import ( "context" "fmt" - "github.com/apache/yunikorn-k8shim/pkg/common/utils" "go.uber.org/zap" v1 "k8s.io/api/core/v1" @@ -32,6 +31,7 @@ import ( "k8s.io/client-go/tools/clientcmd" "k8s.io/client-go/util/retry" + "github.com/apache/yunikorn-k8shim/pkg/common/utils" "github.com/apache/yunikorn-k8shim/pkg/conf" "github.com/apache/yunikorn-k8shim/pkg/log" ) From 609692cf55b9c2e76f27a99ba92a6fc80631867c Mon Sep 17 00:00:00 2001 From: qzhu Date: Sun, 18 Aug 2024 20:42:20 +0800 Subject: [PATCH 3/3] Address new comments --- pkg/client/kubeclient.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/pkg/client/kubeclient.go b/pkg/client/kubeclient.go index 231438f0a..6132ab75b 100644 --- a/pkg/client/kubeclient.go +++ b/pkg/client/kubeclient.go @@ -31,7 +31,6 @@ import ( "k8s.io/client-go/tools/clientcmd" "k8s.io/client-go/util/retry" - "github.com/apache/yunikorn-k8shim/pkg/common/utils" "github.com/apache/yunikorn-k8shim/pkg/conf" "github.com/apache/yunikorn-k8shim/pkg/log" ) @@ -139,13 +138,7 @@ func (nc SchedulerKubeClient) Create(pod *v1.Pod) (*v1.Pod, error) { } func (nc SchedulerKubeClient) Delete(pod *v1.Pod) error { - gracefulSeconds := int64(3) - if utils.GetPlaceholderFlagFromPodSpec(pod) { - gracefulSeconds = int64(0) - } - if err := nc.clientSet.CoreV1().Pods(pod.Namespace).Delete(context.Background(), pod.Name, apis.DeleteOptions{ - GracePeriodSeconds: &gracefulSeconds, - }); err != nil { + if err := nc.clientSet.CoreV1().Pods(pod.Namespace).Delete(context.Background(), pod.Name, apis.DeleteOptions{}); err != nil { log.Log(log.ShimClient).Warn("failed to delete pod", zap.String("namespace", pod.Namespace), zap.String("podName", pod.Name),