Skip to content

Commit a9a48bf

Browse files
authored
Enable automatic node cleaning (#2019)
The goal is to automatically clean nodes on undeployment. This can be done by ironic through automated cleaning. Unfortunately this will also enable cleaning when a node transitions from `managable` to `available`. This would block `osism sync ironic`, since it waits sequentially for every node to reach the `available` state. An alternative is to add an explicit clean step in python-osism. However the `osism manage baremetal undeploy` command is currently a oneshot request to ironic. Adding a cleaning step would require turning it inot an asynchronous task. The taken path is to enable automated cleaning explicitly on a per node basis once it reaches the `available` state. Care has to be taken to unset it before transitioning to `available`, since ironic sometimes moves nodes to `manageable` when errors are encountered. Depends-On: osism/metalbox#292 Signed-off-by: Jan Horstmann <horstmann@osism.tech>
1 parent c84cd54 commit a9a48bf

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

osism/tasks/conductor/ironic.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,11 @@ def sync_ironic(request_id, get_ironic_parameters, node_name=None, force=False):
263263
osism_utils.push_task_output(
264264
request_id, f"Creating baremetal node for {device.name}\n"
265265
)
266+
# NOTE: Create node without automated_clean, so it can be
267+
# transitioned fast from managable to available later. It
268+
# is also safer to not clean during sync, so that nodes may
269+
# later be adopted with their provisioned data.
270+
node_attributes.update(dict(automated_clean=False))
266271
node = openstack.baremetal_node_create(device.name, node_attributes)
267272
else:
268273
# NOTE: Check whether the baremetal node needs to be updated
@@ -345,6 +350,11 @@ def sync_ironic(request_id, get_ironic_parameters, node_name=None, force=False):
345350
request_id,
346351
f"Transitioning baremetal node to available state for {device.name}\n",
347352
)
353+
if node["automated_clean"]:
354+
# NOTE: Skip automated cleaning on transition from managable to available. We are waiting for the transition and do not want to wait on cleaning at this point
355+
node = openstack.baremetal_node_update(
356+
node["uuid"], dict(automated_clean=False)
357+
)
348358
node = openstack.baremetal_node_set_provision_state(
349359
node["uuid"], "provide"
350360
)
@@ -353,6 +363,11 @@ def sync_ironic(request_id, get_ironic_parameters, node_name=None, force=False):
353363
node["uuid"], "available"
354364
)
355365
)
366+
if not node["automated_clean"]:
367+
# NOTE: Activate automated cleaning, so that future actions will trigger it
368+
node = openstack.baremetal_node_update(
369+
node["uuid"], dict(automated_clean=True)
370+
)
356371
osism_utils.push_task_output(
357372
request_id,
358373
f"Baremetal node for {device.name} is available\n",
@@ -380,6 +395,11 @@ def sync_ironic(request_id, get_ironic_parameters, node_name=None, force=False):
380395
request_id,
381396
f"Baremetal node for {device.name} is manageable\n",
382397
)
398+
if node["automated_clean"]:
399+
# NOTE: Skip automated cleaning, we do not want to accidentaly clean at this point
400+
node = openstack.baremetal_node_update(
401+
node["uuid"], dict(automated_clean=False)
402+
)
383403
else:
384404
osism_utils.push_task_output(
385405
request_id,

0 commit comments

Comments
 (0)