diff --git a/collection-scripts/gather_apiservices b/collection-scripts/gather_apiservices index 5474803..e542a25 100755 --- a/collection-scripts/gather_apiservices +++ b/collection-scripts/gather_apiservices @@ -7,15 +7,15 @@ if [[ -z "$DIR_NAME" ]]; then fi # Resource list -resources=() +apiservices=() # explicitly adding rabbitmq in the grep because we rely on the rabbitmq-cluster-operator for i in $(/usr/bin/oc get apiservices --all-namespaces | grep -E "(openstack|rabbitmq)\.(org|com)" | awk '{ print $1 }') do - resources+=("$i") + apiservices+=("$i") done -for resource in "${resources[@]}"; do +for resource in "${apiservices[@]}"; do mkdir -p "$BASE_COLLECTION_PATH"/apiservices/ run_bg /usr/bin/oc get apiservice "${resource}" -o yaml '>' "${BASE_COLLECTION_PATH}/apiservices/${resource}.yaml" done diff --git a/collection-scripts/gather_crds b/collection-scripts/gather_crds index 292af6b..9068fa0 100755 --- a/collection-scripts/gather_crds +++ b/collection-scripts/gather_crds @@ -8,17 +8,19 @@ fi # Resource list -resources=() +crds=() for i in $(/usr/bin/oc get crd | grep openstack.org | awk '{print $1}') do - resources+=("crd/$i") + crds+=("$i") done echo "Gathering CRDs" +mkdir -p "$BASE_COLLECTION_PATH"/crd + # Run the collection of resources using must-gather -for resource in "${resources[@]}"; do - run_bg /usr/bin/oc adm inspect --dest-dir must-gather "${resource}" +for resource in "${crds[@]}"; do + run_bg /usr/bin/oc get crd "$resource" -o yaml > "${BASE_COLLECTION_PATH}/crd/${resource}.yaml" done [[ $CALLED -eq 1 ]] && wait_bg diff --git a/collection-scripts/gather_crs b/collection-scripts/gather_crs index e2cc697..bd055a7 100755 --- a/collection-scripts/gather_crs +++ b/collection-scripts/gather_crs @@ -8,33 +8,29 @@ if [[ -z "$DIR_NAME" ]]; then fi # Resource list -resources=() +crs=() # explictly adding rabbit in the grep because it's not part of the openstack # umbrella and we rely on the upstream rabbitmq-cluster-operator for i in $(/usr/bin/oc get crd | grep -E "(openstack|rabbitmq)\.(org|com)" | awk '{print $1}') do - resources+=("$i") + crs+=("$i") done # explicitly adding Metal3 BareMetalHosts -resources+=("baremetalhosts.metal3.io") +crs+=("baremetalhosts.metal3.io") # we use nested loops to nicely output objects partitioned per namespace, kind echo "Gathering CRs" -for resource in "${resources[@]}"; do - /usr/bin/oc get "${resource}" --all-namespaces -o custom-columns=NAME:.metadata.name,NAMESPACE:.metadata.namespace --no-headers 2> /dev/null | \ +for res in "${crs[@]}"; do + /usr/bin/oc get "${res}" --all-namespaces -o custom-columns=NAME:.metadata.name,NAMESPACE:.metadata.namespace --no-headers 2> /dev/null | \ while read -r ocresource; do ocobject=$(echo "$ocresource" | awk '{print $1}') ocproject=$(echo "$ocresource" | awk '{print $2}') - if [ -z "${ocproject}" ]||[ "${ocproject}" == "" ]; then - object_collection_path=${BASE_COLLECTION_PATH}/cluster-scoped-resources/${resource} + if [ -n "${ocproject}" ] && [ "${ocproject}" != "" ]; then + object_collection_path=${BASE_COLLECTION_PATH}/namespaces/${ocproject}/crs/${res} mkdir -p "${object_collection_path}" - run_bg /usr/bin/oc get "${resource}" -o yaml "${ocobject}" '>' "${object_collection_path}/${ocobject}.yaml" - else - object_collection_path=${BASE_COLLECTION_PATH}/namespaces/${ocproject}/crs/${resource} - mkdir -p "${object_collection_path}" - run_bg /usr/bin/oc get "${resource}" -n "${ocproject}" -o yaml "${ocobject}" '>' "${object_collection_path}/${ocobject}.yaml" + run_bg /usr/bin/oc get "${res}" -n "${ocproject}" -o yaml "${ocobject}" '>' "${object_collection_path}/${ocobject}.yaml" fi done done