mirror of
https://github.com/dredx/prole.git
synced 2026-09-24 14:44:32 +00:00
- Introduced `repair_pipeline_cli.py` to implement the repair pipeline in Python, enhancing maintainability and flexibility. - Added `_repair_stale_released_pvs` method to handle reconciliation of stale Persistent Volumes and Persistent Volume Claims. - Replaced complex bash-implemented repair logic in `repair_pipeline.sh` with a simplified wrapper that calls the Python script. - Added unit tests for key repair methods, including `_match_stale_released_pv` and `_clear_pv_claim_ref`. - Ensured support for namespace-scoped PVC repair logic and improved error handling during repair actions. - Updated subprocess calls to handle interactions with `kubectl` within the pipeline's Python implementation. This change simplifies cluster repair flows and improves future extensibility.
84 lines
1.6 KiB
Bash
Executable File
84 lines
1.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
# mock_val/repair_pipeline.sh
|
|
# Purpose:
|
|
# - Validation wrapper around the Python-native cluster repair logic.
|
|
|
|
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|
ROOT_DIR=$(cd "$SCRIPT_DIR/.." && pwd)
|
|
|
|
SERVICE_NAMESPACE=""
|
|
DB_NAMESPACE=""
|
|
MODE=""
|
|
CFG_PATH=""
|
|
|
|
usage() {
|
|
cat <<'USAGE'
|
|
Usage: repair_pipeline.sh [-n|--namespace NS] [--db-namespace NS] [-m|--mode MODE] [--config PATH] [repair]
|
|
USAGE
|
|
}
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
case "$1" in
|
|
-m|--mode)
|
|
shift
|
|
MODE="${1:-}"
|
|
;;
|
|
-m=*|--mode=*)
|
|
MODE="${1#*=}"
|
|
;;
|
|
-n|--namespace)
|
|
shift
|
|
SERVICE_NAMESPACE="${1:-}"
|
|
;;
|
|
-n=*|--namespace=*)
|
|
SERVICE_NAMESPACE="${1#*=}"
|
|
;;
|
|
--db-namespace)
|
|
shift
|
|
DB_NAMESPACE="${1:-}"
|
|
;;
|
|
--db-namespace=*)
|
|
DB_NAMESPACE="${1#*=}"
|
|
;;
|
|
--config)
|
|
shift
|
|
CFG_PATH="${1:-}"
|
|
;;
|
|
--config=*)
|
|
CFG_PATH="${1#*=}"
|
|
;;
|
|
repair)
|
|
;;
|
|
-h|--help)
|
|
usage
|
|
exit 0
|
|
;;
|
|
*)
|
|
usage
|
|
exit 2
|
|
;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
export PROLE_HOME="${PROLE_HOME:-$ROOT_DIR}"
|
|
export PROLE_CONF="${PROLE_CONF:-${CFG_PATH:-$PROLE_HOME/conf}}"
|
|
export PYTHONPATH="$ROOT_DIR${PYTHONPATH:+:$PYTHONPATH}"
|
|
|
|
args=()
|
|
if [[ -n "$SERVICE_NAMESPACE" ]]; then
|
|
args+=("--namespace" "$SERVICE_NAMESPACE")
|
|
fi
|
|
if [[ -n "$DB_NAMESPACE" ]]; then
|
|
args+=("--db-namespace" "$DB_NAMESPACE")
|
|
fi
|
|
if [[ -n "$MODE" ]]; then
|
|
args+=("--mode" "$MODE")
|
|
fi
|
|
args+=("--config" "$PROLE_CONF")
|
|
|
|
exec python3 -m installer.core.repair_pipeline_cli "${args[@]}"
|