Skip to content

Fix raid config#2263

Merged
jklare merged 2 commits intomainfrom
fix_raid_config
May 8, 2026
Merged

Fix raid config#2263
jklare merged 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>
@janhorstmann
Copy link
Copy Markdown
Contributor Author

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.

We do need to pop target_raid_config, because it cannot be updated as a node attribute, but is part of it.

  • 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.

Fixed

@jklare
Copy link
Copy Markdown
Contributor

jklare commented May 7, 2026

LGTM. Was this tested anywhere?

@janhorstmann
Copy link
Copy Markdown
Contributor Author

LGTM. Was this tested anywhere?

tested manually in the baremetal testbed

@berendt berendt requested a review from ideaship May 8, 2026 07:08
@jklare jklare merged commit e334756 into main May 8, 2026
3 checks passed
@jklare jklare deleted the fix_raid_config branch May 8, 2026 07:47
@github-project-automation github-project-automation Bot moved this from In review to Done in Human Board May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants