From efa462c5538809bd9aee7b0050e1d38d5965d673 Mon Sep 17 00:00:00 2001 From: Vimal Kumar Date: Mon, 29 Jan 2024 18:49:11 +0530 Subject: [PATCH] POWERMON-199: fix gather power-monitoring-operator info Signed-off-by: Vimal Kumar --- must-gather/gather | 20 +++- must-gather/gather-olm-info | 16 ++- .../gather-power-monitoring-operator-info | 98 +++++++++++++++++++ 3 files changed, 128 insertions(+), 6 deletions(-) create mode 100755 must-gather/gather-power-monitoring-operator-info diff --git a/must-gather/gather b/must-gather/gather index 54fcaaa3..73087f67 100755 --- a/must-gather/gather +++ b/must-gather/gather @@ -74,11 +74,27 @@ gather_olm_info() { "$SCRIPT_DIR"/gather-olm-info "$BASE_COLLECTION_PATH" } +gather_operator_info() { + KEPLER_OPERATOR_NS=$(oc get ns kepler-operator -oname || true) + POWER_MONITORING_OPERATOR_NS=$(oc get ns openshift-power-monitoring -oname || true) + if [ -n "${KEPLER_OPERATOR_NS}" ]; then + gather_kepler_operator_info + fi + if [ -n "${POWER_MONITORING_OPERATOR_NS}" ]; then + gather_power_monitoring_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" @@ -105,6 +121,8 @@ 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 @@ -112,8 +130,6 @@ main() { 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" diff --git a/must-gather/gather-olm-info b/must-gather/gather-olm-info index 6c465766..3a15081d 100755 --- a/must-gather/gather-olm-info +++ b/must-gather/gather-olm-info @@ -22,17 +22,25 @@ 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" + KEPLER_OPERATOR_NS=$(oc get ns kepler-operator -oname || true) + POWER_MONITORING_OPERATOR_NS=$(oc get ns openshift-power-monitoring -oname || true) + if [ -n "${KEPLER_OPERATOR_NS}" ]; then + 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 + if [ -n "${POWER_MONITORING_OPERATOR_NS}" ]; 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" + 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() { diff --git a/must-gather/gather-power-monitoring-operator-info b/must-gather/gather-power-monitoring-operator-info new file mode 100755 index 00000000..3e2a6a71 --- /dev/null +++ b/must-gather/gather-power-monitoring-operator-info @@ -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 "$@"