15
15
# limitations under the License.
16
16
import copy
17
17
import os
18
- import time
19
18
from typing import Any , List
20
19
21
20
import yaml
@@ -71,12 +70,11 @@ def main(ctx: hook.Context):
71
70
# so we might have LvmVolumeGroup list or LVMVolumeGroup list
72
71
if len (lvg_list .get ('items' , [])) == 0 :
73
72
try :
74
- # ctx.kubernetes.delete(kind='CustomResourceDefinition',
75
- # apiVersion='apiextensions.k8s.io/v1',
76
- # name='LvmVolumeGroup',
77
- # namespace='')
73
+ ctx .kubernetes .delete (kind = 'CustomResourceDefinition' ,
74
+ apiVersion = 'apiextensions.k8s.io/v1' ,
75
+ name = 'LvmVolumeGroup' ,
76
+ namespace = '' )
78
77
79
- api_extenstion .delete_custom_resource_definition ('lvmvolumegroups.storage.deckhouse.io' )
80
78
print (f"{ migrate_script } successfully delete the LvmVolumeGroup CRD" )
81
79
# that means we deleted old kind (LvmVolumeGroup)
82
80
create_new_lvg_crd (ctx )
@@ -90,8 +88,7 @@ def main(ctx: hook.Context):
90
88
version = version )
91
89
for backup in lvg_backup_list .get ('items' , []):
92
90
if backup ['metadata' ]['labels' ][migration_completed_label ] == 'true' :
93
- print (
94
- f"{ migrate_script } the LvmVolumeGroup { backup ['metadata' ]['name' ]} was already migrated" )
91
+ print (f"{ migrate_script } the LvmVolumeGroup { backup ['metadata' ]['name' ]} was already migrated" )
95
92
continue
96
93
97
94
lvg = configure_new_lvg (backup )
@@ -316,8 +313,12 @@ def configure_new_lvg(backup):
316
313
317
314
def turn_on_daemonset (api_v1 , name , namespace , daemonset ):
318
315
del daemonset ['spec' ]['template' ]['spec' ]['nodeSelector' ]['exclude' ]
319
- print (f"{ migrate_script } successfully migrated LvmVolumeGroup kind to LVMVolumeGroup" )
320
- api_v1 .patch_namespaced_daemon_set (name = name , namespace = namespace , body = daemonset )
316
+ try :
317
+ api_v1 .patch_namespaced_daemon_set (name = name , namespace = namespace , body = daemonset )
318
+ print (f"{ migrate_script } successfully migrated LvmVolumeGroup kind to LVMVolumeGroup" )
319
+ except Exception as e :
320
+ print (f"{ migrate_script } an ERROR occurred while turning on the daemonset, err: { e } " )
321
+
321
322
322
323
323
324
def find_crds_root (hookpath ):
0 commit comments