From 5d7a00a385e3510efdac8fc44046956417c6f7e9 Mon Sep 17 00:00:00 2001
From: zhangxiaoyu <zhangxiaoyu58@huawei.com>
Date: Tue, 2 Nov 2021 16:19:38 +0800
Subject: [PATCH 02/12] disable service beforce setup service

Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com>
---
 Makefile                                                  | 8 ++++++--
 eggops.yaml                                               | 2 +-
 .../binary/cleanupcluster/cleanupcommon.go                | 2 +-
 .../binary/commontools/systemdservices.go                 | 2 ++
 pkg/clusterdeployment/runtime/runtime.go                  | 2 +-
 5 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index 9722c0c..3fac780 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,11 @@
 GIT_COMMIT ?= $(if $(shell git rev-parse --short HEAD),$(shell git rev-parse --short HEAD),$(error "commit id failed"))
 SOURCE_DATE_EPOCH ?= $(if $(shell date +%s),$(shell date +%s),$(error "date failed"))
 VERSION := $(shell cat ./VERSION)
-ARCH := $(shell arch)
+# eggo arch amd64/arm64
+ARCH ?= amd64
+ifeq ($(shell uname -p),aarch64)
+ARCH ?= arm64
+endif
 
 EXTRALDFLAGS :=
 LDFLAGS := -X isula.org/eggo/cmd.Version=$(VERSION) \
@@ -13,7 +17,7 @@ STATIC_LDFLAGS := -extldflags=-static -linkmode=external
 SAFEBUILDFLAGS := -buildmode=pie -extldflags=-ftrapv -extldflags=-zrelro -extldflags=-znow -tmpdir=/tmp/xxeggo $(LDFLAGS)
 
 GO := go
-GO_BUILD := CGO_ENABLED=0 $(GO)
+GO_BUILD := CGO_ENABLED=0 GOARCH=$(ARCH) $(GO)
 
 .PHONY: eggo
 eggo:
diff --git a/eggops.yaml b/eggops.yaml
index 606f4da..419854a 100644
--- a/eggops.yaml
+++ b/eggops.yaml
@@ -1626,7 +1626,7 @@ spec:
       containers:
       - command:
         - /manager
-        image: hub.oepkgs.net/haozi007/eggops:v1.0.0-alpha
+        image: hub.oepkgs.net/haozi007/eggops:1.0.0-alpha
         livenessProbe:
           httpGet:
             path: /healthz
diff --git a/pkg/clusterdeployment/binary/cleanupcluster/cleanupcommon.go b/pkg/clusterdeployment/binary/cleanupcluster/cleanupcommon.go
index 8220746..e681b63 100644
--- a/pkg/clusterdeployment/binary/cleanupcluster/cleanupcommon.go
+++ b/pkg/clusterdeployment/binary/cleanupcluster/cleanupcommon.go
@@ -43,7 +43,7 @@ func PostCleanup(r runner.Runner) {
 
 func stopServices(r runner.Runner, services []string) error {
 	join := strings.Join(services, " ")
-	if _, err := r.RunCommand(fmt.Sprintf("sudo -E /bin/sh -c \"systemctl stop %s\"", join)); err != nil {
+	if _, err := r.RunCommand(fmt.Sprintf("sudo -E /bin/sh -c \"systemctl stop %s && systemctl disable %s\"", join, join)); err != nil {
 		logrus.Errorf("stop services failed: %v", err)
 		return err
 	}
diff --git a/pkg/clusterdeployment/binary/commontools/systemdservices.go b/pkg/clusterdeployment/binary/commontools/systemdservices.go
index 790d3d4..e500aab 100644
--- a/pkg/clusterdeployment/binary/commontools/systemdservices.go
+++ b/pkg/clusterdeployment/binary/commontools/systemdservices.go
@@ -406,8 +406,10 @@ func GetSystemdServiceShell(name string, base64Data string, needRestart bool) (s
 	shell := `
 #!/bin/bash
 {{- if .content }}
+systemctl disable {{ .name }}
 rm -f /usr/lib/systemd/system/{{ .name }}.service
 echo {{ .content }} | base64 -d > /usr/lib/systemd/system/{{ .name }}.service
+systemctl daemon-reload
 {{- end }}
 which chcon
 if [ $? -eq 0 ]; then
diff --git a/pkg/clusterdeployment/runtime/runtime.go b/pkg/clusterdeployment/runtime/runtime.go
index 021ce58..ca5e265 100644
--- a/pkg/clusterdeployment/runtime/runtime.go
+++ b/pkg/clusterdeployment/runtime/runtime.go
@@ -177,7 +177,7 @@ Type=notify
 EnvironmentFile=-/etc/sysconfig/docker
 ExecStart=/usr/bin/dockerd \
 {{- range $i, $v := .registry }}
-        --registry-mirrors {{ $v }} \
+        --registry-mirror {{ $v }} \
 {{- end }}
 {{- range $i, $v := .insecure }}
         --insecure-registry {{ $v }} \
-- 
2.25.1

