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 dd09f564 [horus] Pod exception clearing logic detection (#391)
dd09f564 is described below

commit dd09f5641d250bb3a2cbf90834913446d36e8f50
Author: mfordjody <[email protected]>
AuthorDate: Fri Sep 27 17:00:56 2024 +0800

    [horus] Pod exception clearing logic detection (#391)
---
 app/horus/core/horuser/pod_abnormal.go | 10 +++++++---
 app/horus/core/horuser/pod_remove.go   | 12 ++++++------
 2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/app/horus/core/horuser/pod_abnormal.go 
b/app/horus/core/horuser/pod_abnormal.go
index 80ae9f0a..38aefbf1 100644
--- a/app/horus/core/horuser/pod_abnormal.go
+++ b/app/horus/core/horuser/pod_abnormal.go
@@ -28,6 +28,10 @@ import (
        "time"
 )
 
+const (
+       ModuleName = "pod_abnormal_clean"
+)
+
 func (h *Horuser) PodAbnormalCleanManager(ctx context.Context) error {
        go wait.UntilWithContext(ctx, h.PodAbnormalClean, 
time.Duration(h.cc.PodAbnormal.IntervalSecond)*time.Second)
        <-ctx.Done()
@@ -65,7 +69,7 @@ func (h *Horuser) PodsOnCluster(clusterName string) {
                if pod.Status.Phase == corev1.PodRunning || pod.Status.Phase == 
corev1.PodSucceeded || pod.Status.Phase == corev1.PodFailed {
                        continue
                }
-               msg := 
fmt.Sprintf("\n【集群:%v】\n【%d/%d】\n【Namespace:%v】\n【PodName:%v】\n【Phase:%v】\n【节点名:%v】\n",
 clusterName, index+1, count, pod.Namespace, pod.Name, pod.Status.Phase, 
pod.Spec.NodeName)
+               msg := 
fmt.Sprintf("\n【集群:%v】\n【存活:%d/%d】\n【PodName:%v】\n【Namespace:%v】\n【Phase:%v】\n【节点:%v】\n",
 clusterName, index+1, count, pod.Name, pod.Namespace, pod.Status.Phase, 
pod.Spec.NodeName)
                klog.Infof(msg)
 
                wp.Submit(func() {
@@ -99,14 +103,14 @@ func (h *Horuser) PodSingle(pod corev1.Pod, clusterName 
string) {
                                res = fmt.Sprintf("failed:%v", err)
                        }
                        today := time.Now().Format("2006-01-02")
-                       msg := fmt.Sprintf("【集群:%v】【Pod:%v】【Namespace:%v】【无法删除 
pod-patch-finalizer:%v】【处理结果:%v】", clusterName, pod.Name, pod.Namespace, 
action, res)
+                       msg := 
fmt.Sprintf("\n【集群:%v】\n【Pod:%v】\n【Namespace:%v】\n【无法删除的 
finalizer:%v】\n【处理结果:%v】\n", clusterName, pod.Name, pod.Namespace, err, res)
                        alert.DingTalkSend(h.cc.PodAbnormal.DingTalk, msg)
                        write := db.PodDataInfo{
                                PodName:     pod.Name,
                                PodIP:       pod.Status.PodIP,
                                NodeName:    pod.Spec.NodeName,
                                ClusterName: clusterName,
-                               ModuleName:  "pod_abnormal_clean",
+                               ModuleName:  ModuleName,
                                Reason:      action,
                                FirstDate:   today,
                        }
diff --git a/app/horus/core/horuser/pod_remove.go 
b/app/horus/core/horuser/pod_remove.go
index 89984fe1..2ea2396a 100644
--- a/app/horus/core/horuser/pod_remove.go
+++ b/app/horus/core/horuser/pod_remove.go
@@ -24,9 +24,9 @@ import (
        "k8s.io/klog/v2"
 )
 
-type SampleValue struct {
-       Operation string `json:"operation"`
-       Path      string `json:"path"`
+type RemoveJsonValue struct {
+       Op   string `json:"op"`
+       Path string `json:"path"`
 }
 
 func (h *Horuser) Finalizer(clusterName, podName, podNamespace string) error {
@@ -36,9 +36,9 @@ func (h *Horuser) Finalizer(clusterName, podName, 
podNamespace string) error {
                klog.Infof("clusterName:%v podName:%v", clusterName, podName)
                return nil
        }
-       finalizer := SampleValue{
-               Operation: "remove",
-               Path:      "/metadata/finalizers",
+       finalizer := RemoveJsonValue{
+               Op:   "remove",
+               Path: "/metadata/finalizers",
        }
        var payload []interface{}
        payload = append(payload, finalizer)

Reply via email to