Skip to content

Commit

Permalink
Merge pull request #16 from Akrog/cinder
Browse files Browse the repository at this point in the history
Gather cinder information, including Guru Meditation Report.
  • Loading branch information
fmount authored Nov 6, 2023
2 parents 90e866a + 1df7586 commit b53251e
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 0 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,26 @@ sh-5.1# gather
sh-5.1# rm /tmp/rm-to-finish-gathering
```
### Component specifics
Besides the generic OpenShift etcd objects that must-gather scripts are
currently gathering there's also component specific code that gather other
information, so when adding or improving a component we should look into:
- `collection-scripts/common.sh`: Services are in the `OSP_SERVICES` variable
to indicate that the script must gather its config maps, secrets, additional
information, trigger Guru Mediation Reports, etc.
- `collection-scripts/gather_services_status`: Runs OpenStack commands to
gather additional information. For example for Cinder it gather state of the
services, volume types, qos specs, volume transfer requests, summary of
existing volumes, pool information, etc.
- `collection-scripts/gather_trigger_gmr`: Triggers Guru Meditation Reports on
the services so they are present in the logs when those are gathered
afterwards.
## Example
(optional) Build and push the must-gather image to a registry:
Expand Down
3 changes: 3 additions & 0 deletions collection-scripts/gather_run
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ source "${DIR_NAME}/common.sh"
# if exist so we can gather resources about tests
expand_ns "kuttl"

# Trigger Guru Meditation Reports so we then have then in the service logs
/usr/bin/gather_trigger_gmr

for NS in "${DEFAULT_NAMESPACES[@]}"; do
# get Services Config (CM)
/usr/bin/gather_services_cm "$NS"
Expand Down
16 changes: 16 additions & 0 deletions collection-scripts/gather_services_status
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ get_status() {
"neutron")
get_neutron_status
;;
"cinder")
get_cinder_status
;;
*) ;;
esac
}
Expand Down Expand Up @@ -58,6 +61,19 @@ get_neutron_status() {
${BASH_ALIASES[os]} security group list > "$NEUTRON_PATH"/security_group_list
}

# Cinder service gathering - services, vol types, qos, transfers, pools,
get_cinder_status() {
local CINDER_PATH="$BASE_COLLECTION_PATH/ctlplane/cinder"
mkdir -p "$CINDER_PATH"
${BASH_ALIASES[os]} volume service list > "$CINDER_PATH"/service_list
${BASH_ALIASES[os]} volume type list --long > "$CINDER_PATH"/type_list
${BASH_ALIASES[os]} volume qos list > "$CINDER_PATH"/qos_list
${BASH_ALIASES[os]} volume transfer request list --all-project > "$CINDER_PATH"/transfer_list
${BASH_ALIASES[os]} --os-volume-api-version 3.12 volume summary --all-projects > "$CINDER_PATH"/total_volumes_list
# Add --fit once we have https://review.opendev.org/c/openstack/python-openstackclient/+/895971
${BASH_ALIASES[os]} volume backend pool list --long > "$CINDER_PATH"/pool_list
}

# first we gather generic status of the openstack ctlplane
# then we process the existing services (if an associated
# function has been defined)
Expand Down
54 changes: 54 additions & 0 deletions collection-scripts/gather_trigger_gmr
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash
#
# Trigger Guru Meditation Reports in the different services to have them in the
# logs: https://github.com/openstack/oslo.reports
#
# Some services use signals and others use touching a file to trigger the
# reporting.

DIR_NAME=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
# shellcheck disable=SC1091
source "${DIR_NAME}/common.sh"

oc="/usr/bin/oc -n openstack "
oce="$oc exec "


trigger_gmr() {
service="$1"
case "${service}" in
"cinder")
cinder_trigger_gmr
;;
*) ;;
esac

}


cinder_trigger_gmr() {
# https://docs.openstack.org/cinder/latest/contributor/gmr.html
echo "Trigger GMR for Cinder services"

# Get pod name and type of service for cinder pods
svcs=`$oc get pod -l service=cinder -o=custom-columns=N:.metadata.name,T:metadata.labels.component --no-headers`

# Cinder uses files to trigger GMR because volume and backup share the PID
# with the host so we don't know what PID the service has
while read -r line; do
podname="${line% *}"
svctype="${line#* }"
$oce $podname -c $svctype -- touch /etc/cinder
done <<< "$svcs"
}


# get the list of existing ctlplane services (once) and
# filter the whole list processing only services with an
# associated function
services=`$oce openstackclient -- openstack service list -c Name -f value`
for svc in "${OSP_SERVICES[@]}"; do
[[ "${services[*]}" =~ ${svc} ]] && trigger_gmr "$svc"
done

exit 0

0 comments on commit b53251e

Please sign in to comment.