55import random
66import string
77
8- import kopf
9- import yaml
10-
118import easykube
129import httpx
10+ import kopf
11+ import yaml
1312
1413from . import openstack
1514
@@ -47,9 +46,7 @@ async def on_startup(**kwargs):
4746
4847@kopf .on .cleanup ()
4948async def on_cleanup (** kwargs ):
50- """
51- Runs on operator shutdown.
52- """
49+ """Runs on operator shutdown."""
5350 # Make sure that the easykube client is shut down properly
5451 await ekclient .aclose ()
5552
@@ -105,7 +102,6 @@ async def secgroups_for_cluster(resource, cluster):
105102
106103async def filtered_volumes_for_cluster (resource , cluster ):
107104 """Async iterator for volumes belonging to the specified cluster."""
108-
109105 async for vol in resource .list ():
110106 # CSI Cinder sets metadata on the volumes that we can look for
111107 owner = vol .metadata .get ("cinder.csi.openstack.org/cluster" )
@@ -162,7 +158,6 @@ async def purge_openstack_resources(
162158 logger , clouds , cloud_name , cacert , name , include_volumes , include_appcred
163159):
164160 """Cleans up the OpenStack resources created by the OCCM and CSI for a cluster."""
165-
166161 # Use the credential to delete external resources as required
167162 async with openstack .Cloud .from_clouds (clouds , cloud_name , cacert ) as cloud :
168163 if not cloud .is_authenticated :
@@ -360,7 +355,6 @@ async def _on_openstackcluster_event_impl(
360355 name , namespace , meta , labels , spec , logger , ** kwargs
361356):
362357 """Executes whenever an event occurs for an OpenStack cluster."""
363-
364358 # Get the resource for manipulating OpenStackClusters at the preferred version
365359 openstackclusters = await _get_os_cluster_client ()
366360
@@ -375,7 +369,10 @@ async def _on_openstackcluster_event_impl(
375369 if not meta .get ("deletionTimestamp" ):
376370 if FINALIZER not in finalizers :
377371 await patch_finalizers (
378- openstackclusters , name , namespace , finalizers + [FINALIZER ]
372+ openstackclusters ,
373+ name ,
374+ namespace ,
375+ [* finalizers , FINALIZER ],
379376 )
380377 logger .info ("added janitor finalizer to cluster" )
381378 return
0 commit comments