Skip to content

Commit b9ce921

Browse files
fix(ci): gate USB e2e by Kubernetes version and fallback to default NFS storage class (#2307)
Description Skip USB e2e specs on nested clusters that run Kubernetes versions below 1.34 by checking the actual API server version during the reusable CI pipeline. Also make NFS infra disks omit storageClassName when no storage class is explicitly set so the cluster default storage class can be used. ------------- Signed-off-by: Nikita Korolev <nikita.korolev@flant.com>
1 parent 2e62a98 commit b9ce921

2 files changed

Lines changed: 63 additions & 14 deletions

File tree

.github/workflows/e2e-reusable-pipeline.yml

Lines changed: 56 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,6 +1248,37 @@ jobs:
12481248
echo "Download dependencies"
12491249
go mod download
12501250
1251+
- name: Detect Kubernetes version for E2E
1252+
id: detect-k8s-version
1253+
run: |
1254+
set -euo pipefail
1255+
1256+
VERSION_JSON=$(kubectl version -o json)
1257+
SERVER_VERSION=$(echo "$VERSION_JSON" | jq -r '.serverVersion.gitVersion')
1258+
SERVER_MAJOR=$(echo "$VERSION_JSON" | jq -r '.serverVersion.major' | tr -cd '0-9')
1259+
SERVER_MINOR=$(echo "$VERSION_JSON" | jq -r '.serverVersion.minor' | tr -cd '0-9')
1260+
1261+
if [[ -z "$SERVER_MAJOR" || -z "$SERVER_MINOR" ]]; then
1262+
echo "[ERROR] Failed to parse Kubernetes server version: $SERVER_VERSION"
1263+
exit 1
1264+
fi
1265+
1266+
LABEL_FILTER=""
1267+
USB_SUPPORTED=false
1268+
1269+
if (( SERVER_MAJOR > 1 || (SERVER_MAJOR == 1 && SERVER_MINOR >= 34) )); then
1270+
USB_SUPPORTED=true
1271+
echo "[INFO] Kubernetes server version $SERVER_VERSION supports USB E2E tests"
1272+
else
1273+
LABEL_FILTER="!usb-precheck"
1274+
echo "[INFO] Kubernetes server version $SERVER_VERSION does not support USB E2E tests"
1275+
echo "[INFO] USB-labeled specs will be excluded with label filter: $LABEL_FILTER"
1276+
fi
1277+
1278+
echo "server-version=$SERVER_VERSION" >> "$GITHUB_OUTPUT"
1279+
echo "usb-supported=$USB_SUPPORTED" >> "$GITHUB_OUTPUT"
1280+
echo "label-filter=$LABEL_FILTER" >> "$GITHUB_OUTPUT"
1281+
12511282
- name: Create vmclass for e2e tests
12521283
run: |
12531284
if ! (kubectl get vmclass generic-for-e2e 2>/dev/null); then
@@ -1270,6 +1301,9 @@ jobs:
12701301
TIMEOUT: ${{ inputs.e2e_timeout }}
12711302
CSI: ${{ inputs.storage_type }}
12721303
STORAGE_CLASS_NAME: ${{ inputs.nested_storageclass_name }}
1304+
LABELS: ${{ steps.detect-k8s-version.outputs.label-filter }}
1305+
SERVER_K8S_VERSION: ${{ steps.detect-k8s-version.outputs.server-version }}
1306+
USB_SUPPORTED: ${{ steps.detect-k8s-version.outputs.usb-supported }}
12731307
working-directory: ./test/e2e/
12741308
run: |
12751309
GINKGO_RESULT=$(mktemp -p $RUNNER_TEMP)
@@ -1278,25 +1312,36 @@ jobs:
12781312
summary_file_name_junit="e2e_summary_${CSI}_${DATE}.xml"
12791313
ginkgo_json_report="ginkgo_report_${CSI}_${DATE}.json"
12801314
summary_file_name_json="e2e_summary_${CSI}_${DATE}.json"
1315+
FOCUS="${{ inputs.e2e_focus_tests }}"
12811316
12821317
cp -a legacy/testdata /tmp/testdata
12831318
1319+
echo "[INFO] Kubernetes server version: ${SERVER_K8S_VERSION}"
1320+
echo "[INFO] USB E2E supported: ${USB_SUPPORTED}"
1321+
if [ -n "${LABELS:-}" ]; then
1322+
echo "[INFO] Applying Ginkgo label filter: ${LABELS}"
1323+
fi
1324+
12841325
./scripts/precheck-prepare_ci.sh
12851326
12861327
set +e
1287-
FOCUS="${{ inputs.e2e_focus_tests }}"
1328+
GINKGO_ARGS=(
1329+
-v
1330+
--race
1331+
--timeout="$TIMEOUT"
1332+
--json-report="$ginkgo_json_report"
1333+
--junit-report="$summary_file_name_junit"
1334+
)
1335+
1336+
if [ -n "${LABELS:-}" ]; then
1337+
GINKGO_ARGS+=(--label-filter="$LABELS")
1338+
fi
1339+
12881340
if [ -n "$FOCUS" ]; then
1289-
go tool ginkgo \
1290-
--focus="$FOCUS" \
1291-
-v --race --timeout=$TIMEOUT \
1292-
--json-report=$ginkgo_json_report \
1293-
--junit-report=$summary_file_name_junit | tee $GINKGO_RESULT
1294-
else
1295-
go tool ginkgo \
1296-
-v --race --timeout=$TIMEOUT \
1297-
--json-report=$ginkgo_json_report \
1298-
--junit-report=$summary_file_name_junit | tee $GINKGO_RESULT
1341+
GINKGO_ARGS+=(--focus="$FOCUS")
12991342
fi
1343+
1344+
go tool ginkgo "${GINKGO_ARGS[@]}" | tee $GINKGO_RESULT
13001345
GINKGO_EXIT_CODE=$?
13011346
set -e
13021347

test/dvp-static-cluster/charts/infra/templates/nfs/vm.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ metadata:
1010
spec:
1111
persistentVolumeClaim:
1212
size: 150G
13-
storageClassName: linstor-thin-r1
13+
{{- if .Values.storageClass }}
14+
storageClassName: {{ .Values.storageClass }}
15+
{{- end }}
1416
---
1517
apiVersion: virtualization.deckhouse.io/v1alpha2
1618
kind: VirtualDisk
@@ -26,7 +28,9 @@ spec:
2628
type: ContainerImage
2729
persistentVolumeClaim:
2830
size: 1Gi
29-
storageClassName: linstor-thin-r1
31+
{{- if .Values.storageClass }}
32+
storageClassName: {{ .Values.storageClass }}
33+
{{- end }}
3034
---
3135
apiVersion: virtualization.deckhouse.io/v1alpha2
3236
kind: VirtualMachine
@@ -44,7 +48,7 @@ spec:
4448
name: nfs-vd-data
4549
bootloader: EFI
4650
cpu:
47-
coreFraction: 20%
51+
coreFraction: 50%
4852
cores: 1
4953
disruptions:
5054
restartApprovalMode: Automatic

0 commit comments

Comments
 (0)