@@ -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 '
7677select(.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 '
8485select(.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 '
95100select(.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 '
103108select(.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