Skip to content

Commit 9a986d4

Browse files
author
Jesus Carrillo
committed
fixed csi-sanity checks
In order for the node-server sanity checks to pass we have to: 1. Add Linode token and api to the nodeserver daemonset There's a need for the nodeserver to have linode api access because sanity checks require CreateVolume and ListVolume. By patching the node-server Daemonset and injecting the LINODE_TOKEN The Controller Code Path is able to be initialized with a proper client. This is not needed for normal nodeserver operation, however the sanity-checks expect the ability for the nodeserver to also perform controller functions. E2E tests pass without the need of LINODE_TOKEN in the nodeserver
1 parent 91c7be7 commit 9a986d4

File tree

2 files changed

+51
-12
lines changed

2 files changed

+51
-12
lines changed

hack/generate-yaml.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ fi
1919

2020
cd $(dirname "$0")/../
2121
file=./deploy/kubernetes/overlays/release/kustomization.yaml
22-
CSI_VERSION=$TAG CSI_IMAGE_NAME=$IMAGE_NAME envsubst < "$file.template" > $file
22+
CSI_VERSION=$TAG CSI_IMAGE_NAME=$IMAGE_NAME envsubst <"$file.template" >$file
2323

2424
kustomize build "$(dirname $file)"

tests/csi-sanity/run-tests.sh

Lines changed: 50 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,19 @@ DELETE_DIRECTORY="./tests/csi-sanity/rmdir_in_pod.sh"
1010

1111
# Define the list of tests to skip as an array
1212
SKIP_TESTS=(
13-
"WithCapacity"
14-
# Need to skip it because we do not support volume snapshots
15-
"should fail when the volume source volume is not found"
16-
# This case fails because we currently do not support read only volume creation on the linode side
17-
# but we are supporting it in the CSI driver by mounting the volume as read only
18-
"should fail when the volume is already published but is incompatible"
13+
"WithCapacity"
14+
# Need to skip it because we do not support volume snapshots
15+
"should fail when the volume source volume is not found"
16+
# This case fails because we currently do not support read only volume creation on the linode side
17+
# but we are supporting it in the CSI driver by mounting the volume as read only
18+
"should fail when the volume is already published but is incompatible"
1919
)
2020

2121
# Join the array into a single string with '|' as the separator
22-
SKIP_TESTS_STRING=$(IFS='|'; echo "${SKIP_TESTS[*]}")
22+
SKIP_TESTS_STRING=$(
23+
IFS='|'
24+
echo "${SKIP_TESTS[*]}"
25+
)
2326

2427
# Install the latest version of csi-sanity
2528
go install github.com/kubernetes-csi/csi-test/v5/cmd/csi-sanity@latest
@@ -30,8 +33,44 @@ kubectl apply -f tests/csi-sanity/socat.yaml
3033
# Wait for pod to be ready
3134
kubectl wait --for=condition=ready --timeout=60s pods/csi-socat-0
3235

36+
# Patch the NodeServer daemonset and add the LINODE_TOKEN and LINODE_API env vars.
37+
# The csi-sanity check require CrateVolume and ListVolume calls to be working.
38+
39+
# Warning: This patch expects the csi-linode-plugin container to be the 2nd container
40+
# in the manifest
41+
kubectl patch daemonset csi-linode-node \
42+
-n kube-system \
43+
--type='json' \
44+
-p='[
45+
{
46+
"op": "add",
47+
"path": "/spec/template/spec/containers/1/env/-",
48+
"value": {
49+
"name": "LINODE_URL",
50+
"value": "https://api.linode.com/v4"
51+
}
52+
},
53+
{
54+
"op": "add",
55+
"path": "/spec/template/spec/containers/1/env/-",
56+
"value": {
57+
"name": "LINODE_TOKEN",
58+
"valueFrom": {
59+
"secretKeyRef": {
60+
"name": "linode",
61+
"key": "token"
62+
}
63+
}
64+
}
65+
}
66+
]'
67+
68+
echo "Waiting for daemonset csi-linode-node to be ready"
69+
kubectl rollout status daemonset/csi-linode-node -n kube-system
70+
kubectl wait --namespace kube-system --for=condition=Ready pods --selector=app=csi-linode-node --timeout=180s
71+
3372
# Start the port forwarding in the background and log output to a file
34-
nohup kubectl port-forward pods/csi-socat-0 10000:10000 > port-forward.log 2>&1 &
73+
nohup kubectl port-forward pods/csi-socat-0 10000:10000 >port-forward.log 2>&1 &
3574

3675
# Run the csi-sanity tests with the specified parameters
3776
csi-sanity --ginkgo.vv --ginkgo.trace --ginkgo.skip "$SKIP_TESTS_STRING" --csi.endpoint="$CSI_ENDPOINT" --csi.createstagingpathcmd="$CREATE_DIRECTORY" --csi.createmountpathcmd="$CREATE_DIRECTORY" --csi.removestagingpathcmd="$DELETE_DIRECTORY" --csi.removemountpathcmd="$DELETE_DIRECTORY"
@@ -41,10 +80,10 @@ PID=$(lsof -t -i :10000 -sTCP:LISTEN)
4180

4281
# Check if a PID was found and kill the process if it exists
4382
if [ -z "$PID" ]; then
44-
echo "No process found on port 10000."
83+
echo "No process found on port 10000."
4584
else
46-
kill -9 "$PID"
47-
echo "Process on port 10000 with PID $PID has been killed."
85+
kill -9 "$PID"
86+
echo "Process on port 10000 with PID $PID has been killed."
4887
fi
4988

5089
# Remove the socat statefulset

0 commit comments

Comments
 (0)