diff --git a/must-gather/collection-scripts/gather_ceph_resources b/must-gather/collection-scripts/gather_ceph_resources index 65b4b55e7b..b5039fdcd2 100755 --- a/must-gather/collection-scripts/gather_ceph_resources +++ b/must-gather/collection-scripts/gather_ceph_resources @@ -11,15 +11,21 @@ if [ "${BASE_COLLECTION_PATH}" = "" ]; then fi CEPH_COLLECTION_PATH="${BASE_COLLECTION_PATH}/ceph" -POD_TEMPLATE="/templates/pod.template" +POD_TEMPLATE_LATEST="/templates/pod.template.latest" +POD_TEMPLATE_STANDARD="/templates/pod.template.standard" SED_DELIMITER=$(echo -en "\001"); safe_replace () { sed "s${SED_DELIMITER}${1}${SED_DELIMITER}${2}${SED_DELIMITER}g" } -apply_helper_pod() { - < ${POD_TEMPLATE} safe_replace "NAMESPACE" "$1" | safe_replace "IMAGE_NAME" "$2" | safe_replace "MUST_GATHER" "$HOSTNAME" > pod_helper.yaml +apply_standard_helper_pod() { + < ${POD_TEMPLATE_STANDARD} safe_replace "NAMESPACE" "$1" | safe_replace "IMAGE_NAME" "$2" | safe_replace "MUST_GATHER" "$HOSTNAME" > pod_helper.yaml + oc apply -f pod_helper.yaml +} + +apply_latest_helper_pod() { + < ${POD_TEMPLATE_LATEST} safe_replace "NAMESPACE" "$1" | safe_replace "IMAGE_NAME" "$2" | safe_replace "MUST_GATHER" "$HOSTNAME" > pod_helper.yaml oc apply -f pod_helper.yaml } @@ -107,7 +113,12 @@ for ns in $namespaces; do if [ "${operatorImage}" = "" ]; then echo "not able to find the rook's operator image. Skipping collection of ceph command output" | tee -a "${BASE_COLLECTION_PATH}"/gather-debug.log elif [[ $cephClusterCount -gt 0 ]]; then - apply_helper_pod "$ns" "$operatorImage" + current_version=$(oc get csv -n "${ns}" --no-headers | awk '{print $5}' | tr -dc '0-9') + if [[ $current_version -ge 460 ]]; then + apply_latest_helper_pod "$ns" "$operatorImage" + else + apply_standard_helper_pod "$ns" "$operatorImage" + fi fi COMMAND_OUTPUT_DIR=${CEPH_COLLECTION_PATH}/must_gather_commands diff --git a/must-gather/templates/pod.template b/must-gather/templates/pod.template.latest old mode 100644 new mode 100755 similarity index 100% rename from must-gather/templates/pod.template rename to must-gather/templates/pod.template.latest diff --git a/must-gather/templates/pod.template.standard b/must-gather/templates/pod.template.standard new file mode 100755 index 0000000000..9a4614d719 --- /dev/null +++ b/must-gather/templates/pod.template.standard @@ -0,0 +1,49 @@ +apiVersion: v1 +kind: Pod +metadata: + name: MUST_GATHER-helper + namespace: NAMESPACE +spec: + containers: + - args: + - -g + - -- + - /usr/local/bin/toolbox.sh + command: + - /tini + env: + - name: ROOK_ADMIN_SECRET + valueFrom: + secretKeyRef: + key: admin-secret + name: rook-ceph-mon + image: IMAGE_NAME + imagePullPolicy: IfNotPresent + name: must-gather-helper + securityContext: + privileged: true + volumeMounts: + - mountPath: /dev + name: dev + - mountPath: /sys/bus + name: sysbus + - mountPath: /lib/modules + name: libmodules + - name: mon-endpoint-volume + mountPath: /etc/rook + volumes: + - name: dev + hostPath: + path: /dev + - name: sysbus + hostPath: + path: /sys/bus + - name: libmodules + hostPath: + path: /lib/modules + - name: mon-endpoint-volume + configMap: + name: rook-ceph-mon-endpoints + items: + - key: data + path: mon-endpoints