]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
k8s: Fix problem when it restores a 'namespace'
authorfrancisco.garcia <francisco.garcia@baculasystems.com>
Wed, 13 Dec 2023 21:54:23 +0000 (22:54 +0100)
committerEric Bollengier <eric@baculasystems.com>
Tue, 13 Feb 2024 09:36:03 +0000 (10:36 +0100)
bacula/src/plugins/fd/kubernetes-backend/baculak8s/plugins/k8sbackend/namespaces.py

index c7787b763516e296a55966d5e0f5f70565d706e9..3fc356cd595f7b40d0becc20353fe1086ee0bf60 100644 (file)
@@ -81,8 +81,10 @@ def namespaces_list_all_names(corev1api):
 def namespaces_restore(corev1api, file_info, file_content):
     ns = encoder_load(file_content, file_info.name)
     metadata = prepare_metadata(ns.metadata)
+    projectid = None
     # Populate annotations about projectId
-    projectid = ns.metadata.annotations.get('field.cattle.io/projectId', None)
+    if ns.metadata.annotations is not None:
+        projectid = ns.metadata.annotations.get('field.cattle.io/projectId', None)
     if projectid is not None:
         ann = {'field.cattle.io/projectId': projectid}
         if metadata.annotations is not None: