Skip to content

Commit

Permalink
Merge pull request #40 from black-dragon74/export-base-path
Browse files Browse the repository at this point in the history
Improve handling of BASE_COLLECTION_PATH
  • Loading branch information
yati1998 authored Aug 2, 2023
2 parents 9e5c879 + 742f3c5 commit caea8d8
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 55 deletions.
2 changes: 1 addition & 1 deletion must-gather/collection-scripts/gather
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
BASE_COLLECTION_PATH="must-gather"
export BASE_COLLECTION_PATH="must-gather"
mkdir -p ${BASE_COLLECTION_PATH}

# Command line argument
Expand Down
26 changes: 11 additions & 15 deletions must-gather/collection-scripts/gather_ceph_resources
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
#!/bin/bash

# Expect base collection path as an argument
BASE_COLLECTION_PATH=$1
# Expect base collection path as an exported variable
# If it is not defined, use PWD instead
BASE_COLLECTION_PATH=${BASE_COLLECTION_PATH:-"$(pwd)"}

# Expect time option as an argument
SINCE_TIME=$2

gather_common_ceph_resources "${BASE_COLLECTION_PATH}" "${SINCE_TIME}"

# Use PWD as base path if no argument is passed
if [ "${BASE_COLLECTION_PATH}" = "" ]; then
BASE_COLLECTION_PATH=$(pwd)
fi

CEPH_GATHER_DBGLOG="${BASE_COLLECTION_PATH}"/gather-ceph-debug.log
CEPH_COLLECTION_PATH="${BASE_COLLECTION_PATH}/ceph"

Expand Down Expand Up @@ -256,14 +252,14 @@ for ns in $namespaces; do
pids_rbd=()
for image in $images; do
dbglogf "${CEPH_GATHER_DBGLOG}" "collecting vol and snapshot info for ${image}"
{
printf "Collecting image info for: %s/%s\n" "${bp}" "${image}";
timeout 120 oc -n "${ns}" exec "${HOSTNAME}"-helper -- bash -c "rbd info $image --pool $bp" 2>> "${COMMAND_ERR_OUTPUT_DIR}"/gather-rbd-image-"${image}"-debug.log;
printf "Collecting image status for: %s/%s\n" "${bp}" "${image}";
timeout 120 oc -n "${ns}" exec "${HOSTNAME}"-helper -- bash -c "rbd status $image --pool $bp" 2>> "${COMMAND_ERR_OUTPUT_DIR}"/gather-rbd-image-status-"${image}"-debug.log;
printf "Collecting snap info for: %s/%s\n" "${bp}" "${image}";
timeout 120 oc -n "${ns}" exec "${HOSTNAME}"-helper -- bash -c "rbd snap ls --all $image --pool $bp" 2>> "${COMMAND_ERR_OUTPUT_DIR}"/gather-rbd-snap-"${image}"-debug.log;
timeout 120 oc -n "${ns}" exec "${HOSTNAME}"-helper -- bash -c "rbd snap ls --all --format=json --pretty-format $image --pool $bp" 2>> "${COMMAND_ERR_OUTPUT_DIR}"/gather-rbd-snap-json-"${image}"-debug.log;
{
printf "Collecting image info for: %s/%s\n" "${bp}" "${image}"
timeout 120 oc -n "${ns}" exec "${HOSTNAME}"-helper -- bash -c "rbd info $image --pool $bp" 2>>"${COMMAND_ERR_OUTPUT_DIR}"/gather-rbd-image-"${image}"-debug.log
printf "Collecting image status for: %s/%s\n" "${bp}" "${image}"
timeout 120 oc -n "${ns}" exec "${HOSTNAME}"-helper -- bash -c "rbd status $image --pool $bp" 2>>"${COMMAND_ERR_OUTPUT_DIR}"/gather-rbd-image-status-"${image}"-debug.log
printf "Collecting snap info for: %s/%s\n" "${bp}" "${image}"
timeout 120 oc -n "${ns}" exec "${HOSTNAME}"-helper -- bash -c "rbd snap ls --all $image --pool $bp" 2>>"${COMMAND_ERR_OUTPUT_DIR}"/gather-rbd-snap-"${image}"-debug.log
timeout 120 oc -n "${ns}" exec "${HOSTNAME}"-helper -- bash -c "rbd snap ls --all --format=json --pretty-format $image --pool $bp" 2>>"${COMMAND_ERR_OUTPUT_DIR}"/gather-rbd-snap-json-"${image}"-debug.log
} >>"${COMMAND_OUTPUT_DIR}"/rbd_vol_and_snap_info_"${image}".part &
pids_rbd+=($!)
done
Expand Down
10 changes: 3 additions & 7 deletions must-gather/collection-scripts/gather_clusterscoped_resources
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
#!/bin/bash
# Expect base collection path as an argument
BASE_COLLECTION_PATH=$1

# Use PWD as base path if no argument is passed
if [ "${BASE_COLLECTION_PATH}" = "" ]; then
BASE_COLLECTION_PATH=$(pwd)
fi
# Expect base collection path as an exported variable
# If it is not defined, use PWD instead
BASE_COLLECTION_PATH=${BASE_COLLECTION_PATH:-"$(pwd)"}

# Expect time option as an argument
SINCE_TIME=$2
Expand Down
10 changes: 3 additions & 7 deletions must-gather/collection-scripts/gather_common_ceph_resources
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
#!/bin/bash

# Expect base collection path as an argument
BASE_COLLECTION_PATH=$1
# Expect base collection path as an exported variable
# If it is not defined, use PWD instead
BASE_COLLECTION_PATH=${BASE_COLLECTION_PATH:-"$(pwd)"}

# Expect time option as an argument
SINCE_TIME=$2

# Use PWD as base path if no argument is passed
if [ "${BASE_COLLECTION_PATH}" = "" ]; then
BASE_COLLECTION_PATH=$(pwd)
fi

CEPH_COLLECTION_PATH="${BASE_COLLECTION_PATH}/ceph"

# common Ceph resources
Expand Down
28 changes: 12 additions & 16 deletions must-gather/collection-scripts/gather_namespaced_resources
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
#!/bin/bash
# Expect base collection path as an argument
BASE_COLLECTION_PATH=$1

# Use PWD as base path if no argument is passed
if [ "${BASE_COLLECTION_PATH}" = "" ]; then
BASE_COLLECTION_PATH=$(pwd)
fi
# Expect base collection path as an exported variable
# If it is not defined, use PWD instead
BASE_COLLECTION_PATH=${BASE_COLLECTION_PATH:-"$(pwd)"}

# Expect time option as an argument
SINCE_TIME=$2
Expand Down Expand Up @@ -188,11 +184,11 @@ if [ "$(oc get storageclassclaim --no-headers -A | awk '{print $2}')" != "" ]; t
fi

# Collect details of managedfusionoffering of all namespaces for managed services
echo "collecting dump of oc get managedfusionoffering all namespaces" | tee -a "${BASE_COLLECTION_PATH}/gather-debug.log"
if [ "$(oc get managedfusionoffering --no-headers -A | awk '{print $1}')" != "" ] ; then
{ oc get managedfusionoffering --all-namespaces; } >> "${BASE_COLLECTION_PATH}/namespaces/all/get_managedfusionoffering_all_ns"
{ oc describe managedfusionoffering --all-namespaces; } >> "${BASE_COLLECTION_PATH}/namespaces/all/desc_managedfusionoffering_all_ns"
{ oc get managedfusionoffering -oyaml --all-namespaces; } >> "${BASE_COLLECTION_PATH}/namespaces/all/get_yaml_managedfusionoffering_all_ns"
echo "collecting dump of oc get managedfusionoffering all namespaces" | tee -a "${BASE_COLLECTION_PATH}/gather-debug.log"
if [ "$(oc get managedfusionoffering --no-headers -A | awk '{print $1}')" != "" ]; then
{ oc get managedfusionoffering --all-namespaces; } >>"${BASE_COLLECTION_PATH}/namespaces/all/get_managedfusionoffering_all_ns"
{ oc describe managedfusionoffering --all-namespaces; } >>"${BASE_COLLECTION_PATH}/namespaces/all/desc_managedfusionoffering_all_ns"
{ oc get managedfusionoffering -oyaml --all-namespaces; } >>"${BASE_COLLECTION_PATH}/namespaces/all/get_yaml_managedfusionoffering_all_ns"
fi

# Collect csi-addons object details of all namespaces
Expand Down Expand Up @@ -224,8 +220,8 @@ if [ "$(oc get networkfence --no-headers -A | awk '{print $1}')" != "" ]; then
{ oc get networkfence -oyaml --all-namespaces; } >>"${BASE_COLLECTION_PATH}/namespaces/all/get_yaml_networkfence_all_ns"
fi

echo "collecting network-attachment-definitions of oc get network-attachment-definitions all namespaces" | tee -a "${BASE_COLLECTION_PATH}/gather-debug.log"
if [ "$(oc get network-attachment-definitions --no-headers -A | awk '{print $1}')" != "" ] ; then
{ oc get network-attachment-definitions -oyaml --all-namespaces; } >> "${BASE_COLLECTION_PATH}/namespaces/all/get_yaml_net_attach_def_all_ns"
{ oc describe network-attachment-definitions --all-namespaces; } >> "${BASE_COLLECTION_PATH}/namespaces/all/desc_net_attach_def_all_ns"
echo "collecting network-attachment-definitions of oc get network-attachment-definitions all namespaces" | tee -a "${BASE_COLLECTION_PATH}/gather-debug.log"
if [ "$(oc get network-attachment-definitions --no-headers -A | awk '{print $1}')" != "" ]; then
{ oc get network-attachment-definitions -oyaml --all-namespaces; } >>"${BASE_COLLECTION_PATH}/namespaces/all/get_yaml_net_attach_def_all_ns"
{ oc describe network-attachment-definitions --all-namespaces; } >>"${BASE_COLLECTION_PATH}/namespaces/all/desc_net_attach_def_all_ns"
fi
10 changes: 3 additions & 7 deletions must-gather/collection-scripts/gather_noobaa_resources
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
#!/bin/bash

# Expect base collection path as an argument
BASE_COLLECTION_PATH=$1
# Expect base collection path as an exported variable
# If it is not defined, use PWD instead
BASE_COLLECTION_PATH=${BASE_COLLECTION_PATH:-"$(pwd)"}

# Expect time option as an argument
SINCE_TIME=$2

# Use PWD as base path if no argument is passed
if [ "${BASE_COLLECTION_PATH}" = "" ]; then
BASE_COLLECTION_PATH=$(pwd)
fi

# Make a global variable for namespace
INSTALL_NAMESPACE=openshift-storage

Expand Down
5 changes: 3 additions & 2 deletions must-gather/collection-scripts/pre-install.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/bin/bash

# Expect base collection path as an argument
# Expect base collection path as an exported variable
# If it is not defined, use PWD instead
# shellcheck disable=SC2034
BASE_COLLECTION_PATH="${1}"
BASE_COLLECTION_PATH=${BASE_COLLECTION_PATH:-"$(pwd)"}

ns=$(oc get deploy --all-namespaces -o go-template --template='{{range .items}}{{if .metadata.labels}}{{printf "%s %v" .metadata.namespace (index .metadata.labels "olm.owner")}} {{printf "\n"}}{{end}}{{end}}' | grep ocs-operator | awk '{print $1}' | uniq)

Expand Down

0 comments on commit caea8d8

Please sign in to comment.