Skip to content

Fix raid config#2263

Open
janhorstmann wants to merge 2 commits intomainfrom
fix_raid_config
Open

Fix raid config#2263
janhorstmann wants to merge 2 commits intomainfrom
fix_raid_config

Conversation

@janhorstmann
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • Consider avoiding in-place mutation of node_attributes when popping target_raid_config (e.g. work on a shallow copy) so that callers or subsequent logic that may rely on the full attributes dict are not surprised by missing keys.
  • When creating the stub node, the direct access to node_attributes["driver"] will raise a KeyError if the driver is not present; if this is a realistic scenario, guard this lookup or raise a clearer error to aid debugging.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider avoiding in-place mutation of `node_attributes` when popping `target_raid_config` (e.g. work on a shallow copy) so that callers or subsequent logic that may rely on the full attributes dict are not surprised by missing keys.
- When creating the stub node, the direct access to `node_attributes["driver"]` will raise a `KeyError` if the driver is not present; if this is a realistic scenario, guard this lookup or raise a clearer error to aid debugging.

## Individual Comments

### Comment 1
<location path="osism/tasks/conductor/ironic.py" line_range="368-369" />
<code_context>
+        # transitioned fast from managable to available later. It is also safer
+        # to not clean during sync, so that nodes may later be adopted with
+        # their provisioned data.
+        node = openstack.baremetal_node_create(
+            device.name, dict(automated_clean=False, driver=node_attributes["driver"])
+        )
+
</code_context>
<issue_to_address>
**issue:** Guard against missing `driver` in `node_attributes` when creating the stub node

This indexing will raise a `KeyError` if `driver` is ever omitted from `node_attributes`, which would abort the sync. Please either use `node_attributes.get("driver")` with a clear error, or validate/assert the presence of `driver` earlier so failures are explicit and easier to debug.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread osism/tasks/conductor/ironic.py Outdated
@berendt berendt moved this from Backlog to In review in Human Board May 5, 2026
The `target_raid_config` was popped from `node_attributes` before create
and therefore was not available for comparision during node updates.
Instead of also duplicating this code, the node creation was refactored
to just create a stub node with the device name if it does not exist and
unconditionally run the node update procedure afterwards.
This way all `target_raid_config` releated code is situated in the
update path and does not need to be duplicated.

Signed-off-by: Jan Horstmann <horstmann@osism.tech>
The erase_devices_metadata deploy step is required when creating
software RAID on prepartitioned devices.

Signed-off-by: Jan Horstmann <horstmann@osism.tech>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

3 participants