github.com/verrazzano/verrazzano@v1.7.1/ci/scripts/capture_cluster_snapshot.sh (about) 1 # Copyright (c) 2022, Oracle and/or its affiliates. 2 # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 4 captureFullCluster() { 5 mkdir -p ${FULL_CLUSTER_DIR} 6 ${CLUSTER_SNAPSHOT_SCRIPT} -d ${FULL_CLUSTER_DIR} -r ${FULL_CLUSTER_DIR}/${ANALYSIS_REPORT} 7 } 8 9 captureBugReport() { 10 # Create a bug-report and run analysis tool on the bug-report 11 # Requires environment variable KUBECONFIG or $HOME/.kube/config 12 mkdir -p ${BUG_REPORT_DIR} 13 $VZ_COMMAND bug-report --report-file ${BUG_REPORT_FILE} 14 15 # Check if the bug-report exists 16 if [ -f "${BUG_REPORT_FILE}" ]; then 17 tar -xf ${BUG_REPORT_FILE} -C ${BUG_REPORT_DIR} 18 rm ${BUG_REPORT_FILE} || true 19 20 # Run vz analyze on the extracted directory 21 $VZ_COMMAND analyze --capture-dir ${BUG_REPORT_DIR} --report-file ${BUG_REPORT_DIR}/${ANALYSIS_REPORT} --report-format detailed 22 fi 23 } 24 25 if [ -z "$VZ_COMMAND" ]; then 26 echo "This script requires an environment variable VZ_COMMAND to indicate the Verrazzano command-line executable" 27 exit 1 28 fi 29 30 if [ -z $1 ]; then 31 echo "Directory to place the cluster resources is required" 32 exit 1 33 fi 34 35 CLUSTER_SNAPSHOT_ROOT=$1 36 37 SCRIPT_DIR=$(cd $(dirname "$0"); pwd -P) 38 CLUSTER_SNAPSHOT_SCRIPT=${SCRIPT_DIR}/../../tools/scripts/k8s-dump-cluster.sh 39 40 ANALYSIS_REPORT="analysis.report" 41 BUG_REPORT="bug-report.tar.gz" 42 43 if [ ! -f "${CLUSTER_SNAPSHOT_SCRIPT}" ]; then 44 echo "The script to capture the cluster resources ${CLUSTER_SNAPSHOT_SCRIPT} doesn't exist" 45 exit 1 46 fi 47 48 FULL_CLUSTER_DIR=${CLUSTER_SNAPSHOT_ROOT}/full-cluster 49 BUG_REPORT_DIR=${CLUSTER_SNAPSHOT_ROOT}/bug-report 50 BUG_REPORT_FILE="${BUG_REPORT_DIR}/${BUG_REPORT}" 51 52 captureFullCluster 53 captureBugReport