From b29390d0e6982876b76ca7777bb01b22db561b7b Mon Sep 17 00:00:00 2001 From: wanyaoqi <18528551+wanyaoqi@users.noreply.github.com> Date: Fri, 31 May 2024 19:00:37 +0800 Subject: [PATCH] misc: disable cgo by default (#20423) * misc: disable cgo by default * fix(host): container isolated device skip get numa node --- Makefile | 9 ++++--- .../container_device/base_dev.go | 4 +++ scripts/docker_push.sh | 25 +++++++++++++------ 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index cfc311ae0f..253eb8b888 100644 --- a/Makefile +++ b/Makefile @@ -89,11 +89,14 @@ vet: # cmd/esxi-agent: prepare_dir # CGO_ENABLED=0 $(GO_BUILD) -o $(BIN_DIR)/$(shell basename $@) $(REPO_PREFIX)/$@ -cmd/fetcherfs: prepare_dir - CGO_ENABLED=0 $(GO_BUILD) -o $(BIN_DIR)/$(shell basename $@) $(REPO_PREFIX)/$@ +cmd/host: prepare_dir + CGO_ENABLED=1 $(GO_BUILD) -o $(BIN_DIR)/$(shell basename $@) $(REPO_PREFIX)/$@ + +cmd/host-image: prepare_dir + CGO_ENABLED=1 $(GO_BUILD) -o $(BIN_DIR)/$(shell basename $@) $(REPO_PREFIX)/$@ cmd/%: prepare_dir - $(GO_BUILD) -o $(BIN_DIR)/$(shell basename $@) $(REPO_PREFIX)/$@ + CGO_ENABLED=0 $(GO_BUILD) -o $(BIN_DIR)/$(shell basename $@) $(REPO_PREFIX)/$@ rpm/%: cmd/% $(BUILD_SCRIPT) $* diff --git a/pkg/hostman/isolated_device/container_device/base_dev.go b/pkg/hostman/isolated_device/container_device/base_dev.go index 763c7ba1b3..e4616e95ba 100644 --- a/pkg/hostman/isolated_device/container_device/base_dev.go +++ b/pkg/hostman/isolated_device/container_device/base_dev.go @@ -64,6 +64,10 @@ func (c BaseDevice) GetNvidiaMpsThreadPercentage() int { return -1 } +func (c BaseDevice) GetNumaNode() (int, error) { + return -1, nil +} + func CheckVirtualNumber(dev *isolated_device.ContainerDevice) error { if dev.VirtualNumber <= 0 { return errors.Errorf("virtual_number must > 0") diff --git a/scripts/docker_push.sh b/scripts/docker_push.sh index fcd7916b72..c3545242bc 100755 --- a/scripts/docker_push.sh +++ b/scripts/docker_push.sh @@ -157,6 +157,16 @@ build_process() { local arch=$2 local is_all_arch=$3 local img_name=$(get_image_name $component $arch $is_all_arch) + local build_env="" + + case "$component" in + host | host-image) + build_env="$build_env CGO_ENABLED=1" + ;; + *) + build_env="$build_env CGO_ENABLED=0" + ;; + esac build_bin $component if [[ "$DRY_RUN" == "true" ]]; then @@ -174,13 +184,14 @@ build_process_with_buildx() { local is_all_arch=$3 local img_name=$(get_image_name $component $arch $is_all_arch) - build_env="GOARCH=$arch" - if [[ "$arch" == arm64 ]]; then - build_env="$build_env" - if [[ $component == host ]]; then - build_env="$build_env CGO_ENABLED=1" - fi - fi + case "$component" in + host | host-image) + build_env="$build_env CGO_ENABLED=1" + ;; + *) + build_env="$build_env CGO_ENABLED=0" + ;; + esac case "$component" in host | torrent)