Skip to content

Commit ae0edd9

Browse files
committed
ci: skip mapping configmap if file not found
Signed-off-by: Yang Chiu <yang.chiu@suse.com>
1 parent d975bfa commit ae0edd9

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

pipelines/utilities/run_longhorn_e2e_test.sh

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,42 +71,50 @@ run_longhorn_test(){
7171
yq e -i 'select(.spec.containers[0].env != null).spec.containers[0].env += {"name": "APPCO_TEST", "value": "'${APPCO_TEST}'"}' "${LONGHORN_TESTS_MANIFEST_FILE_PATH}"
7272

7373
# share instance mapping information between jenkins job agent and test pod for later use, e.g. power on/off nodes.
74-
kubectl create configmap instance-mapping --from-file=/tmp/instance_mapping
75-
yq -i '
74+
if [[ -f /tmp/instance_mapping ]]; then
75+
kubectl create configmap instance-mapping --from-file=/tmp/instance_mapping
76+
yq -i '
7677
select(.kind == "Pod").spec.volumes += [{
7778
"name": "instance-mapping",
7879
"configMap": {
7980
"name": "instance-mapping"
8081
}
8182
}]
8283
' "${LONGHORN_TESTS_MANIFEST_FILE_PATH}"
83-
yq -i '
84+
yq -i '
8485
select(.kind == "Pod").spec.containers[0].volumeMounts += [{
8586
"name": "instance-mapping",
8687
"mountPath": "/tmp/instance_mapping",
8788
"subPath": "instance_mapping",
8889
"readOnly": true
8990
}]
9091
' "${LONGHORN_TESTS_MANIFEST_FILE_PATH}"
92+
else
93+
echo "/tmp/instance_mapping not found, skipping instance mapping configmap setup"
94+
fi
9195

9296
# share public IP mapping information between jenkins job agent and test pod for later use, e.g. ssh to nodes.
93-
kubectl create configmap public-ip-mapping --from-file=/tmp/public_ip_mapping
94-
yq -i '
97+
if [[ -f /tmp/public_ip_mapping ]]; then
98+
kubectl create configmap public-ip-mapping --from-file=/tmp/public_ip_mapping
99+
yq -i '
95100
select(.kind == "Pod").spec.volumes += [{
96101
"name": "public-ip-mapping",
97102
"configMap": {
98103
"name": "public-ip-mapping"
99104
}
100105
}]
101106
' "${LONGHORN_TESTS_MANIFEST_FILE_PATH}"
102-
yq -i '
107+
yq -i '
103108
select(.kind == "Pod").spec.containers[0].volumeMounts += [{
104109
"name": "public-ip-mapping",
105110
"mountPath": "/tmp/public_ip_mapping",
106111
"subPath": "public_ip_mapping",
107112
"readOnly": true
108113
}]
109114
' "${LONGHORN_TESTS_MANIFEST_FILE_PATH}"
115+
else
116+
echo "/tmp/public_ip_mapping not found, skipping public IP mapping configmap setup"
117+
fi
110118

111119
# share ssh key with test pod for later use, e.g. ssh to nodes
112120
kubectl create secret generic ssh-key --from-file=$HOME/.ssh/id_rsa

0 commit comments

Comments
 (0)