diff --git a/hooks/convert_bd_names_to_selector.py b/hooks/convert_bd_names_to_selector.py index f96a0176..37a00916 100755 --- a/hooks/convert_bd_names_to_selector.py +++ b/hooks/convert_bd_names_to_selector.py @@ -248,18 +248,18 @@ def main(ctx: hook.Context): print(f"{migrate_script} starts to create backups and add 'kubernetes.io/hostname' to store the node name") for lvg in lvg_list.get('items', []): lvg_backup = {'apiVersion': lvg['apiVersion'], - 'kind': 'LvmVolumeGroupBackup', - 'metadata': { - 'name': - lvg['metadata'][ - 'name'], - 'labels': {}, - 'finalizers': - lvg['metadata'][ - 'finalizers']}, - 'spec': lvg['spec']} + 'kind': 'LvmVolumeGroupBackup', + 'metadata': { + 'name': + lvg['metadata'][ + 'name'], + 'labels': {}, + 'finalizers': lvg['metadata'].get('finalizers', [])}, + 'spec': lvg['spec']} if 'labels' in lvg['metadata']: lvg_backup['metadata']['labels'] = lvg['metadata']['labels'] + if default_finalizer not in lvg_backup['metadata']['finalizers']: + lvg_backup['metadata']['finalizers'].append('storage.deckhouse.io/sds-node-configurator') lvg_backup['metadata']['labels']['kubernetes.io/hostname'] = lvg['status']['nodes'][0]['name'] lvg_backup['metadata']['labels'][migration_completed_label] = 'false'