From 2da7f8c9ed2218fc1a3c91fb9e72d08c372cda2d Mon Sep 17 00:00:00 2001 From: Artem Glazychev Date: Wed, 26 Jan 2022 14:37:26 +0700 Subject: [PATCH] Calico fixes Signed-off-by: Artem Glazychev --- .cloudtest.yaml | 2 +- .cloudtest_calico.yaml | 2 +- .github/workflows/ci.yaml | 1 - go.mod | 2 +- main_test.go | 32 --------------------- scripts/calico/deploy-calico.sh | 5 ++-- scripts/calico/kustomization.yaml | 2 +- scripts/calico/setup-interfaces.sh | 42 ++++++++++++++++++++++++++-- scripts/create-kubernetes-cluster.sh | 15 +++++----- 9 files changed, 54 insertions(+), 49 deletions(-) diff --git a/.cloudtest.yaml b/.cloudtest.yaml index bceb398a..17ec795a 100644 --- a/.cloudtest.yaml +++ b/.cloudtest.yaml @@ -1,7 +1,7 @@ --- version: 1.0 root: "./.tests/cloud_test/" -timeout: 10800 # 3 hour total total timeout +timeout: 7200 # 2 hour total total timeout shuffle-enabled: true statistics: enabled: true diff --git a/.cloudtest_calico.yaml b/.cloudtest_calico.yaml index 1127f7b2..bb08463b 100644 --- a/.cloudtest_calico.yaml +++ b/.cloudtest_calico.yaml @@ -1,7 +1,7 @@ --- version: 1.0 root: "./.tests/cloud_test_calico/" -timeout: 10800 # 3 hour total total timeout +timeout: 7200 # 2 hour total total timeout shuffle-enabled: true statistics: enabled: true diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 02265945..80034573 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -83,7 +83,6 @@ jobs: - name: Install cloudtest # 3. Install cloudtest run: | go get github.com/networkservicemesh/cloudtest@master -# GOPROXY=direct go get github.com/Mixaster995/cloudtest@no-cleanup env: GO111MODULE: on GOBIN: /bin diff --git a/go.mod b/go.mod index 94cb645c..bb7bfd22 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/networkservicemesh/integratiohuhgyn-k8s-packet +module github.com/networkservicemesh/integration-k8s-packet go 1.16 diff --git a/main_test.go b/main_test.go index 07498b6b..8cdcf8ad 100644 --- a/main_test.go +++ b/main_test.go @@ -17,12 +17,10 @@ package main_test import ( - "os" "testing" "github.com/stretchr/testify/suite" - "github.com/networkservicemesh/integration-tests/suites/calico" "github.com/networkservicemesh/integration-tests/suites/heal" "github.com/networkservicemesh/integration-tests/suites/memory" "github.com/networkservicemesh/integration-tests/suites/multiforwarder" @@ -30,52 +28,22 @@ import ( "github.com/networkservicemesh/integration-tests/suites/sriov" ) -func isCalico() bool { - return os.Getenv("CALICO") == "on" -} - func TestMemory(t *testing.T) { - if isCalico() { - t.Skip("not available with Calico") - } suite.Run(t, new(memory.Suite)) } func TestSRIOV(t *testing.T) { - if isCalico() { - t.Skip("not available with Calico") - } suite.Run(t, new(sriov.Suite)) } func TestMultiForwarder(t *testing.T) { - if isCalico() { - t.Skip("not available with Calico") - } suite.Run(t, new(multiforwarder.Suite)) } func TestHeal(t *testing.T) { - if isCalico() { - t.Skip("not available with Calico") - } suite.Run(t, new(heal.Suite)) } func TestRunObservabilitySuite(t *testing.T) { suite.Run(t, new(observability.Suite)) } - -func TestBasic(t *testing.T) { - if isCalico() { - t.Skip("not available with Calico") - } - suite.Run(t, new(basic.Suite)) -} - -func TestCalico(t *testing.T) { - if !isCalico() { - t.Skip("not available without Calico") - } - suite.Run(t, new(calico.Suite)) -} diff --git a/scripts/calico/deploy-calico.sh b/scripts/calico/deploy-calico.sh index b1753164..4f5fec1f 100755 --- a/scripts/calico/deploy-calico.sh +++ b/scripts/calico/deploy-calico.sh @@ -6,7 +6,8 @@ function on_error() { } trap 'on_error' ERR +kubectl apply -f https://projectcalico.docs.tigera.io/v3.22/manifests/tigera-operator.yaml +kubectl apply -f https://raw.githubusercontent.com/projectcalico/vpp-dataplane/master/yaml/calico/installation-default.yaml kubectl apply -k scripts/calico -kubectl -n calico-vpp-dataplane rollout status daemonset/calico-vpp-node --timeout=5m -kubectl -n kube-system rollout status deployment/calico-kube-controllers --timeout=5m +kubectl rollout status -n calico-vpp-dataplane ds/calico-vpp-node --timeout=10m diff --git a/scripts/calico/kustomization.yaml b/scripts/calico/kustomization.yaml index 446d8683..997912f1 100644 --- a/scripts/calico/kustomization.yaml +++ b/scripts/calico/kustomization.yaml @@ -3,7 +3,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: - - https://raw.githubusercontent.com/projectcalico/vpp-dataplane/v0.17.0-calicov3.20.2/yaml/generated/calico-vpp-nohuge.yaml + - https://raw.githubusercontent.com/projectcalico/vpp-dataplane/master/yaml/generated/calico-vpp-nohuge.yaml patchesStrategicMerge: - patch.yaml diff --git a/scripts/calico/setup-interfaces.sh b/scripts/calico/setup-interfaces.sh index c093f56b..f2d26262 100755 --- a/scripts/calico/setup-interfaces.sh +++ b/scripts/calico/setup-interfaces.sh @@ -2,7 +2,43 @@ set -e -ip="$1" +cdr2mask () +{ + # Number of args to shift, 255..255, first non-255 byte, zeroes + set -- $(( 5 - ("$1" / 8) )) 255 255 255 255 $(( (255 << (8 - ("$1" % 8))) & 255 )) 0 0 0 + if [[ "$1" -gt 1 ]] + then + shift "$1" + else + shift + fi + echo "${1-0}"."${2-0}"."${3-0}"."${4-0}" +} -ip addr add "${ip}" dev eno2 -ip link set up dev eno2 +iface="$1" +ip="$2" +cidr="$3" +mask=$(cdr2mask "$3") + +# Unbond interface and set IP address +cd /etc/network/ +awk -v pattern="iface $1 inet" -v ip="$2" -v mask="$mask" ' + $0 ~ pattern { + printf "%s static\n",pattern; + printf " address %s\n",ip; + printf " netmask %s\n",mask; + getline; + while ($0 != "") { + if ($1=="bond-master") { + next; + break + }; + print; + getline + } + } 1 +' interfaces > interfaces.tmp && mv interfaces.tmp interfaces +cd +ifenslave -d bond0 "${iface}" +ip addr change "${ip}/${cidr}" dev "${iface}" +ip link set up dev "${iface}" diff --git a/scripts/create-kubernetes-cluster.sh b/scripts/create-kubernetes-cluster.sh index b5529dba..cff6172b 100755 --- a/scripts/create-kubernetes-cluster.sh +++ b/scripts/create-kubernetes-cluster.sh @@ -15,7 +15,8 @@ if [[ "$CALICO" == "on" ]]; then # calico CALICO_MASTER_IP="10.0.0.$(( base_ip + 1 ))" CALICO_WORKER_IP="10.0.0.$(( base_ip + 2 ))" - CALICO_SUBNET_MASK="30" + CALICO_CIDR_PREFIX="30" + CALICO_INTERFACE="eno2" fi ENVS="KUBERNETES_VERSION CALICO" @@ -53,24 +54,24 @@ wait_pids "${pids}" "SR-IOV config failed" || exit 21 if [[ "$CALICO" == "on" ]]; then # calico # 3. Create Calico scripts directory on nodes. - ssh ${SSH_OPTS} root@${master_ip} mkdir calico || exit 31 - ssh ${SSH_OPTS} root@${worker_ip} mkdir calico || exit 32 + ssh ${SSH_OPTS} root@${master_ip} mkdir -p calico || exit 31 + ssh ${SSH_OPTS} root@${worker_ip} mkdir -p calico || exit 32 # 4. Setup Calico interfaces. scp ${SSH_OPTS} scripts/calico/setup-interfaces.sh root@${master_ip}:calico/setup-interfaces.sh || exit 41 scp ${SSH_OPTS} scripts/calico/setup-interfaces.sh root@${worker_ip}:calico/setup-interfaces.sh || exit 42 pids="" - ssh ${SSH_OPTS} root@${master_ip} ./calico/setup-interfaces.sh "${CALICO_MASTER_IP}/${CALICO_SUBNET_MASK}" & + ssh ${SSH_OPTS} root@${master_ip} ./calico/setup-interfaces.sh "${CALICO_INTERFACE}" "${CALICO_MASTER_IP}" "${CALICO_CIDR_PREFIX}" & pids+=" $!" - ssh ${SSH_OPTS} root@${worker_ip} ./calico/setup-interfaces.sh "${CALICO_WORKER_IP}/${CALICO_SUBNET_MASK}" & + ssh ${SSH_OPTS} root@${worker_ip} ./calico/setup-interfaces.sh "${CALICO_INTERFACE}" "${CALICO_WORKER_IP}" "${CALICO_CIDR_PREFIX}" & pids+=" $!" wait_pids "${pids}" "setup Calico interfaces failed" || exit 43 fi # 5. Create k8s scripts directory on nodes. -ssh ${SSH_OPTS} root@${master_ip} mkdir k8s || exit 51 -ssh ${SSH_OPTS} root@${worker_ip} mkdir k8s || exit 52 +ssh ${SSH_OPTS} root@${master_ip} mkdir -p k8s || exit 51 +ssh ${SSH_OPTS} root@${worker_ip} mkdir -p k8s || exit 52 # 6. Config docker. scp ${SSH_OPTS} scripts/k8s/config-docker.sh root@${master_ip}:k8s/config-docker.sh || exit 61