fixing counter
All checks were successful
Check scripts syntax / check-scripts-syntax (push) Successful in 50s
All checks were successful
Check scripts syntax / check-scripts-syntax (push) Successful in 50s
This commit is contained in:
@@ -122,7 +122,7 @@ capture_replicas_state() {
|
|||||||
for kind in "${WORKLOAD_KIND_LIST[@]}"; do
|
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
|
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"
|
log_warn "Failed to list kind '${kind}' in namespace '${namespace}' while capturing state"
|
||||||
((scale_warnings++))
|
scale_warnings=$((scale_warnings + 1))
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -131,7 +131,7 @@ capture_replicas_state() {
|
|||||||
if [[ -z "$replicas" ]]; then
|
if [[ -z "$replicas" ]]; then
|
||||||
replicas="1"
|
replicas="1"
|
||||||
log_warn "Resource ${kind}/${name} had no explicit replicas; defaulting saved value to 1"
|
log_warn "Resource ${kind}/${name} had no explicit replicas; defaulting saved value to 1"
|
||||||
((scale_warnings++))
|
scale_warnings=$((scale_warnings + 1))
|
||||||
fi
|
fi
|
||||||
printf '%s\t%s\t%s\n' "$kind" "$name" "$replicas" >> "$state_file"
|
printf '%s\t%s\t%s\n' "$kind" "$name" "$replicas" >> "$state_file"
|
||||||
done <<< "$output"
|
done <<< "$output"
|
||||||
@@ -160,7 +160,7 @@ scale_namespace_to_zero() {
|
|||||||
log_info "Scaled down ${namespace}:${kind}/${name} to 0"
|
log_info "Scaled down ${namespace}:${kind}/${name} to 0"
|
||||||
else
|
else
|
||||||
log_warn "Failed to scale down ${namespace}:${kind}/${name}; continuing with backup by policy"
|
log_warn "Failed to scale down ${namespace}:${kind}/${name}; continuing with backup by policy"
|
||||||
((scale_warnings++))
|
scale_warnings=$((scale_warnings + 1))
|
||||||
fi
|
fi
|
||||||
done < "$state_file"
|
done < "$state_file"
|
||||||
}
|
}
|
||||||
@@ -178,7 +178,7 @@ restore_namespace_replicas() {
|
|||||||
log_info "Restored ${namespace}:${kind}/${name} to ${replicas}"
|
log_info "Restored ${namespace}:${kind}/${name} to ${replicas}"
|
||||||
else
|
else
|
||||||
log_warn "Failed to restore ${namespace}:${kind}/${name} to ${replicas}"
|
log_warn "Failed to restore ${namespace}:${kind}/${name} to ${replicas}"
|
||||||
((restore_warnings++))
|
restore_warnings=$((restore_warnings + 1))
|
||||||
fi
|
fi
|
||||||
done < "$state_file"
|
done < "$state_file"
|
||||||
}
|
}
|
||||||
@@ -222,16 +222,16 @@ wait_for_scale_state() {
|
|||||||
|
|
||||||
if [[ "$direction" == "down" ]]; then
|
if [[ "$direction" == "down" ]]; then
|
||||||
if [[ "$spec" != "0" || "$status" != "0" ]]; then
|
if [[ "$spec" != "0" || "$status" != "0" ]]; then
|
||||||
((unresolved++))
|
unresolved=$((unresolved + 1))
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [[ "$target" == "0" ]]; then
|
if [[ "$target" == "0" ]]; then
|
||||||
if [[ "$spec" != "0" || "$status" != "0" ]]; then
|
if [[ "$spec" != "0" || "$status" != "0" ]]; then
|
||||||
((unresolved++))
|
unresolved=$((unresolved + 1))
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [[ "$spec" != "$target" || "$ready" != "$target" ]]; then
|
if [[ "$spec" != "$target" || "$ready" != "$target" ]]; then
|
||||||
((unresolved++))
|
unresolved=$((unresolved + 1))
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -326,12 +326,12 @@ process_folder() {
|
|||||||
local has_mapping=0
|
local has_mapping=0
|
||||||
|
|
||||||
folder_name="$(basename "$folder_path")"
|
folder_name="$(basename "$folder_path")"
|
||||||
((total_folders++))
|
total_folders=$((total_folders + 1))
|
||||||
log_info "Processing folder: ${folder_name}"
|
log_info "Processing folder: ${folder_name}"
|
||||||
|
|
||||||
if namespace="$(namespace_for_folder "$folder_name")"; then
|
if namespace="$(namespace_for_folder "$folder_name")"; then
|
||||||
has_mapping=1
|
has_mapping=1
|
||||||
((mapped_folders++))
|
mapped_folders=$((mapped_folders + 1))
|
||||||
log_info "Exact namespace match found for folder '${folder_name}' -> namespace '${namespace}'"
|
log_info "Exact namespace match found for folder '${folder_name}' -> namespace '${namespace}'"
|
||||||
state_file="$(state_file_for_folder "$folder_name")"
|
state_file="$(state_file_for_folder "$folder_name")"
|
||||||
|
|
||||||
@@ -342,16 +342,16 @@ process_folder() {
|
|||||||
log_info "Namespace '${namespace}' reached scale-down target"
|
log_info "Namespace '${namespace}' reached scale-down target"
|
||||||
else
|
else
|
||||||
log_warn "Timeout waiting for namespace '${namespace}' to fully scale down; continuing by policy"
|
log_warn "Timeout waiting for namespace '${namespace}' to fully scale down; continuing by policy"
|
||||||
((scale_warnings++))
|
scale_warnings=$((scale_warnings + 1))
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
((unmapped_folders++))
|
unmapped_folders=$((unmapped_folders + 1))
|
||||||
log_warn "No namespace matched folder '${folder_name}'. Running backup only."
|
log_warn "No namespace matched folder '${folder_name}'. Running backup only."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
archive_path="$(archive_path_for_folder "$folder_name")"
|
archive_path="$(archive_path_for_folder "$folder_name")"
|
||||||
if backup_folder "$folder_path" "$archive_path"; then
|
if backup_folder "$folder_path" "$archive_path"; then
|
||||||
((backup_successes++))
|
backup_successes=$((backup_successes + 1))
|
||||||
local file_size_bytes
|
local file_size_bytes
|
||||||
file_size_bytes="$(wc -c < "$archive_path" | tr -d '[:space:]')"
|
file_size_bytes="$(wc -c < "$archive_path" | tr -d '[:space:]')"
|
||||||
if [[ "$file_size_bytes" =~ ^[0-9]+$ ]]; then
|
if [[ "$file_size_bytes" =~ ^[0-9]+$ ]]; then
|
||||||
@@ -359,7 +359,7 @@ process_folder() {
|
|||||||
fi
|
fi
|
||||||
log_info "Backup created: ${archive_path}"
|
log_info "Backup created: ${archive_path}"
|
||||||
else
|
else
|
||||||
((backup_failures++))
|
backup_failures=$((backup_failures + 1))
|
||||||
log_error "Backup failed for folder '${folder_name}'"
|
log_error "Backup failed for folder '${folder_name}'"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -369,7 +369,7 @@ process_folder() {
|
|||||||
log_info "Namespace '${namespace}' reached restore target"
|
log_info "Namespace '${namespace}' reached restore target"
|
||||||
else
|
else
|
||||||
log_warn "Timeout waiting for namespace '${namespace}' to fully restore replicas"
|
log_warn "Timeout waiting for namespace '${namespace}' to fully restore replicas"
|
||||||
((restore_warnings++))
|
restore_warnings=$((restore_warnings + 1))
|
||||||
fi
|
fi
|
||||||
rm -f "$state_file"
|
rm -f "$state_file"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user