Skip to content

Commit

Permalink
must-gather: add helper pod yaml with compatible secret for version <4.6
Browse files Browse the repository at this point in the history
add helper pod yaml with compatible secret for version <4.6
and change naming of templates according to the versions
>=4.6 will be latest and <4.6 will be standard.

Signed-off-by: crombus <pkundra@redhat.com>
  • Loading branch information
crombus committed Jan 15, 2021
1 parent 0c1dccc commit 4038a7a
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 4 deletions.
19 changes: 15 additions & 4 deletions must-gather/collection-scripts/gather_ceph_resources
Expand Up @@ -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
}

Expand Down Expand Up @@ -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
Expand Down
File renamed without changes.
49 changes: 49 additions & 0 deletions 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

0 comments on commit 4038a7a

Please sign in to comment.