This is an automated email from the ASF dual-hosted git repository.
zhongxjian pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-kubernetes.git
The following commit(s) were added to refs/heads/master by this push:
new bb8324dd [horus] Add pod Cleanup Terminating (#379)
bb8324dd is described below
commit bb8324dd66f7ca02990cf03305c6c59eaebc9859
Author: mfordjody <[email protected]>
AuthorDate: Wed Sep 25 14:24:16 2024 +0800
[horus] Add pod Cleanup Terminating (#379)
---
app/horus/core/horuser/pod_remove.go | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/app/horus/core/horuser/pod_remove.go
b/app/horus/core/horuser/pod_remove.go
index 9d2ea881..7a7a5c53 100644
--- a/app/horus/core/horuser/pod_remove.go
+++ b/app/horus/core/horuser/pod_remove.go
@@ -16,7 +16,9 @@
package horuser
import (
+ "context"
"encoding/json"
+ corev1 "k8s.io/api/core/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/klog/v2"
@@ -46,3 +48,21 @@ func (h *Horuser) Finalizer(clusterName, podName,
podNamespace string) error {
_, err := kubeClient.CoreV1().Pods(podNamespace).Patch(ctx, podName,
types.JSONPatchType, data, v1.PatchOptions{})
return err
}
+
+func (h *Horuser) Terminating(clusterName string, oldPod *corev1.Pod) bool {
+ kubeClient := h.kubeClientMap[clusterName]
+ if kubeClient == nil {
+ return false
+ }
+ newPod, _ :=
kubeClient.CoreV1().Pods(oldPod.Namespace).Get(context.Background(),
oldPod.Name, v1.GetOptions{})
+ if newPod == nil {
+ return false
+ }
+ if newPod.UID != oldPod.UID {
+ return false
+ }
+ if newPod.DeletionTimestamp.IsZero() {
+ return false
+ }
+ return true
+}