Skip to content

Commit 1143a88

Browse files
authored
Fix the cause of failure of multiple kind job runs (#6468)
on same VM. There were three 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. 3) Cleanup of antrea images after test. Signed-off-by: Pulkit Jain <[email protected]>
1 parent f74eee0 commit 1143a88

File tree

4 files changed

+23
-23
lines changed

4 files changed

+23
-23
lines changed

Makefile

+11-9
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,6 @@ TEST_ARGS ?=
3737
# If we have stdin we can run interactive so the tests running in docker can be interrupted.
3838
INTERACTIVE_ARGS := $(shell [ -t 0 ] && echo "-it")
3939

40-
BUILD_TAG :=
41-
ifndef CUSTOM_BUILD_TAG
42-
BUILD_TAG = $(shell build/images/build-tag.sh)
43-
else
44-
BUILD_TAG = $(CUSTOM_BUILD_TAG)
45-
DOCKER_IMG_VERSION = $(CUSTOM_BUILD_TAG)
46-
endif
47-
4840
DOCKER_BUILD_ARGS :=
4941
ifeq ($(NO_PULL),)
5042
DOCKER_BUILD_ARGS += --pull
@@ -57,7 +49,6 @@ ifneq ($(DOCKER_TARGETPLATFORM),)
5749
endif
5850
DOCKER_BUILD_ARGS += --build-arg OVS_VERSION=$(OVS_VERSION)
5951
DOCKER_BUILD_ARGS += --build-arg GO_VERSION=$(GO_VERSION)
60-
DOCKER_BUILD_ARGS += --build-arg BUILD_TAG=$(BUILD_TAG)
6152

6253
export CGO_ENABLED
6354

@@ -66,6 +57,17 @@ all: build
6657

6758
include versioning.mk
6859

60+
# This should be located after the include directive for versioning.mk,
61+
# so that we can override DOCKER_IMG_VERSION with CUSTOM_BUILD_TAG.
62+
BUILD_TAG :=
63+
ifndef CUSTOM_BUILD_TAG
64+
BUILD_TAG = $(shell build/images/build-tag.sh)
65+
else
66+
BUILD_TAG = $(CUSTOM_BUILD_TAG)
67+
DOCKER_IMG_VERSION = $(CUSTOM_BUILD_TAG)
68+
endif
69+
DOCKER_BUILD_ARGS += --build-arg BUILD_TAG=$(BUILD_TAG)
70+
6971
LDFLAGS += $(VERSION_LDFLAGS)
7072

7173
UNAME_S := $(shell uname -s)

ci/jenkins/test.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ Run K8s e2e community tests (Conformance & Network Policy) or Antrea e2e tests o
7373
--kind-cluster-name Name of the kind Cluster.
7474
--proxyall Enable proxyAll to test AntreaProxy.
7575
--build-tag Custom build tag for images.
76-
--docker-user Username for Docker account.
77-
--docker-password Password for Docker account."
76+
--docker-user Username for Docker account.
77+
--docker-password Password for Docker account."
7878

7979
function print_usage {
8080
echoerr "$_usage"
@@ -201,7 +201,7 @@ function clean_antrea {
201201
for antrea_yml in ${WORKDIR}/*.yml; do
202202
kubectl delete -f $antrea_yml --ignore-not-found=true || true
203203
done
204-
docker images --format "{{.Repository}}:{{.Tag}}" | grep 'antrea'| xargs -r docker rmi -f || true
204+
docker images --format "{{.Repository}}:{{.Tag}}" | grep ${BUILD_TAG} | xargs -r docker rmi || true
205205
docker images | grep '<none>' | awk '{print $3}' | xargs -r docker rmi || true
206206
check_and_cleanup_docker_build_cache
207207
}
@@ -666,9 +666,9 @@ function run_e2e {
666666
if [[ $TESTBED_TYPE == "flexible-ipam" ]]; then
667667
go test -v antrea.io/antrea/test/e2e --logs-export-dir `pwd`/antrea-test-logs --provider remote -timeout=100m --prometheus --antrea-ipam
668668
elif [[ $TESTBED_TYPE == "kind" ]]; then
669-
go test -v antrea.io/antrea/test/e2e --logs-export-dir `pwd`/antrea-test-logs --provider kind -timeout=100m --prometheus
669+
go test -v antrea.io/antrea/test/e2e --logs-export-dir `pwd`/antrea-test-logs --provider kind --kind.kubeconfig ${KUBECONFIG_PATH} -timeout=100m --prometheus
670670
elif [[ $TESTBED_TYPE == "kind-flexible-ipam" ]]; then
671-
go test -v antrea.io/antrea/test/e2e --logs-export-dir `pwd`/antrea-test-logs --provider kind -timeout=100m --prometheus --antrea-ipam
671+
go test -v antrea.io/antrea/test/e2e --logs-export-dir `pwd`/antrea-test-logs --provider kind --kind.kubeconfig ${KUBECONFIG_PATH} -timeout=100m --prometheus --antrea-ipam
672672
else
673673
go test -v antrea.io/antrea/test/e2e --logs-export-dir `pwd`/antrea-test-logs --provider remote -timeout=100m --prometheus
674674
fi

ci/kind/kind-setup.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ function clean_kind {
565565
flock -x 200
566566

567567
current_timestamp=$(date +%s)
568-
touch ~/.antrea/.clusters.swp
568+
> ~/.antrea/.clusters.swp
569569
while IFS=' ' read -r name creationTimestamp; do
570570
if [[ -z "$name" || -z "$creationTimestamp" ]]; then
571571
continue

test/e2e/providers/kind.go

+6-8
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package providers
1616

1717
import (
18+
"flag"
1819
"fmt"
1920
"os"
2021
"path"
@@ -23,6 +24,8 @@ import (
2324
"antrea.io/antrea/test/e2e/providers/exec"
2425
)
2526

27+
var kindKubeconfigPath = flag.String("kind.kubeconfig", path.Join(homedir, ".kube", "config"), "Path of the kubeconfig of the cluster")
28+
2629
type KindProvider struct {
2730
controlPlaneNodeName string
2831
}
@@ -47,15 +50,10 @@ func (provider *KindProvider) RunCommandOnNodeExt(nodeName, cmd string, envs map
4750
}
4851

4952
func (provider *KindProvider) GetKubeconfigPath() (string, error) {
50-
homeDir, err := os.UserHomeDir()
51-
if err != nil {
52-
return "", fmt.Errorf("error when retrieving user home directory: %v", err)
53-
}
54-
kubeconfigPath := path.Join(homeDir, ".kube", "config")
55-
if _, err := os.Stat(kubeconfigPath); os.IsNotExist(err) {
56-
return "", fmt.Errorf("Kubeconfig file not found at expected location '%s'", kubeconfigPath)
53+
if _, err := os.Stat(*kindKubeconfigPath); os.IsNotExist(err) {
54+
return "", fmt.Errorf("Kubeconfig file not found at expected location '%s'", *kindKubeconfigPath)
5755
}
58-
return kubeconfigPath, nil
56+
return *kindKubeconfigPath, nil
5957
}
6058

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

0 commit comments

Comments
 (0)