Skip to content

Commit

Permalink
Fix the cause of failure of multiple kind job runs
Browse files Browse the repository at this point in the history
on same VM.

There were two main causes of failure:
1) Overriding of DOCKER_IMG_VERSION in makefile.
2) Overriding of kubeconfig because of which, when
we ran multiple e2e tests together it used the
same kubeconfig which was present the default
location, so multiple jobs used the same cluster
and failed.

Signed-off-by: Pulkit Jain <[email protected]>
  • Loading branch information
jainpulkit22 committed Oct 24, 2024
1 parent c722fc3 commit 643f3e1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 22 deletions.
20 changes: 11 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,6 @@ TEST_ARGS ?=
# If we have stdin we can run interactive so the tests running in docker can be interrupted.
INTERACTIVE_ARGS := $(shell [ -t 0 ] && echo "-it")

BUILD_TAG :=
ifndef CUSTOM_BUILD_TAG
BUILD_TAG = $(shell build/images/build-tag.sh)
else
BUILD_TAG = $(CUSTOM_BUILD_TAG)
DOCKER_IMG_VERSION = $(CUSTOM_BUILD_TAG)
endif

DOCKER_BUILD_ARGS :=
ifeq ($(NO_PULL),)
DOCKER_BUILD_ARGS += --pull
Expand All @@ -57,7 +49,6 @@ ifneq ($(DOCKER_TARGETPLATFORM),)
endif
DOCKER_BUILD_ARGS += --build-arg OVS_VERSION=$(OVS_VERSION)
DOCKER_BUILD_ARGS += --build-arg GO_VERSION=$(GO_VERSION)
DOCKER_BUILD_ARGS += --build-arg BUILD_TAG=$(BUILD_TAG)

export CGO_ENABLED

Expand All @@ -66,6 +57,17 @@ all: build

include versioning.mk

# This should be located after the include directive for versioning.mk,
# so that we can override DOCKER_IMG_VERSION with CUSTOM_BUILD_TAG.
BUILD_TAG :=
ifndef CUSTOM_BUILD_TAG
BUILD_TAG = $(shell build/images/build-tag.sh)
else
BUILD_TAG = $(CUSTOM_BUILD_TAG)
DOCKER_IMG_VERSION = $(CUSTOM_BUILD_TAG)
endif
DOCKER_BUILD_ARGS += --build-arg BUILD_TAG=$(BUILD_TAG)

LDFLAGS += $(VERSION_LDFLAGS)

UNAME_S := $(shell uname -s)
Expand Down
9 changes: 4 additions & 5 deletions ci/jenkins/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ Run K8s e2e community tests (Conformance & Network Policy) or Antrea e2e tests o
--kind-cluster-name Name of the kind Cluster.
--proxyall Enable proxyAll to test AntreaProxy.
--build-tag Custom build tag for images.
--docker-user Username for Docker account.
--docker-password Password for Docker account."
--docker-user Username for Docker account.
--docker-password Password for Docker account."

function print_usage {
echoerr "$_usage"
Expand Down Expand Up @@ -201,7 +201,7 @@ function clean_antrea {
for antrea_yml in ${WORKDIR}/*.yml; do
kubectl delete -f $antrea_yml --ignore-not-found=true || true
done
docker images --format "{{.Repository}}:{{.Tag}}" | grep 'antrea'| xargs -r docker rmi -f || true
docker images --format "{{.Repository}}:{{.Tag}}" | grep ${BUILD_TAG} | xargs -r docker rmi || true
docker images | grep '<none>' | awk '{print $3}' | xargs -r docker rmi || true
check_and_cleanup_docker_build_cache
}
Expand Down Expand Up @@ -608,7 +608,6 @@ function deliver_antrea {
kind load docker-image antrea/antrea-agent-ubuntu:$BUILD_TAG --name ${KIND_CLUSTER}
kind load docker-image antrea/antrea-controller-ubuntu:$BUILD_TAG --name ${KIND_CLUSTER}
kind load docker-image antrea/flow-aggregator:latest --name ${KIND_CLUSTER}
kubectl config use-context kind-${KIND_CLUSTER}
docker cp ./build/yamls/antrea.yml ${KIND_CLUSTER}-control-plane:/root/antrea.yml
elif [[ $TESTBED_TYPE == "jumper" ]]; then
kubectl get nodes -o wide --no-headers=true | awk '{print $6}' | while read IP; do
Expand Down Expand Up @@ -674,7 +673,7 @@ function run_e2e {
if [[ $TESTBED_TYPE == "flexible-ipam" ]]; then
go test -v antrea.io/antrea/test/e2e --logs-export-dir `pwd`/antrea-test-logs --provider remote -timeout=100m --prometheus --antrea-ipam
elif [[ $TESTBED_TYPE == "kind" ]]; then
go test -v antrea.io/antrea/test/e2e --logs-export-dir `pwd`/antrea-test-logs --provider kind -timeout=100m --prometheus
go test -v antrea.io/antrea/test/e2e --logs-export-dir `pwd`/antrea-test-logs --provider kind --kind.kubeconfig ${KUBECONFIG_PATH} -timeout=100m --prometheus
elif [[ $TESTBED_TYPE == "kind-flexible-ipam" ]]; then
go test -v antrea.io/antrea/test/e2e --logs-export-dir `pwd`/antrea-test-logs --provider kind -timeout=100m --prometheus --antrea-ipam
else
Expand Down
14 changes: 6 additions & 8 deletions test/e2e/providers/kind.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package providers

import (
"flag"
"fmt"
"os"
"path"
Expand All @@ -23,6 +24,8 @@ import (
"antrea.io/antrea/test/e2e/providers/exec"
)

var kindKubeconfigPath = flag.String("kind.kubeconfig", path.Join(homedir, ".kube", "config"), "Path of the kubeconfig of the cluster")

type KindProvider struct {
controlPlaneNodeName string
}
Expand All @@ -47,15 +50,10 @@ func (provider *KindProvider) RunCommandOnNodeExt(nodeName, cmd string, envs map
}

func (provider *KindProvider) GetKubeconfigPath() (string, error) {
homeDir, err := os.UserHomeDir()
if err != nil {
return "", fmt.Errorf("error when retrieving user home directory: %v", err)
}
kubeconfigPath := path.Join(homeDir, ".kube", "config")
if _, err := os.Stat(kubeconfigPath); os.IsNotExist(err) {
return "", fmt.Errorf("Kubeconfig file not found at expected location '%s'", kubeconfigPath)
if _, err := os.Stat(*kindKubeconfigPath); os.IsNotExist(err) {
return "", fmt.Errorf("Kubeconfig file not found at expected location '%s'", *kindKubeconfigPath)
}
return kubeconfigPath, nil
return *kindKubeconfigPath, nil
}

// enableKubectlOnControlPlane copies the Kubeconfig file on the Kind control-plane / control-plane Node to the
Expand Down

0 comments on commit 643f3e1

Please sign in to comment.