From 8de23665bba05ad50b0a155d12af473f1f779c94 Mon Sep 17 00:00:00 2001 From: OrangeBao Date: Sat, 11 May 2024 20:58:26 +0800 Subject: [PATCH] feat: Compatibility without kubeadm.cfg file Signed-off-by: OrangeBao --- deploy/virtual-cluster-operator.yml | 104 ++++++++++++---- hack/k8s-in-k8s/env.dev.sh | 22 ++++ hack/k8s-in-k8s/env.sh | 22 ++++ hack/{ => k8s-in-k8s}/kubelet_node_helper.sh | 114 ++++++++++++------ hack/{ => k8s-in-k8s}/node_agent_backup.sh | 0 .../virtualcluster.node.controller/env/env.go | 16 +++ .../exector/exector.go | 28 +++-- .../exector/remote_cmd.go | 11 +- .../workflow/task/task.go | 21 ++-- 9 files changed, 255 insertions(+), 83 deletions(-) create mode 100644 hack/k8s-in-k8s/env.dev.sh create mode 100644 hack/k8s-in-k8s/env.sh rename hack/{ => k8s-in-k8s}/kubelet_node_helper.sh (57%) rename hack/{ => k8s-in-k8s}/node_agent_backup.sh (100%) diff --git a/deploy/virtual-cluster-operator.yml b/deploy/virtual-cluster-operator.yml index 0e1926f12..526a48690 100644 --- a/deploy/virtual-cluster-operator.yml +++ b/deploy/virtual-cluster-operator.yml @@ -51,7 +51,7 @@ metadata: name: virtual-cluster-operator namespace: kosmos-system data: - kubelet_node_helper.sh: | + env.sh: | #!/usr/bin/env bash SCRIPT_VERSION=0.0.1 @@ -74,22 +74,45 @@ data: PATH_KUBELET_LIB=/var/lib/kubelet # scpKubeletConfigCmd.name KUBELET_CONFIG_NAME=config.yaml + kubelet_node_helper.sh: | + #!/usr/bin/env bash + + source "env.sh" # args DNS_ADDRESS=${2:-10.237.0.10} LOG_NAME=${2:-kubelet} - JOIN_TOKEN=$2 + JOIN_HOST=$2 + JOIN_TOKEN=$3 + JOIN_CA_HASH=$4 function unjoin() { # before unjoin, you need delete node by kubectl - echo "exec(1/1): kubeadm reset...." + echo "exec(1/2): kubeadm reset...." echo "y" | ${PATH_KUBEADM} reset if [ $? -ne 0 ]; then exit 1 fi + + echo "exec(2/2): delete cni...." + if [ -d "/etc/cni/net.d" ]; then + mv /etc/cni/net.d '/etc/cni/net.d.back'`date +%Y_%m_%d_%H_%M_%S` + if [ $? -ne 0 ]; then + exit 1 + fi + fi } function revert() { + if [ ! -f "$PATH_KUBEADM_CONFIG/kubeadm.cfg" ]; then + echo "exec(1/1): execure join cmd" + kubeadm join $JOIN_HOST --token $JOIN_TOKEN --discovery-token-ca-cert-hash $JOIN_CA_HASH + if [ $? -ne 0 ]; then + exit 1 + fi + exit 0 + fi + echo "exec(1/3): update kubeadm.cfg..." sed -e "s|token: .*$|token: $JOIN_TOKEN|g" -e "w $PATH_FILE_TMP/kubeadm.cfg.current" "$PATH_KUBEADM_CONFIG/kubeadm.cfg" if [ $? -ne 0 ]; then @@ -112,37 +135,46 @@ data: # before join, you need upload ca.crt and kubeconfig to tmp dir!!! function join() { - echo "exec(1/7): stop containerd...." + echo "exec(1/8): stop containerd...." systemctl stop containerd if [ $? -ne 0 ]; then exit 1 fi - echo "exec(2/7): copy ca.crt...." + echo "exec(2/8): copy ca.crt...." cp "$PATH_FILE_TMP/ca.crt" "$PATH_KUBERNETES_PKI/ca.crt" if [ $? -ne 0 ]; then exit 1 fi - echo "exec(3/7): copy kubeconfig...." + echo "exec(3/8): copy kubeconfig...." cp "$PATH_FILE_TMP/$KUBELET_KUBE_CONFIG_NAME" "$PATH_KUBERNETES/$KUBELET_KUBE_CONFIG_NAME" if [ $? -ne 0 ]; then exit 1 fi - echo "exec(4/7): set core dns address...." + echo "exec(4/8): set core dns address...." sed -e "s|__DNS_ADDRESS__|$DNS_ADDRESS|g" -e "w ${PATH_KUBELET_LIB}/${KUBELET_CONFIG_NAME}" "$PATH_FILE_TMP"/"$KUBELET_CONFIG_NAME" if [ $? -ne 0 ]; then exit 1 fi - echo "exec(5/7): copy kubeadm-flags.env...." + echo "exec(5/8): copy kubeadm-flags.env...." cp "$PATH_FILE_TMP/kubeadm-flags.env" "$PATH_KUBELET_LIB/kubeadm-flags.env" if [ $? -ne 0 ]; then exit 1 fi - echo "exec(6/7): start containerd" + echo "exec(6/8): start containerd" systemctl start containerd if [ $? -ne 0 ]; then exit 1 fi - echo "exec(7/7): start kubelet...." + + echo "exec(7/8): delete cni...." + if [ -d "/etc/cni/net.d" ]; then + mv /etc/cni/net.d '/etc/cni/net.d.back'`date +%Y_%m_%d_%H_%M_%S` + if [ $? -ne 0 ]; then + exit 1 + fi + fi + + echo "exec(8/8): start kubelet...." systemctl start kubelet if [ $? -ne 0 ]; then exit 1 @@ -173,20 +205,43 @@ data: # check the environments function check() { - echo "check(1/2): try to create $PATH_FILE_TMP" + echo "check(1/3): try to create $PATH_FILE_TMP" if [ ! -d "$PATH_FILE_TMP" ]; then mkdir -p "$PATH_FILE_TMP" if [ $? -ne 0 ]; then exit 1 fi fi - - echo "check(2/2): copy kubeadm-flags.env to create $PATH_FILE_TMP and remove args[cloud-provider] " - if [ ! -f "${PATH_FILE_TMP}/kubeadm-flags.env"]; then - sed -e "s| --cloud-provider=external | |g" -e "w ${PATH_FILE_TMP}/kubeadm-flags.env" "$PATH_KUBELET_LIB/kubeadm-flags.env" + + echo "check(2/3): check dir: $PATH_KUBEADM_CONFIG" + if [ ! -d "$PATH_KUBEADM_CONFIG" ]; then + mkdir -p "$PATH_KUBEADM_CONFIG" if [ $? -ne 0 ]; then exit 1 fi + + echo "--- + apiVersion: kubeadm.k8s.io/v1beta2 + discovery: + bootstrapToken: + apiServerEndpoint: apiserver.cluster.local:6443 + token: xxxxxxxx + unsafeSkipCAVerification: true + kind: JoinConfiguration + nodeRegistration: + criSocket: /run/containerd/containerd.sock + kubeletExtraArgs: + container-runtime: remote + container-runtime-endpoint: unix:///run/containerd/containerd.sock + taints: null" > $PATH_KUBEADM_CONFIG/kubeadm.cfg + + fi + + echo "check(3/3): copy kubeadm-flags.env to create $PATH_FILE_TMP , remove args[cloud-provider] and taints" + sed -e "s| --cloud-provider=external | |g" -e "w ${PATH_FILE_TMP}/kubeadm-flags.env" "$PATH_KUBELET_LIB/kubeadm-flags.env" + sed -i "s| --register-with-taints=node.kosmos.io/unschedulable:NoSchedule||g" "${PATH_FILE_TMP}/kubeadm-flags.env" + if [ $? -ne 0 ]; then + exit 1 fi echo "environments is ok" @@ -198,28 +253,28 @@ data: # See how we were called. case "$1" in - unjoin) + unjoin) unjoin ;; - join) + join) join ;; - health) + health) health ;; - check) + check) check ;; - log) + log) log ;; - revert) + revert) revert ;; - version) + version) version ;; - *) + *) echo $"usage: $0 unjoin|join|health|log|check|version|revert" exit 1 esac @@ -348,6 +403,9 @@ spec: - name: credentials mountPath: /etc/virtual-cluster-operator readOnly: true + - name: shellscript + mountPath: /etc/vc-node-dir/env.sh + subPath: env.sh - name: shellscript mountPath: /etc/vc-node-dir/kubelet_node_helper.sh subPath: kubelet_node_helper.sh diff --git a/hack/k8s-in-k8s/env.dev.sh b/hack/k8s-in-k8s/env.dev.sh new file mode 100644 index 000000000..96246634f --- /dev/null +++ b/hack/k8s-in-k8s/env.dev.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +SCRIPT_VERSION=0.0.1 +# save tmp file +PATH_FILE_TMP=/apps/conf/kosmos/tmp +################################################### +# path for kubeadm +PATH_KUBEADM=/usr/bin/kubeadm +################################################## +# path for kubeadm config +PATH_KUBEADM_CONFIG=/etc/kubeadm +################################################## +# path for kubernetes +PATH_KUBERNETES=/etc/kubernetes/ +PATH_KUBERNETES_PKI="$PATH_KUBERNETES/pki" +# scpKCCmd.name +KUBELET_KUBE_CONFIG_NAME=kubelet.conf +################################################## +# path for kubelet +PATH_KUBELET_LIB=/var/lib/kubelet +# scpKubeletConfigCmd.name +KUBELET_CONFIG_NAME=config.yaml \ No newline at end of file diff --git a/hack/k8s-in-k8s/env.sh b/hack/k8s-in-k8s/env.sh new file mode 100644 index 000000000..13fd54987 --- /dev/null +++ b/hack/k8s-in-k8s/env.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +SCRIPT_VERSION=0.0.1 +# save tmp file +PATH_FILE_TMP=/apps/conf/kosmos/tmp +################################################### +# path for kubeadm +PATH_KUBEADM=/usr/bin/kubeadm +################################################## +# path for kubeadm config +PATH_KUBEADM_CONFIG=/etc/kubeadm +################################################## +# path for kubernetes +PATH_KUBERNETES=/apps/conf/kubernetes/ +PATH_KUBERNETES_PKI="$PATH_KUBERNETES/ssl" +# scpKCCmd.name +KUBELET_KUBE_CONFIG_NAME=kubelet.conf +################################################## +# path for kubelet +PATH_KUBELET_LIB=/var/lib/kubelet +# scpKubeletConfigCmd.name +KUBELET_CONFIG_NAME=config.yaml \ No newline at end of file diff --git a/hack/kubelet_node_helper.sh b/hack/k8s-in-k8s/kubelet_node_helper.sh similarity index 57% rename from hack/kubelet_node_helper.sh rename to hack/k8s-in-k8s/kubelet_node_helper.sh index b155f69ae..ae08a2868 100755 --- a/hack/kubelet_node_helper.sh +++ b/hack/k8s-in-k8s/kubelet_node_helper.sh @@ -1,41 +1,41 @@ #!/usr/bin/env bash -SCRIPT_VERSION=0.0.1 -# save tmp file -PATH_FILE_TMP=/apps/conf/kosmos/tmp -################################################### -# path for kubeadm -PATH_KUBEADM=/usr/bin/kubeadm -################################################## -# path for kubeadm config -PATH_KUBEADM_CONFIG=/etc/kubeadm -################################################## -# path for kubernetes -PATH_KUBERNETES=/etc/kubernetes/ -PATH_KUBERNETES_PKI="$PATH_KUBERNETES/pki" -# scpKCCmd.name -KUBELET_KUBE_CONFIG_NAME=kubelet.conf -################################################## -# path for kubelet -PATH_KUBELET_LIB=/var/lib/kubelet -# scpKubeletConfigCmd.name -KUBELET_CONFIG_NAME=config.yaml +source "env.sh" # args DNS_ADDRESS=${2:-10.237.0.10} LOG_NAME=${2:-kubelet} -JOIN_TOKEN=$2 +JOIN_HOST=$2 +JOIN_TOKEN=$3 +JOIN_CA_HASH=$4 function unjoin() { # before unjoin, you need delete node by kubectl - echo "exec(1/1): kubeadm reset...." + echo "exec(1/2): kubeadm reset...." echo "y" | ${PATH_KUBEADM} reset if [ $? -ne 0 ]; then exit 1 fi + + echo "exec(2/2): delete cni...." + if [ -d "/etc/cni/net.d" ]; then + mv /etc/cni/net.d '/etc/cni/net.d.back'`date +%Y_%m_%d_%H_%M_%S` + if [ $? -ne 0 ]; then + exit 1 + fi + fi } function revert() { + if [ ! -f "$PATH_KUBEADM_CONFIG/kubeadm.cfg" ]; then + echo "exec(1/1): execure join cmd" + kubeadm join $JOIN_HOST --token $JOIN_TOKEN --discovery-token-ca-cert-hash $JOIN_CA_HASH + if [ $? -ne 0 ]; then + exit 1 + fi + exit 0 + fi + echo "exec(1/3): update kubeadm.cfg..." sed -e "s|token: .*$|token: $JOIN_TOKEN|g" -e "w $PATH_FILE_TMP/kubeadm.cfg.current" "$PATH_KUBEADM_CONFIG/kubeadm.cfg" if [ $? -ne 0 ]; then @@ -58,37 +58,46 @@ function revert() { # before join, you need upload ca.crt and kubeconfig to tmp dir!!! function join() { - echo "exec(1/7): stop containerd...." + echo "exec(1/8): stop containerd...." systemctl stop containerd if [ $? -ne 0 ]; then exit 1 fi - echo "exec(2/7): copy ca.crt...." + echo "exec(2/8): copy ca.crt...." cp "$PATH_FILE_TMP/ca.crt" "$PATH_KUBERNETES_PKI/ca.crt" if [ $? -ne 0 ]; then exit 1 fi - echo "exec(3/7): copy kubeconfig...." + echo "exec(3/8): copy kubeconfig...." cp "$PATH_FILE_TMP/$KUBELET_KUBE_CONFIG_NAME" "$PATH_KUBERNETES/$KUBELET_KUBE_CONFIG_NAME" if [ $? -ne 0 ]; then exit 1 fi - echo "exec(4/7): set core dns address...." + echo "exec(4/8): set core dns address...." sed -e "s|__DNS_ADDRESS__|$DNS_ADDRESS|g" -e "w ${PATH_KUBELET_LIB}/${KUBELET_CONFIG_NAME}" "$PATH_FILE_TMP"/"$KUBELET_CONFIG_NAME" if [ $? -ne 0 ]; then exit 1 fi - echo "exec(5/7): copy kubeadm-flags.env...." + echo "exec(5/8): copy kubeadm-flags.env...." cp "$PATH_FILE_TMP/kubeadm-flags.env" "$PATH_KUBELET_LIB/kubeadm-flags.env" if [ $? -ne 0 ]; then exit 1 fi - echo "exec(6/7): start containerd" + echo "exec(6/8): start containerd" systemctl start containerd if [ $? -ne 0 ]; then exit 1 fi - echo "exec(7/7): start kubelet...." + + echo "exec(7/8): delete cni...." + if [ -d "/etc/cni/net.d" ]; then + mv /etc/cni/net.d '/etc/cni/net.d.back'`date +%Y_%m_%d_%H_%M_%S` + if [ $? -ne 0 ]; then + exit 1 + fi + fi + + echo "exec(8/8): start kubelet...." systemctl start kubelet if [ $? -ne 0 ]; then exit 1 @@ -119,16 +128,41 @@ function log() { # check the environments function check() { - echo "check(1/2): try to create $PATH_FILE_TMP" + echo "check(1/3): try to create $PATH_FILE_TMP" if [ ! -d "$PATH_FILE_TMP" ]; then mkdir -p "$PATH_FILE_TMP" if [ $? -ne 0 ]; then exit 1 fi fi + + echo "check(2/3): check dir: $PATH_KUBEADM_CONFIG" + if [ ! -d "$PATH_KUBEADM_CONFIG" ]; then + mkdir -p "$PATH_KUBEADM_CONFIG" + if [ $? -ne 0 ]; then + exit 1 + fi + + echo "--- +apiVersion: kubeadm.k8s.io/v1beta2 +discovery: + bootstrapToken: + apiServerEndpoint: apiserver.cluster.local:6443 + token: xxxxxxxx + unsafeSkipCAVerification: true +kind: JoinConfiguration +nodeRegistration: + criSocket: /run/containerd/containerd.sock + kubeletExtraArgs: + container-runtime: remote + container-runtime-endpoint: unix:///run/containerd/containerd.sock + taints: null" > $PATH_KUBEADM_CONFIG/kubeadm.cfg + + fi - echo "check(2/2): copy kubeadm-flags.env to create $PATH_FILE_TMP and remove args[cloud-provider] " + echo "check(3/3): copy kubeadm-flags.env to create $PATH_FILE_TMP , remove args[cloud-provider] and taints" sed -e "s| --cloud-provider=external | |g" -e "w ${PATH_FILE_TMP}/kubeadm-flags.env" "$PATH_KUBELET_LIB/kubeadm-flags.env" + sed -i "s| --register-with-taints=node.kosmos.io/unschedulable:NoSchedule||g" "${PATH_FILE_TMP}/kubeadm-flags.env" if [ $? -ne 0 ]; then exit 1 fi @@ -142,28 +176,28 @@ function version() { # See how we were called. case "$1" in - unjoin) + unjoin) unjoin ;; - join) + join) join ;; - health) + health) health ;; - check) + check) check ;; - log) + log) log ;; - revert) + revert) revert ;; - version) + version) version ;; - *) + *) echo $"usage: $0 unjoin|join|health|log|check|version|revert" exit 1 -esac +esac \ No newline at end of file diff --git a/hack/node_agent_backup.sh b/hack/k8s-in-k8s/node_agent_backup.sh similarity index 100% rename from hack/node_agent_backup.sh rename to hack/k8s-in-k8s/node_agent_backup.sh diff --git a/pkg/kubenest/controller/virtualcluster.node.controller/env/env.go b/pkg/kubenest/controller/virtualcluster.node.controller/env/env.go index c493dea59..bd15bb7cb 100644 --- a/pkg/kubenest/controller/virtualcluster.node.controller/env/env.go +++ b/pkg/kubenest/controller/virtualcluster.node.controller/env/env.go @@ -34,6 +34,15 @@ func GetExectorShellName() string { return shellName } +func GetExectorShellEnvName() string { + shellName := os.Getenv("EXECTOR_SHELL_ENV_NAME") + + if len(shellName) == 0 { + shellName = "env.sh" + } + return shellName +} + func GetExectorShellPath() string { exectorWorkDir := GetExectorWorkerDir() shellVersion := GetExectorShellName() @@ -41,6 +50,13 @@ func GetExectorShellPath() string { return fmt.Sprintf("%s%s", exectorWorkDir, shellVersion) } +func GetExectorShellEnvPath() string { + exectorWorkDir := GetExectorWorkerDir() + shellVersion := GetExectorShellEnvName() + + return fmt.Sprintf("%s%s", exectorWorkDir, shellVersion) +} + func GetExectorHostMasterNodeIP() string { hostIP := os.Getenv("EXECTOR_HOST_MASTER_NODE_IP") if len(hostIP) == 0 { diff --git a/pkg/kubenest/controller/virtualcluster.node.controller/exector/exector.go b/pkg/kubenest/controller/virtualcluster.node.controller/exector/exector.go index 9e6cb4493..306132a5b 100644 --- a/pkg/kubenest/controller/virtualcluster.node.controller/exector/exector.go +++ b/pkg/kubenest/controller/virtualcluster.node.controller/exector/exector.go @@ -65,17 +65,28 @@ func (h *ExectorHelper) DoExector(stopCh <-chan struct{}, exector Exector) *Exec ret := h.DoExectorReal(stopCh, exector) if ret.Text == NotFoundText { // try to update shell script - srcFile := env.GetExectorShellPath() - klog.V(4).Infof("exector: src file path %s", srcFile) + srcEnvFile := env.GetExectorShellEnvPath() + klog.V(4).Infof("exector: src file path %s", srcEnvFile) - scpExector := &SCPExector{ + scpEnvExector := &SCPExector{ + DstFilePath: ".", + DstFileName: env.GetExectorShellEnvName(), + SrcFile: srcEnvFile, + } + + srcShellFile := env.GetExectorShellPath() + klog.V(4).Infof("exector: src file path %s", srcShellFile) + + scpShellExector := &SCPExector{ DstFilePath: ".", DstFileName: env.GetExectorShellName(), - SrcFile: srcFile, + SrcFile: srcShellFile, } - if ret := h.DoExectorReal(stopCh, scpExector); ret.Status == SUCCESS { - return h.DoExectorReal(stopCh, exector) + if ret := h.DoExectorReal(stopCh, scpEnvExector); ret.Status == SUCCESS { + if ret := h.DoExectorReal(stopCh, scpShellExector); ret.Status == SUCCESS { + return h.DoExectorReal(stopCh, exector) + } } else { return ret } @@ -106,6 +117,9 @@ func (h *ExectorHelper) DoExectorReal(stopCh <-chan struct{}, exector Exector) * defer close(done) for { _, message, err := conn.ReadMessage() + if len(message) > 0 { + klog.V(4).Infof("recv: %s", string(message)) + } if err != nil { klog.V(4).Infof("read: %s", err) cerr, ok := err.(*websocket.CloseError) @@ -123,7 +137,7 @@ func (h *ExectorHelper) DoExectorReal(stopCh <-chan struct{}, exector Exector) * } return } - klog.V(4).Infof("recv: %s", string(message)) + // klog.V(4).Infof("recv: %s", string(message)) // last result.LastLog = result.LastLog + string(message) } diff --git a/pkg/kubenest/controller/virtualcluster.node.controller/exector/remote_cmd.go b/pkg/kubenest/controller/virtualcluster.node.controller/exector/remote_cmd.go index a6eb32dbc..a0d9a2dfc 100644 --- a/pkg/kubenest/controller/virtualcluster.node.controller/exector/remote_cmd.go +++ b/pkg/kubenest/controller/virtualcluster.node.controller/exector/remote_cmd.go @@ -1,6 +1,8 @@ package exector import ( + "strings" + "github.com/gorilla/websocket" ) @@ -9,9 +11,16 @@ type CMDExector struct { } func (e *CMDExector) GetWebSocketOption() WebSocketOption { + cmdArgs := strings.Split(e.Cmd, " ") + command := cmdArgs[0] + rawQuery := "command=" + command + if len(cmdArgs) > 1 { + args := cmdArgs[1:] + rawQuery = rawQuery + "&args=" + strings.Join(args, "&args=") + } return WebSocketOption{ Path: "cmd/", - RawQuery: "command=" + e.Cmd, + RawQuery: rawQuery, } } diff --git a/pkg/kubenest/controller/virtualcluster.node.controller/workflow/task/task.go b/pkg/kubenest/controller/virtualcluster.node.controller/workflow/task/task.go index df92569e6..a6bb216a1 100644 --- a/pkg/kubenest/controller/virtualcluster.node.controller/workflow/task/task.go +++ b/pkg/kubenest/controller/virtualcluster.node.controller/workflow/task/task.go @@ -247,6 +247,7 @@ func NewRemoteNodeJoinTask() Task { joinCmd := &exector.CMDExector{ Cmd: fmt.Sprintf("bash %s join %s", env.GetExectorShellName(), to.KubeDNSAddress), } + klog.V(4).Infof("join node %s with cmd: %s", to.NodeInfo.Name, joinCmd.Cmd) ret := exectHelper.DoExector(ctx.Done(), joinCmd) if ret.Status != exector.SUCCESS { return nil, fmt.Errorf("join node %s failed: %s", to.NodeInfo.Name, ret.String()) @@ -428,19 +429,15 @@ func getJoinCmdStr(log string) (string, error) { if len(strs) != 2 { return "", fmt.Errorf("get join cmd str failed") } - return fmt.Sprintf("kubeadm join %s", strs[1]), nil + return fmt.Sprintf("kubeadm join %s", strings.TrimSpace(strs[1])), nil } -func getJoinCmdToken(joinCmdStr string) (string, error) { - strs := strings.Split(joinCmdStr, " --token ") - if len(strs) != 2 { - return "", fmt.Errorf("get join cmd token failed") - } - strs = strings.Split(strs[1], " ") - if len(strs) < 2 { - return "", fmt.Errorf("get join cmd token failed") +func getJoinCmdArgs(joinCmdStr string) (string, string, string, error) { + strs := strings.Split(joinCmdStr, " ") + if len(strs) != 7 { + return "", "", "", fmt.Errorf("invalid join cmd str: %s", joinCmdStr) } - return strings.TrimSpace(strs[0]), nil + return strings.TrimSpace(strs[2]), strings.TrimSpace(strs[4]), strings.TrimSpace(strs[6]), nil } func NewJoinNodeToHostCmd() Task { @@ -486,12 +483,12 @@ func NewExecJoinNodeToHostCmdTask() Task { if !ok { return nil, fmt.Errorf("get join cmd str failed") } - token, err := getJoinCmdToken(joinCmdStr) + host, token, certHash, err := getJoinCmdArgs(joinCmdStr) if err != nil { return nil, err } joinCmd := &exector.CMDExector{ - Cmd: fmt.Sprintf("bash %s revert %s", env.GetExectorShellName(), token), + Cmd: fmt.Sprintf("bash %s revert %s %s %s", env.GetExectorShellName(), host, token, certHash), } exectHelper := exector.NewExectorHelper(to.NodeInfo.Spec.NodeIP, "")