From e7890ee8f620518fb21d4e3240adf5b5bc27108a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Thu, 9 Nov 2023 07:08:02 +0100 Subject: [PATCH 1/2] gha: Fix regex used to get kubectl version from the k3s version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It seems that with the new k3s release, they've bumped their kubectl version from x.y.z+k3s1 to x.y.z+k3s2. Let's ensure our regexp is more generic and future proof for such changes. Fixes: #8410 Signed-off-by: Fabiano FidĂȘncio --- tests/gha-run-k8s-common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/gha-run-k8s-common.sh b/tests/gha-run-k8s-common.sh index 4f7de35e14..2ed2f70b33 100644 --- a/tests/gha-run-k8s-common.sh +++ b/tests/gha-run-k8s-common.sh @@ -161,7 +161,7 @@ function deploy_k3s() { if [ "${ARCH}" = "x86_64" ]; then ARCH=amd64 fi - kubectl_version=$(/usr/local/bin/k3s kubectl version --short 2>/dev/null | grep "Client Version" | sed -e 's/Client Version: //' -e 's/\+k3s1//') + kubectl_version=$(/usr/local/bin/k3s kubectl version --short 2>/dev/null | grep "Client Version" | sed -e 's/Client Version: //' -e 's/\+k3s[0-9]\+//') sudo curl -fL --progress-bar -o /usr/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/${kubectl_version}/bin/linux/${ARCH}/kubectl sudo chmod +x /usr/bin/kubectl sudo rm -rf /usr/local/bin/kubectl From 455b7bf7760b2e8db002e0b3d2b8287076fc37f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Thu, 9 Nov 2023 08:42:25 +0100 Subject: [PATCH 2/2] gha: k3s: Avoid unnecessary escape MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There's no reason to escape the first + on the +k3s[0-9]\+ regex, as shown here: ```sh ubuntu@k3s:~$ /usr/local/bin/k3s kubectl version --short 2>/dev/null | \ grep "Client Version" | \ sed \ -e 's/Client Version: //' \ -e 's/+k3s[0-9]\+//' v1.27.7 ``` Signed-off-by: Fabiano FidĂȘncio --- tests/gha-run-k8s-common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/gha-run-k8s-common.sh b/tests/gha-run-k8s-common.sh index 2ed2f70b33..7617f5989e 100644 --- a/tests/gha-run-k8s-common.sh +++ b/tests/gha-run-k8s-common.sh @@ -161,7 +161,7 @@ function deploy_k3s() { if [ "${ARCH}" = "x86_64" ]; then ARCH=amd64 fi - kubectl_version=$(/usr/local/bin/k3s kubectl version --short 2>/dev/null | grep "Client Version" | sed -e 's/Client Version: //' -e 's/\+k3s[0-9]\+//') + kubectl_version=$(/usr/local/bin/k3s kubectl version --short 2>/dev/null | grep "Client Version" | sed -e 's/Client Version: //' -e 's/+k3s[0-9]\+//') sudo curl -fL --progress-bar -o /usr/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/${kubectl_version}/bin/linux/${ARCH}/kubectl sudo chmod +x /usr/bin/kubectl sudo rm -rf /usr/local/bin/kubectl