refactor: make NFS backup script testable with minimal config vars, add test harness + Gitea workflow, address review nits
Some checks failed
Test automated-nfs-backup / test-automated-nfs-backup (push) Successful in 28s
Check scripts syntax / check-scripts-syntax (push) Successful in 1m2s
Haven Notify Build and Deploy / Build Haven Notify Image (push) Successful in 2m5s
Haven Notify Build and Deploy / Deploy Haven Notify (internal) (push) Failing after 23s
Some checks failed
Test automated-nfs-backup / test-automated-nfs-backup (push) Successful in 28s
Check scripts syntax / check-scripts-syntax (push) Successful in 1m2s
Haven Notify Build and Deploy / Build Haven Notify Image (push) Successful in 2m5s
Haven Notify Build and Deploy / Deploy Haven Notify (internal) (push) Failing after 23s
This commit is contained in:
@@ -25,9 +25,11 @@ SEVENZ_METHOD="${SEVENZ_METHOD:-lzma2}"
|
||||
SEVENZ_LEVEL="${SEVENZ_LEVEL:-9}"
|
||||
SEVENZ_HEADER_ENCRYPT="${SEVENZ_HEADER_ENCRYPT:-on}"
|
||||
SEVENZ_THREADS="${SEVENZ_THREADS:-on}"
|
||||
SEVENZ_BIN="${SEVENZ_BIN:-7z}"
|
||||
SCALE_TIMEOUT_SECONDS="${SCALE_TIMEOUT_SECONDS:-600}"
|
||||
SCALE_RETRY_COUNT="${SCALE_RETRY_COUNT:-3}"
|
||||
SCALE_RETRY_DELAY_SECONDS="${SCALE_RETRY_DELAY_SECONDS:-5}"
|
||||
SCALE_WAIT_SECONDS="${SCALE_WAIT_SECONDS:-30}"
|
||||
TMP_STATE_DIR="${TMP_STATE_DIR:-/tmp/k8s-nfs-backup}"
|
||||
NOTIFY_SUCCESS_URL="${NOTIFY_SUCCESS_URL:-}"
|
||||
NOTIFY_FAILURE_URL="${NOTIFY_FAILURE_URL:-}"
|
||||
@@ -75,7 +77,7 @@ parse_workload_kinds() {
|
||||
|
||||
validate_inputs() {
|
||||
require_cmd "$KUBECTL_BIN"
|
||||
require_cmd "7z"
|
||||
require_cmd "$SEVENZ_BIN"
|
||||
if [[ -n "$NOTIFY_SUCCESS_URL" || -n "$NOTIFY_FAILURE_URL" ]]; then
|
||||
require_cmd "curl"
|
||||
fi
|
||||
@@ -323,7 +325,7 @@ backup_folder() {
|
||||
local folder_path="${1:?folder path required}"
|
||||
local archive_path="${2:?archive path required}"
|
||||
local -a cmd=(
|
||||
7z a -t7z
|
||||
"$SEVENZ_BIN" a -t7z
|
||||
"$archive_path"
|
||||
"$folder_path"
|
||||
"-m0=${SEVENZ_METHOD}"
|
||||
@@ -405,8 +407,8 @@ process_folder() {
|
||||
capture_replicas_state "$namespace" "$state_file"
|
||||
scale_namespace_to_zero "$namespace" "$state_file"
|
||||
|
||||
log_info "Waiting 30 seconds for namespace '${namespace}' to scale down..."
|
||||
sleep 30
|
||||
log_info "Waiting ${SCALE_WAIT_SECONDS} seconds for namespace '${namespace}' to scale down..."
|
||||
sleep "$SCALE_WAIT_SECONDS"
|
||||
else
|
||||
unmapped_folders=$((unmapped_folders + 1))
|
||||
log_warn "No namespace matched folder '${folder_name}'. Running backup only."
|
||||
@@ -422,8 +424,8 @@ process_folder() {
|
||||
|
||||
if [[ "$has_mapping" -eq 1 ]]; then
|
||||
restore_namespace_replicas "$namespace" "$state_file"
|
||||
log_info "Waiting 30 seconds for namespace '${namespace}' to restore replicas..."
|
||||
sleep 30
|
||||
log_info "Waiting ${SCALE_WAIT_SECONDS} seconds for namespace '${namespace}' to restore replicas..."
|
||||
sleep "$SCALE_WAIT_SECONDS"
|
||||
rm -f "$state_file"
|
||||
fi
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user