Skip to content

Commit

Permalink
POWERMON-199: fix gather power-monitoring-operator info (#353)
Browse files Browse the repository at this point in the history
Signed-off-by: Vimal Kumar <vimal78@gmail.com>
  • Loading branch information
vimalk78 authored Jan 30, 2024
1 parent ad7857f commit 683b6a1
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 6 deletions.
18 changes: 16 additions & 2 deletions must-gather/gather
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,25 @@ gather_olm_info() {
"$SCRIPT_DIR"/gather-olm-info "$BASE_COLLECTION_PATH"
}

gather_operator_info() {
IS_POWER_MONITORING_OPERATOR=$(oc get csv | grep power-monitoring-operator || true)
if [ -n "${IS_POWER_MONITORING_OPERATOR}" ]; then
gather_power_monitoring_operator_info
else
gather_kepler_operator_info
fi
}

gather_kepler_operator_info() {
log "getting kepler-operator info"
"$SCRIPT_DIR"/gather-kepler-operator-info "$BASE_COLLECTION_PATH"
}

gather_power_monitoring_operator_info() {
log "getting power-monitoring-operator info"
"$SCRIPT_DIR"/gather-power-monitoring-operator-info "$BASE_COLLECTION_PATH"
}

gather_monitoring_info() {
log "getting monitoring info"
"$SCRIPT_DIR"/gather-monitoring-info "$BASE_COLLECTION_PATH"
Expand All @@ -105,15 +119,15 @@ main() {
export KUBECACHEDIR=/tmp/cache-dir

echo "powermon must-gather started..."
gather_olm_info
gather_operator_info
get_kepler_instance
get_kepler_events
get_kepler_daemon_set
get_kepler_config_map
get_kepler_sa
get_kepler_scc
gather_kepler_exporter_info
gather_olm_info
gather_kepler_operator_info
gather_monitoring_info

echo "powermon must-gather completed"
Expand Down
14 changes: 10 additions & 4 deletions must-gather/gather-olm-info
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,23 @@ source "${SCRIPT_DIR}/common"

BASE_COLLECTION_PATH=$1

KEPLER_OPERATOR_NS="openshift-operators"
KEPLER_OPERATOR_LABELS="operators.coreos.com/kepler-operator.openshift-operators"
POWER_MONITORING_OPERATOR_LABELS="operators.coreos.com/power-monitoring-operator.openshift-operators"

get_olm() {
log "collecting olm info for kepler-operator"
run oc -n "$KEPLER_OPERATOR_NS" get olm -l "${KEPLER_OPERATOR_LABELS}"= -oyaml "$OLM_INFO_DIR/olm-reources.yaml"
IS_POWER_MONITORING_OPERATOR=$(oc get csv | grep power-monitoring-operator || true)
if [ -n "${IS_POWER_MONITORING_OPERATOR}" ]; then
log "collecting olm info for power-monitoring-operator"
run oc -n openshift-operators get olm -l "${POWER_MONITORING_OPERATOR_LABELS}"= -oyaml "$OLM_INFO_DIR/olm-reources.yaml"
else
log "collecting olm info for kepler-operator"
run oc -n openshift-operators get olm -l "${KEPLER_OPERATOR_LABELS}"= -oyaml "$OLM_INFO_DIR/olm-reources.yaml"
fi
}

get_summary() {
log "collecting olm summary"
run oc -n "$KEPLER_OPERATOR_NS" get olm -owide "$OLM_INFO_DIR/summary.txt"
run oc -n openshift-operators get olm -owide "$OLM_INFO_DIR/summary.txt"
}

main() {
Expand Down
98 changes: 98 additions & 0 deletions must-gather/gather-power-monitoring-operator-info
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#!/usr/bin/env bash

# copyright 2023.
#
# licensed under the apache license, version 2.0 (the "license");
# you may not use this file except in compliance with the license.
# you may obtain a copy of the license at
#
# http://www.apache.org/licenses/license-2.0
#
# unless required by applicable law or agreed to in writing, software
# distributed under the license is distributed on an "as is" basis,
# without warranties or conditions of any kind, either express or implied.
# see the license for the specific language governing permissions and
# limitations under the license.
#

set -eu -o pipefail

SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
source "${SCRIPT_DIR}/common"

BASE_COLLECTION_PATH=$1

KEPLER_OPERATOR_NS="openshift-operators"

get_catalogsource() {
log "getting catalogsource info for kepler-operator"
run oc -n "$KEPLER_OPERATOR_NS" get catalogsource kepler-operator-catalog -oyaml "$POWER_MONITORING_OPERATOR_INFO_DIR/kepler-operator-catalogsource.yaml"
}

get_subscription() {
log "getting subscription info for power-monitoring-operator"
run oc -n "$KEPLER_OPERATOR_NS" get subscription -l operators.coreos.com/power-monitoring-operator.openshift-operators= -oyaml "$POWER_MONITORING_OPERATOR_INFO_DIR/power-monitoring-operator-subscription.yaml"
}

get_install_plan() {
log "getting installplan info for power-monitoring-operator"
run oc -n "$KEPLER_OPERATOR_NS" get installplan -l operators.coreos.com/power-monitoring-operator.openshift-operators= -oyaml "$POWER_MONITORING_OPERATOR_INFO_DIR/kepler-operator-installplan.yaml"
}

get_csv() {
log "getting CSV for power-monitoring-operator"
run oc -n "$KEPLER_OPERATOR_NS" get csv -l operators.coreos.com/power-monitoring-operator.openshift-operators= -oyaml "$POWER_MONITORING_OPERATOR_INFO_DIR/power-monitoring-operator-csv.yaml"
}

get_kepler_operator_deployment_info() {
KEPLER_OPERATOR_DEPLOY="kepler-operator-controller"
log "getting deployment info for kepler-operator"
run oc -n "$KEPLER_OPERATOR_NS" get deployment "$KEPLER_OPERATOR_DEPLOY" -oyaml "$POWER_MONITORING_OPERATOR_INFO_DIR/kepler-operator-deployment.yaml"
}

get_kepler_operator_pod_info() {
log "getting pod info for kepler-operator"
run oc -n "$KEPLER_OPERATOR_NS" get pod \
-l app.kubernetes.io/component=manager \
-l app.kubernetes.io/part-of=kepler-operator \
-oyaml "$POWER_MONITORING_OPERATOR_INFO_DIR/kepler-operator.yaml"
}

get_summary() {
run oc -n "$KEPLER_OPERATOR_NS" get catalogsource kepler-operator-catalog -owide "$POWER_MONITORING_OPERATOR_INFO_DIR/summary.txt"
echo -e "\n" >>"$POWER_MONITORING_OPERATOR_INFO_DIR/summary.txt"

run oc -n "$KEPLER_OPERATOR_NS" get subscription -owide "$POWER_MONITORING_OPERATOR_INFO_DIR/summary.txt"
echo -e "\n" >>"$POWER_MONITORING_OPERATOR_INFO_DIR/summary.txt"

run oc -n "$KEPLER_OPERATOR_NS" get installplan -owide "$POWER_MONITORING_OPERATOR_INFO_DIR/summary.txt"
echo -e "\n" >>"$POWER_MONITORING_OPERATOR_INFO_DIR/summary.txt"

run oc -n "$KEPLER_OPERATOR_NS" get csv -owide "$POWER_MONITORING_OPERATOR_INFO_DIR/summary.txt"
echo -e "\n" >>"$POWER_MONITORING_OPERATOR_INFO_DIR/summary.txt"

KEPLER_OPERATOR_DEPLOY="kepler-operator-controller"
run oc -n "$KEPLER_OPERATOR_NS" get deployment "$KEPLER_OPERATOR_DEPLOY" -owide "$POWER_MONITORING_OPERATOR_INFO_DIR/summary.txt"
echo -e "\n" >>"$POWER_MONITORING_OPERATOR_INFO_DIR/summary.txt"

run oc -n "$KEPLER_OPERATOR_NS" get pod \
-l app.kubernetes.io/component=manager \
-l app.kubernetes.io/part-of=kepler-operator \
-owide "$POWER_MONITORING_OPERATOR_INFO_DIR/summary.txt"
}

main() {

POWER_MONITORING_OPERATOR_INFO_DIR="$BASE_COLLECTION_PATH/power-monitoring-operator-info"
mkdir -p "$POWER_MONITORING_OPERATOR_INFO_DIR"

get_subscription
get_catalogsource
get_install_plan
get_csv
get_kepler_operator_deployment_info
get_kepler_operator_pod_info
get_summary
}

main "$@"

0 comments on commit 683b6a1

Please sign in to comment.