fixing counter
All checks were successful
Check scripts syntax / check-scripts-syntax (push) Successful in 50s

This commit is contained in:
2026-05-26 15:50:10 -03:00
parent 4870ede3ad
commit 2de4ca75a1

View File

@@ -122,7 +122,7 @@ capture_replicas_state() {
for kind in "${WORKLOAD_KIND_LIST[@]}"; do
if ! output="$(_kubectl -n "$namespace" get "$kind" -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.replicas}{"\n"}{end}' 2>/dev/null)"; then
log_warn "Failed to list kind '${kind}' in namespace '${namespace}' while capturing state"
((scale_warnings++))
scale_warnings=$((scale_warnings + 1))
continue
fi
@@ -131,7 +131,7 @@ capture_replicas_state() {
if [[ -z "$replicas" ]]; then
replicas="1"
log_warn "Resource ${kind}/${name} had no explicit replicas; defaulting saved value to 1"
((scale_warnings++))
scale_warnings=$((scale_warnings + 1))
fi
printf '%s\t%s\t%s\n' "$kind" "$name" "$replicas" >> "$state_file"
done <<< "$output"
@@ -160,7 +160,7 @@ scale_namespace_to_zero() {
log_info "Scaled down ${namespace}:${kind}/${name} to 0"
else
log_warn "Failed to scale down ${namespace}:${kind}/${name}; continuing with backup by policy"
((scale_warnings++))
scale_warnings=$((scale_warnings + 1))
fi
done < "$state_file"
}
@@ -178,7 +178,7 @@ restore_namespace_replicas() {
log_info "Restored ${namespace}:${kind}/${name} to ${replicas}"
else
log_warn "Failed to restore ${namespace}:${kind}/${name} to ${replicas}"
((restore_warnings++))
restore_warnings=$((restore_warnings + 1))
fi
done < "$state_file"
}
@@ -222,16 +222,16 @@ wait_for_scale_state() {
if [[ "$direction" == "down" ]]; then
if [[ "$spec" != "0" || "$status" != "0" ]]; then
((unresolved++))
unresolved=$((unresolved + 1))
fi
else
if [[ "$target" == "0" ]]; then
if [[ "$spec" != "0" || "$status" != "0" ]]; then
((unresolved++))
unresolved=$((unresolved + 1))
fi
else
if [[ "$spec" != "$target" || "$ready" != "$target" ]]; then
((unresolved++))
unresolved=$((unresolved + 1))
fi
fi
fi
@@ -326,12 +326,12 @@ process_folder() {
local has_mapping=0
folder_name="$(basename "$folder_path")"
((total_folders++))
total_folders=$((total_folders + 1))
log_info "Processing folder: ${folder_name}"
if namespace="$(namespace_for_folder "$folder_name")"; then
has_mapping=1
((mapped_folders++))
mapped_folders=$((mapped_folders + 1))
log_info "Exact namespace match found for folder '${folder_name}' -> namespace '${namespace}'"
state_file="$(state_file_for_folder "$folder_name")"
@@ -342,16 +342,16 @@ process_folder() {
log_info "Namespace '${namespace}' reached scale-down target"
else
log_warn "Timeout waiting for namespace '${namespace}' to fully scale down; continuing by policy"
((scale_warnings++))
scale_warnings=$((scale_warnings + 1))
fi
else
((unmapped_folders++))
unmapped_folders=$((unmapped_folders + 1))
log_warn "No namespace matched folder '${folder_name}'. Running backup only."
fi
archive_path="$(archive_path_for_folder "$folder_name")"
if backup_folder "$folder_path" "$archive_path"; then
((backup_successes++))
backup_successes=$((backup_successes + 1))
local file_size_bytes
file_size_bytes="$(wc -c < "$archive_path" | tr -d '[:space:]')"
if [[ "$file_size_bytes" =~ ^[0-9]+$ ]]; then
@@ -359,7 +359,7 @@ process_folder() {
fi
log_info "Backup created: ${archive_path}"
else
((backup_failures++))
backup_failures=$((backup_failures + 1))
log_error "Backup failed for folder '${folder_name}'"
fi
@@ -369,7 +369,7 @@ process_folder() {
log_info "Namespace '${namespace}' reached restore target"
else
log_warn "Timeout waiting for namespace '${namespace}' to fully restore replicas"
((restore_warnings++))
restore_warnings=$((restore_warnings + 1))
fi
rm -f "$state_file"
fi