From a6a4a5d612bf8d0108eecec8b6bb8cd5c393b6ed Mon Sep 17 00:00:00 2001 From: Zenghui Shi Date: Fri, 7 May 2021 21:22:45 +0800 Subject: [PATCH 1/2] Fix index out of range panic when ifaceName is empty Signed-off-by: Zenghui Shi --- pkg/utils/utils.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index 409041ba9..71b084140 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -336,6 +336,9 @@ func setNetdevMTU(pciAddr string, mtu int) error { glog.Warningf("setNetdevMTU(): fail to get interface name for %s: %s", pciAddr, err) return err } + if len(ifaceName) < 1 { + return fmt.Errorf("setNetdevMTU(): interface name is empty") + } mtuFile := "net/" + ifaceName[0] + "/mtu" mtuFilePath := filepath.Join(sysBusPciDevices, pciAddr, mtuFile) return ioutil.WriteFile(mtuFilePath, []byte(strconv.Itoa(mtu)), os.ModeAppend) From 3505f3eeaaa31a2baf39c298fdd66fa07ee92812 Mon Sep 17 00:00:00 2001 From: Peng Liu Date: Fri, 7 May 2021 08:25:31 -0400 Subject: [PATCH 2/2] Fix setup-envtest.sh source in Makefile --- Makefile | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 5ab313c8f..91e75ead7 100644 --- a/Makefile +++ b/Makefile @@ -75,7 +75,7 @@ image: ; $(info Building image...) ENVTEST_ASSETS_DIR=$(shell pwd)/testbin test: generate vet manifests mkdir -p ${ENVTEST_ASSETS_DIR} - test -f ${ENVTEST_ASSETS_DIR}/setup-envtest.sh || curl -sSLo ${ENVTEST_ASSETS_DIR}/setup-envtest.sh https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/master/hack/setup-envtest.sh + test -f ${ENVTEST_ASSETS_DIR}/setup-envtest.sh || curl -sSLo ${ENVTEST_ASSETS_DIR}/setup-envtest.sh https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/v0.7.2/hack/setup-envtest.sh source ${ENVTEST_ASSETS_DIR}/setup-envtest.sh; fetch_envtest_tools $(ENVTEST_ASSETS_DIR); setup_envtest_env $(ENVTEST_ASSETS_DIR); go test ./... -coverprofile cover.out -v # Build manager binary @@ -201,12 +201,15 @@ test-e2e-conformance: test-e2e: generate vet manifests skopeo mkdir -p ${ENVTEST_ASSETS_DIR} - test -f ${ENVTEST_ASSETS_DIR}/setup-envtest.sh || curl -sSLo ${ENVTEST_ASSETS_DIR}/setup-envtest.sh https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/master/hack/setup-envtest.sh - source ${ENVTEST_ASSETS_DIR}/setup-envtest.sh; fetch_envtest_tools $(ENVTEST_ASSETS_DIR); setup_envtest_env $(ENVTEST_ASSETS_DIR); source hack/env.sh; go test ./test/e2e/... -coverprofile cover.out -v + test -f ${ENVTEST_ASSETS_DIR}/setup-envtest.sh || curl -sSLo ${ENVTEST_ASSETS_DIR}/setup-envtest.sh https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/v0.7.2/hack/setup-envtest.sh + source ${ENVTEST_ASSETS_DIR}/setup-envtest.sh; fetch_envtest_tools $(ENVTEST_ASSETS_DIR); setup_envtest_env $(ENVTEST_ASSETS_DIR); source hack/env.sh; go test ./test/e2e/... -timeout 60m -coverprofile cover.out -v + +test-e2e-k8s: export NAMESPACE=sriov-network-operator +test-e2e-k8s: test-e2e test-%: generate vet manifests mkdir -p ${ENVTEST_ASSETS_DIR} - test -f ${ENVTEST_ASSETS_DIR}/setup-envtest.sh || curl -sSLo ${ENVTEST_ASSETS_DIR}/setup-envtest.sh https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/master/hack/setup-envtest.sh + test -f ${ENVTEST_ASSETS_DIR}/setup-envtest.sh || curl -sSLo ${ENVTEST_ASSETS_DIR}/setup-envtest.sh https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/v0.7.2/hack/setup-envtest.sh source ${ENVTEST_ASSETS_DIR}/setup-envtest.sh; fetch_envtest_tools $(ENVTEST_ASSETS_DIR); setup_envtest_env $(ENVTEST_ASSETS_DIR); go test ./$*/... -coverprofile cover.out -v # deploy-setup-k8s: export NAMESPACE=sriov-network-operator