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 3807575e [horus] Again combabilite restart logic (#375)
3807575e is described below

commit 3807575e9c73da37caf4509c1e6f7cebdff5a4d6
Author: mfordjody <[email protected]>
AuthorDate: Tue Sep 24 15:22:48 2024 +0800

    [horus] Again combabilite restart logic (#375)
---
 app/horus/core/horuser/restart.go | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/app/horus/core/horuser/restart.go 
b/app/horus/core/horuser/restart.go
index 161a7ff9..99f9e1c9 100644
--- a/app/horus/core/horuser/restart.go
+++ b/app/horus/core/horuser/restart.go
@@ -23,6 +23,7 @@ import (
        "github.com/gammazero/workerpool"
        "k8s.io/apimachinery/pkg/util/wait"
        "k8s.io/klog/v2"
+       "syscall"
        "time"
 )
 
@@ -51,17 +52,24 @@ func (h *Horuser) RestartOrRepair(ctx context.Context) {
 }
 
 func (h *Horuser) TryRestart(node db.NodeDataInfo) {
+       msg := fmt.Sprintf("\n【节点尝试重启】\n 节点:%v\n 日期:%v\n 集群:%v\n", 
node.NodeName, node.FirstDate, node.ClusterName)
+
        err := h.UnCordon(node.NodeName, node.ClusterName)
-       if err == nil {
-               klog.Infof("Node %v is already uncordoned.", node.NodeName)
+       if err != nil {
+               msg += fmt.Sprintf("\n【取消不可调度状态失败:%v】\n", err)
+               alert.DingTalkSend(h.cc.NodeDownTime.DingTalk, msg)
                return
+       } else {
+               klog.Infof("Node %v is already uncordoned.", node.NodeName)
        }
-       msg := fmt.Sprintf("\n【节点尝试重启】\n 节点:%v\n 日期:%v\n 集群:%v\n", 
node.NodeName, node.FirstDate, node.ClusterName)
+
+       err = syscall.Reboot(syscall.LINUX_REBOOT_CMD_RESTART)
        if err != nil {
-               msg = fmt.Sprintf("\n【节点重启失败:%v】\n", err)
+               msg += fmt.Sprintf("\n【节点重启失败:%v】\n", err)
        } else {
                msg = fmt.Sprintf("\n【节点重启成功】\n 节点:%v\n 日期:%v\n 集群:%v\n", 
node.NodeName, node.FirstDate, node.ClusterName)
        }
+
        alert.DingTalkSend(h.cc.NodeDownTime.DingTalk, msg)
        pass, err := node.RestartMarker()
        klog.Infof("RestartMarker result pass:%v err:%v", pass, err)

Reply via email to