|
| 1 | +import os |
1 | 2 | import sys |
2 | 3 | import argparse |
3 | 4 | import signal |
4 | 5 | import yaml |
5 | 6 |
|
| 7 | +from src.kubernetes.base import KubernetesBase |
6 | 8 | from src.kubernetes.job_volume import VolumeBackupJob |
7 | 9 | from src.kubernetes.job_postgresql import PostgresBackupJob |
8 | 10 | import src.utils.psql as psql |
@@ -117,7 +119,7 @@ def run_backup_job(cluster_context: str, namespace: str): |
117 | 119 | # STRICT BACKUP-MAP CHECK |
118 | 120 | # -------------------------------------------------- |
119 | 121 | ns_claims_entries = [] |
120 | | - backup_map_config = backup_map.get_backup_map(kube, master_ns=master_ns) |
| 122 | + backup_map_config = backup_map.get_backup_map_content(kube, master_ns=master_ns) |
121 | 123 |
|
122 | 124 | if isinstance(backup_map_config, dict) and "namespaces" in backup_map_config: |
123 | 125 | for ns_entry in backup_map_config.get("namespaces", []): |
@@ -351,23 +353,29 @@ def main(): |
351 | 353 | # ---------------------------------- |
352 | 354 | # Reject if kube context if missing |
353 | 355 | try: |
354 | | - kube = VolumeBackupJob(context=cluster_context, namespace="default") |
| 356 | + cluster_context = os.environ["CLUSTER_CONTEXT"] |
| 357 | + target_namespaces = os.environ["TARGET_NAMESPACES"] |
| 358 | + |
| 359 | + kube = KubernetesBase(context=cluster_context, namespace=namespace) |
355 | 360 | kube_client_sigkill = kube |
356 | 361 | except Exception as e: |
357 | 362 | print(f"error: {e}") |
358 | 363 | sys.exit(1) |
359 | 364 |
|
360 | | - master_ns = config_secret.get_config_secret_namespace(kube) |
361 | | - kube.namespace = master_ns |
| 365 | + # master_ns = config_secret.get_config_secret_namespace(kube) |
| 366 | + # kube.namespace = master_ns |
362 | 367 |
|
363 | | - # Verify ConfigMap existence before processing |
364 | | - saved_map = backup_map.get_backup_map(kube, master_ns=master_ns) |
365 | | - if not saved_map or not saved_map.get("namespaces"): |
366 | | - print(f"error: ConfigMap 'bkup-backup-map' is missing or empty in namespace '{master_ns}'.") |
367 | | - print("hint: Generate and apply one first using 'bkup -bm -a'") |
368 | | - sys.exit(1) |
| 368 | + # backup_map_name = backup_map.get_backup_map_name |
| 369 | + # backup_map_ns = master_ns |
| 370 | + |
| 371 | + # # Verify ConfigMap existence before processing |
| 372 | + # saved_map = backup_map.get_backup_map_content(kube, namespace=backup_map_ns) |
| 373 | + # if not saved_map or not saved_map.get("namespaces"): |
| 374 | + # print(f"error: ConfigMap '{backup_map_name}' is missing or empty in namespace '{backup_map_ns}'.") |
| 375 | + # print("hint: Generate and apply one first using 'bkup -bm -a'") |
| 376 | + # sys.exit(1) |
369 | 377 |
|
370 | | - print(f"{yaml.dump(saved_map, sort_keys=False, default_flow_style=False)}\n") |
| 378 | + # print(f"{yaml.dump(saved_map, sort_keys=False, default_flow_style=False)}\n") |
371 | 379 |
|
372 | 380 | # If a single namespace is targeted via -n, execute only this one |
373 | 381 | if namespace_input: |
|
0 commit comments