From bcc61e6596a51db112bdc50ff781e06f802b51a4 Mon Sep 17 00:00:00 2001 From: Peter Rifel Date: Mon, 19 Jul 2021 22:18:41 -0400 Subject: [PATCH 1/2] Assert the correct number of kubeconfig CAs during keypair rotation --- .../e2e/scenarios/keypair-rotation/run-test.sh | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/tests/e2e/scenarios/keypair-rotation/run-test.sh b/tests/e2e/scenarios/keypair-rotation/run-test.sh index 7afa7e33b4..c5be8a3ea9 100755 --- a/tests/e2e/scenarios/keypair-rotation/run-test.sh +++ b/tests/e2e/scenarios/keypair-rotation/run-test.sh @@ -40,17 +40,8 @@ ${KOPS} promote keypair all ${KOPS} update cluster --yes ${KOPS} rolling-update cluster --yes --validate-count=10 -KUBECFG_PROMOTE=$(mktemp -t kubeconfig.XXXXXXXXX) -${KOPS} export kubecfg --admin --kubeconfig="${KUBECFG_PROMOTE}" -kubectl --kubeconfig="${KUBECFG_PROMOTE}" config view > "${REPORT_DIR}/promote.kubeconfig" +${KOPS} validate cluster --wait=10m --count=3 -CA=$(kubectl --kubeconfig="${KUBECFG_PROMOTE}" config view --raw -o jsonpath="{.clusters[0].cluster.certificate-authority-data}" | base64 --decode) -if [ "$(echo "${CA}" | grep -c "BEGIN CERTIFICATE")" != "1" ]; then - >&2 echo unexpected number of CA certificates in kubeconfig - exit 1 -fi - -export KUBECONFIG="${KUBECFG_PROMOTE}" ${KOPS} distrust keypair all ${KOPS} update cluster --yes ${KOPS} rolling-update cluster --yes --validate-count=10 @@ -59,5 +50,11 @@ KUBECFG_DISTRUST=$(mktemp -t kubeconfig.XXXXXXXXX) ${KOPS} export kubecfg --admin --kubeconfig="${KUBECFG_DISTRUST}" kubectl --kubeconfig="${KUBECFG_DISTRUST}" config view > "${REPORT_DIR}/distrust.kubeconfig" +CA=$(kubectl --kubeconfig="${KUBECFG_DISTRUST}" config view --raw -o jsonpath="{.clusters[0].cluster.certificate-authority-data}" | base64 --decode) +if [ "$(echo "${CA}" | grep -c "BEGIN CERTIFICATE")" != "1" ]; then + >&2 echo unexpected number of CA certificates in kubeconfig + exit 1 +fi + export KUBECONFIG="${KUBECFG_DISTRUST}" ${KOPS} validate cluster --wait=10m --count=3 From 0fd13998282c3a6e3404e9954893ece318b71731 Mon Sep 17 00:00:00 2001 From: Peter Rifel Date: Mon, 19 Jul 2021 22:19:01 -0400 Subject: [PATCH 2/2] Fix whitespace to be consistent in file --- tests/e2e/scenarios/lib/common.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/e2e/scenarios/lib/common.sh b/tests/e2e/scenarios/lib/common.sh index 6f051c680a..40c1d7fad9 100644 --- a/tests/e2e/scenarios/lib/common.sh +++ b/tests/e2e/scenarios/lib/common.sh @@ -118,8 +118,8 @@ function kops-up() { create_args="${create_args} --zones=${ZONES}" fi ${KUBETEST2} \ - --up \ - --kops-binary-path="${KOPS}" \ - --kubernetes-version="1.21.0" \ - --create-args="${create_args}" + --up \ + --kops-binary-path="${KOPS}" \ + --kubernetes-version="1.21.0" \ + --create-args="${create_args}" } \ No newline at end of file