From b34b16464b37db02c3cfdf151be36f40f98937c8 Mon Sep 17 00:00:00 2001 From: weihao Date: Mon, 16 Dec 2024 09:46:15 +0800 Subject: [PATCH] fix some variable name spell error --- cmd/admin-container/main.go | 24 ++++++++--------- cmd/operator/controllers/operation.go | 2 +- cmd/operator/controllers/os_controller.go | 32 +++++++++++------------ 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/cmd/admin-container/main.go b/cmd/admin-container/main.go index 5fa08381..2edb3c09 100644 --- a/cmd/admin-container/main.go +++ b/cmd/admin-container/main.go @@ -23,17 +23,17 @@ import ( ) const ( - bashPath = "/usr/bin/bash" - usrBin = "/usr/bin" - usrSbin = "/usr/sbin" - localBin = "/usr/local/bin" - localSbin = "/usr/local/sbin" - usrLib = "/usr/lib" - usrLib64 = "/usr/lib64" - lib = "/lib" - lib64 = "/lib64" - envPathPrefix = "PATH=$PATH:" - envLdLibrarPathPrefix = "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:" + bashPath = "/usr/bin/bash" + usrBin = "/usr/bin" + usrSbin = "/usr/sbin" + localBin = "/usr/local/bin" + localSbin = "/usr/local/sbin" + usrLib = "/usr/lib" + usrLib64 = "/usr/lib64" + lib = "/lib" + lib64 = "/lib64" + envPathPrefix = "PATH=$PATH:" + envLdLibraryPathPrefix = "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:" ) func main() { @@ -46,7 +46,7 @@ func main() { PPID := os.Getppid() rootFsPath := "/proc/" + strconv.Itoa(PPID) + "/root" path := concatenateEnvPath(rootFsPath, envPathPrefix, []string{usrBin, usrSbin, localBin, localSbin}) - libPath := concatenateEnvPath(rootFsPath, envLdLibrarPathPrefix, []string{usrLib, usrLib64, lib, lib64}) + libPath := concatenateEnvPath(rootFsPath, envLdLibraryPathPrefix, []string{usrLib, usrLib64, lib, lib64}) if err := syscall.Exec("/usr/bin/nsenter", []string{"nsenter", "-t", "1", "-a", "env", "-i", path, libPath, rootFsPath + bashPath}, os.Environ()); err != nil { logrus.Error("nsenter excute error", err) diff --git a/cmd/operator/controllers/operation.go b/cmd/operator/controllers/operation.go index 9f130479..12c72111 100644 --- a/cmd/operator/controllers/operation.go +++ b/cmd/operator/controllers/operation.go @@ -263,7 +263,7 @@ func (s serialOps) updateNodes(ctx context.Context, r common.ReadStatusWriter, o } default: log.Error(nil, "ops "+s.getOpsLabel().label+" cannot be recognized") - return count, []error{fmt.Errorf("ops " + s.getOpsLabel().label + " cannot be recognized")} + return count, []error{fmt.Errorf("%s", "ops "+s.getOpsLabel().label+" cannot be recognized")} } } if len(errList) == 0 { diff --git a/cmd/operator/controllers/os_controller.go b/cmd/operator/controllers/os_controller.go index 3a9b58d2..14b21b25 100644 --- a/cmd/operator/controllers/os_controller.go +++ b/cmd/operator/controllers/os_controller.go @@ -76,17 +76,17 @@ func Reconcile(ctx context.Context, r common.ReadStatusWriter, req ctrl.Request) return values.Requeue, nil } ops := os.Spec.OpsType - var opsInsatnce operation + var opsInstance operation switch ops { case "upgrade", "rollback": - opsInsatnce = upgradeOps{ + opsInstance = upgradeOps{ label: opsLabel{ label: values.LabelUpgrading, op: selection.DoesNotExist, }, } case "config": - opsInsatnce = configOps{ + opsInstance = configOps{ label: opsLabel{ label: values.LabelConfiguring, op: selection.DoesNotExist, @@ -108,19 +108,19 @@ func Reconcile(ctx context.Context, r common.ReadStatusWriter, req ctrl.Request) log.V(1).Info("get all nodes num is " + strconv.Itoa(len(allNodes))) switch os.Spec.ExecutionMode { case ExecutionModeParallel: - result, err := excuteParallelOperation(ctx, r, os, opsInsatnce, len(allNodes)) + result, err := executeParallelOperation(ctx, r, os, opsInstance, len(allNodes)) if err != nil { return values.RequeueNow, nil } return result, nil case ExecutionModeSerial: - result, err := excuteSerialOperation(ctx, r, os, opsInsatnce, len(allNodes)) + result, err := executeSerialOperation(ctx, r, os, opsInstance, len(allNodes)) if err != nil { return values.RequeueNow, err } return result, nil default: - log.Error(nil, "excutionMode "+os.Spec.ExecutionMode+" cannot be recognized") + log.Error(nil, "executionMode "+os.Spec.ExecutionMode+" cannot be recognized") return values.Requeue, nil } } @@ -284,10 +284,10 @@ func setTimeInterval(timeInterval int) ctrl.Result { return ctrl.Result{Requeue: true, RequeueAfter: time.Duration(timeInterval) * time.Second} } -func excuteParallelOperation(ctx context.Context, r common.ReadStatusWriter, os upgradev1.OS, - opsInsatnce operation, nodeNum int) (ctrl.Result, error) { +func executeParallelOperation(ctx context.Context, r common.ReadStatusWriter, os upgradev1.OS, + opsInstance operation, nodeNum int) (ctrl.Result, error) { log.V(1).Info("start parallel operation") - opsLabel := opsInsatnce.getOpsLabel() + opsLabel := opsInstance.getOpsLabel() opsLabel.op = selection.Exists opsNodesReq, err := newopsNodesRequirement(os.Spec.NodeSelector, selection.Equals, opsLabel).createNodeRequirement(ctx, r) @@ -305,16 +305,16 @@ func excuteParallelOperation(ctx context.Context, r common.ReadStatusWriter, os if err != nil { return values.RequeueNow, nil } - if _, err := assignOperation(ctx, r, os, limit, opsInsatnce, noOpsNodesReq); err != nil { + if _, err := assignOperation(ctx, r, os, limit, opsInstance, noOpsNodesReq); err != nil { return values.RequeueNow, nil } return setTimeInterval(os.Spec.TimeInterval), nil } -func excuteSerialOperation(ctx context.Context, r common.ReadStatusWriter, os upgradev1.OS, - opsInsatnce operation, nodeNum int) (ctrl.Result, error) { +func executeSerialOperation(ctx context.Context, r common.ReadStatusWriter, os upgradev1.OS, + opsInstance operation, nodeNum int) (ctrl.Result, error) { log.V(1).Info("start serial operation") - opsLabel := opsInsatnce.getOpsLabel() + opsLabel := opsInstance.getOpsLabel() opsLabel.op = selection.Exists opsNodesReq, err := newopsNodesRequirement(os.Spec.NodeSelector, selection.Equals, opsLabel).createNodeRequirement(ctx, r) @@ -347,7 +347,7 @@ func excuteSerialOperation(ctx context.Context, r common.ReadStatusWriter, os up } // add serial label to node serialOpsInstance := serialOps{ - label: opsInsatnce.getOpsLabel(), + label: opsInstance.getOpsLabel(), } log.V(1).Info("start add serial label to nodes") if _, err := assignOperation(ctx, r, os, serialNodeLimit, serialOpsInstance, noSerialNodesRequirement); err != nil { @@ -355,8 +355,8 @@ func excuteSerialOperation(ctx context.Context, r common.ReadStatusWriter, os up } log.V(1).Info("start check nodes needed to be upgrade/configure or not") - serialLimit := 1 // 1 is the number of operation nodes when excution mode in serial - count, err := assignOperation(ctx, r, os, serialLimit, opsInsatnce, serialNodesRequirement) + serialLimit := 1 // 1 is the number of operation nodes when execution mode in serial + count, err := assignOperation(ctx, r, os, serialLimit, opsInstance, serialNodesRequirement) if err != nil { return values.RequeueNow, nil } -- Gitee