Skip to content

Centralize and harmonize condition/reason constants across controllers#795

Open
afritzler wants to merge 2 commits intomainfrom
enh/conditions
Open

Centralize and harmonize condition/reason constants across controllers#795
afritzler wants to merge 2 commits intomainfrom
enh/conditions

Conversation

@afritzler
Copy link
Copy Markdown
Member

@afritzler afritzler commented Apr 9, 2026

Proposed Changes

Condition and reason constants were scattered across controller files with inconsistent naming conventions (mixed prefixes, unexported names, BIOS/BMC-specific names for generic concepts) and true duplicates using identical string values. This made it hard to discover existing constants and led to accidental duplication when adding new controllers.

Consolidate shared condition and reason constants into a central conditions.go file and normalize naming to a consistent Condition/Reason pattern. Generalize BIOS/BMC-specific names and string values where the concepts are generic (e.g., ConditionBMCResetIssued → ConditionResetIssued,
"BIOSSettingsTimedOut" → "SettingsTimedOut").

Since this change would be breaking, a migration logic has been introduced which migrate the legacy conditions to the new format.

Summary by CodeRabbit

Release Notes

  • Refactor

    • Consolidated and standardized condition and reason identifiers across controllers; centralized shared condition definitions.
    • Renamed several internal finalizer identifiers to unexported names and reorganized constant declarations.
  • Chores / Migration

    • Added automatic, in‑place migration of legacy status condition types during reconciliation to preserve existing resource status.

Condition and reason constants were scattered across controller files
with inconsistent naming conventions (mixed prefixes, unexported names,
BIOS/BMC-specific names for generic concepts) and true duplicates using
identical string values. This made it hard to discover existing constants
and led to accidental duplication when adding new controllers.

Consolidate shared condition and reason constants into a central
conditions.go file and normalize naming to a consistent
Condition<Name>/Reason<Name> pattern. Generalize BIOS/BMC-specific
names and string values where the concepts are generic (e.g.,
ConditionBMCResetIssued → ConditionResetIssued,
"BIOSSettingsTimedOut" → "SettingsTimedOut").

This is a breaking change for existing CRs due to changed condition type
and reason string values.
@afritzler afritzler requested a review from a team as a code owner April 9, 2026 13:00
@github-actions github-actions bot added size/XL enhancement New feature or request labels Apr 9, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 9, 2026

Walkthrough

Consolidates controller condition and reason constants into a new shared conditions.go, updates controllers/tests to use the new Condition*/Reason* identifiers, introduces per-controller status condition migration patches in several Reconcile implementations, and renames multiple exported finalizer constants to unexported identifiers.

Changes

Cohort / File(s) Summary
Shared Conditions Definition
internal/controller/conditions.go
New file: exported Condition* and Reason* constants for server maintenance, resets, version upgrades, power states, readiness, and related reasons.
BIOS Settings
internal/controller/biossettings_controller.go, internal/controller/biossettings_controller_test.go
Replaced local BIOSSettings condition/reason constants with shared Condition*/Reason* names; added migration step to remap legacy Status.Conditions/FlowState[].Conditions; updated tests.
BIOS Version
internal/controller/biosversion_controller.go, internal/controller/biosversion_controller_test.go
Replaced BIOS-upgrade-specific constants with shared identifiers; added legacy condition-type migration and updated upgrade/reset/verification condition usage and tests.
BMC Controllers
internal/controller/bmc_controller.go, internal/controller/bmc_controller_test.go, internal/controller/bmcsettings_controller.go, internal/controller/bmcsettingsset_controller.go, internal/controller/bmcsettings_controller_test.go
Switched local BMC/BMCSettings constants to shared Condition*/Reason*; updated ready/reset/auth handling; added migration in BMCSettings Reconcile; reorganized some finalizer const blocks and tests.
BMC Version
internal/controller/bmcversion_controller.go, internal/controller/bmcversion_controller_test.go
Consolidated BMCVersion condition/reason identifiers to shared constants; added legacy-condition migration and updated reset/upgrade flows and tests.
Helper & Migrations
internal/controller/helper.go
Removed server-maintenance constants from helper; added migrateConditionTypes(conditions, migrations) utility used by controllers for in-place type remapping.
Server & ServerClaim
internal/controller/server_controller.go, internal/controller/server_controller_test.go, internal/controller/serverclaim_controller.go, internal/controller/serverclaim_controller_test.go
Replaced PoweringOnCondition with ConditionPoweringOn; renamed exported finalizer ServerClaimFinalizer → unexported serverClaimFinalizer and updated usages/tests.
Server Maintenance & Endpoint
internal/controller/servermaintenance_controller.go, internal/controller/endpoint_controller.go
Moved ServerMaintenance constants into shared file; renamed finalizers from exported to unexported (serverMaintenanceFinalizer, endpointFinalizer) and updated usages.
Finalizer Const Block Reorg
internal/controller/biossettingsset_controller.go, internal/controller/biosversionset_controller.go, internal/controller/bmcsettingsset_controller.go, internal/controller/bmcversionset_controller.go
Moved several finalizer declarations into parenthesized const (...) blocks for consistency; no behavioral changes.
Misc Tests/Small Renames
internal/controller/..._test.go (various)
Updated tests to expect new Condition*/Reason* constants and renamed finalizer constants where applicable.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested labels

api-change, area/metal-automation

Suggested reviewers

  • nagadeesh-nagaraja
  • Nuckal777
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main objective: centralizing and harmonizing condition/reason constants across controllers.
Description check ✅ Passed The description adequately explains the problem (scattered constants with inconsistent naming), the solution (centralize in conditions.go with consistent naming), and notes the breaking change with migration logic.
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch enh/conditions

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
internal/controller/bmcversion_controller.go (1)

294-363: ⚠️ Potential issue | 🟠 Major

Don’t rename these persisted upgrade checkpoints without a compatibility layer.

ConditionVersionUpgradeIssued, ConditionVersionUpgradeCompleted, ConditionVersionUpgradeReboot, and ConditionVersionUpgradeVerification are the upgrade state machine’s checkpoints. After this rollout, a BMCVersion that was already mid-flight with the legacy condition types will read as “not started” here, and we can issue a second firmware upgrade task or BMC reset against the same device. Please keep the stored Type strings compatible or migrate legacy entries before these checks run.

As per coding guidelines "Implement idempotent reconciliation logic - safe to run the same reconciliation multiple times without side effects".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/controller/bmcversion_controller.go` around lines 294 - 363, The
checks for ConditionVersionUpgradeIssued, ConditionVersionUpgradeCompleted,
ConditionVersionUpgradeReboot and ConditionVersionUpgradeVerification will treat
existing BMCVersion resources with legacy condition Type strings as "not
started" and may re-issue upgrades; to fix this, add a compatibility/migration
step that runs before these GetCondition calls (e.g., a function
MigrateLegacyConditionTypes or Extend GetCondition to accept legacy aliases)
which scans bmcVersion.Status.Conditions, maps legacy Type values to the current
constants (ConditionVersionUpgradeIssued, ConditionVersionUpgradeCompleted,
ConditionVersionUpgradeReboot, ConditionVersionUpgradeVerification) and updates
the resource status (or treats legacy names as equivalent at read time) so the
existing in-flight upgrades are recognized; ensure this migration is idempotent
and runs once per resource before issuing upgrades or resets, and reference the
existing symbols in this file (GetCondition, r.Conditions.Update,
r.patchBMCVersionStatusAndCondition, and the ConditionVersionUpgrade* constants)
when implementing it.
internal/controller/biosversion_controller.go (1)

305-327: ⚠️ Potential issue | 🔴 Critical

Preserve legacy condition checkpoints before re-entering upgrade/reset steps.

BIOSVersion.Status.Conditions is acting as the reconciler’s checkpoint store here. After this rename, any already-running BIOSVersion that still carries the old condition types/reasons will miss these GetCondition(...) gates and can re-enter upgradeBIOSVersion() or resetBMCOfServer() after an operator rollout. That turns a status-string rename into a duplicate external action hazard.

Please add backward-compatible lookups or migrate legacy condition entries before branching on these checkpoints.

As per coding guidelines "Implement idempotent reconciliation logic - safe to run the same reconciliation multiple times without side effects".

Also applies to: 413-445, 466-515

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/controller/biosversion_controller.go` around lines 305 - 327,
GetCondition lookups against BIOSVersion.Status.Conditions must tolerate legacy
condition names/types before deciding to call upgradeBIOSVersion or
resetBMCOfServer; update the code around the GetCondition(...) calls (e.g.,
where ConditionVersionUpgradeIssued and ConditionVersionUpgradeCompleted are
checked) to first search for legacy condition keys or migrate legacy entries
into the new condition names (or treat legacy matches as equivalent) so old
in-flight BIOSVersion objects won’t slip past the gate; ensure this
compatibility lookup/migration happens prior to branching (before calling
upgradeBIOSVersion, resetBMCOfServer, or returning) and apply the same pattern
to the other blocks noted (around lines checking
ConditionVersionUpgradeCompleted and the reset logic).
internal/controller/biosversion_controller_test.go (1)

603-622: ⚠️ Potential issue | 🟡 Minor

Assert the reboot checkpoints instead of rechecking completion.

Lines 603 and 622 still look up ConditionVersionUpgradeCompleted. processInProgressState() now records those steps under ConditionUpgradePowerOff and ConditionUpgradePowerOn, so these assertions can pass without ever validating the renamed reboot conditions.

Suggested test fix
-			g.Expect(acc.FindSlice(biosVersion.Status.Conditions, ConditionVersionUpgradeCompleted, rebootStart)).To(BeTrue())
+			g.Expect(acc.FindSlice(biosVersion.Status.Conditions, ConditionUpgradePowerOff, rebootStart)).To(BeTrue())
...
-		g.Expect(acc.FindSlice(biosVersion.Status.Conditions, ConditionVersionUpgradeCompleted, rebootComplete)).To(BeTrue())
+		g.Expect(acc.FindSlice(biosVersion.Status.Conditions, ConditionUpgradePowerOn, rebootComplete)).To(BeTrue())
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/controller/biosversion_controller_test.go` around lines 603 - 622,
Replace the two assertions that look up ConditionVersionUpgradeCompleted for the
reboot checkpoints with the new reboot condition names: when validating the
pre-reboot checkpoint currently stored in variable rebootStart use
ConditionUpgradePowerOff, and when validating the post-reboot checkpoint stored
in rebootComplete use ConditionUpgradePowerOn; keep the same pattern of using
acc.FindSlice(...) and asserting the condition's Status == metav1.ConditionTrue
so the test asserts the actual reboot checkpoints instead of the renamed
completion condition.
🧹 Nitpick comments (1)
internal/controller/bmc_controller.go (1)

163-166: Centralize ResetComplete too.

ConditionReset is shared now, but the terminal reason is still a raw string here, so the condition contract is still split across controller code and tests. Adding a shared ReasonResetComplete constant would finish the cleanup and make future renames compile-time safe.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/controller/bmc_controller.go` around lines 163 - 166, The code uses
the raw string "ResetComplete" as the terminal reason when calling
updateConditions for ConditionReset; introduce a package-level constant
ReasonResetComplete (matching the existing ReasonConnected/ReasonXXX pattern)
and replace the literal "ResetComplete" with ReasonResetComplete in the
updateConditions call (and any other occurrences/tests) so the reset reason is
centralized and compile-time-safe; add the new ReasonResetComplete constant next
to the other reason constants and run tests to update any assertions referencing
the raw string.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@internal/controller/biossettings_controller.go`:
- Around line 37-63: The constants like ConditionPendingSettingsCheck,
ConditionSettingsDuplicateKeys, ConditionSettingsUpdateStartTime, etc. are used
as serialized keys in status.conditions and flowState[].conditions; renaming
them breaks idempotency for existing CRs. Fix by adding legacy aliases and a
small migration in the controller: define legacy constant values mapping
oldName->newName (e.g., LegacyConditionX -> ConditionX) and update the condition
lookup utilities (the codepaths that call GetCondition / FindSlice) to treat
either legacy or new strings as equivalent (or on reconcile, detect legacy keys
in status.conditions/flowState and replace them with the new constants once).
Ensure both the lookup and the reconciliation step that emits conditions write
the new names going forward so upgrades remain compatible and no duplicate
actions are reissued.

In `@internal/controller/bmcsettings_controller.go`:
- Line 377: The reconcile check using handleBMCReset and ConditionResetIssued
must accept legacy condition type names before deciding a reset has been issued;
update the gate that calls handleBMCReset(ctx, settings, bmcObj,
ConditionResetIssued) (and similar checks around SetBMCAttributesImmediately and
GetCondition) to first map/translate any legacy status.conditions[].type values
to the current constants (or check both the new and legacy names) so existing
InProgress BMCSettings are recognized as already progressed and do not
re-trigger resetting or re-issuing annotations; ensure the translation occurs
before invoking GetCondition/handleBMCReset and apply the same mapping in the
other ranges noted (around lines that call SetBMCAttributesImmediately and
additional GetCondition checks).

In `@internal/controller/conditions.go`:
- Around line 7-74: Controllers will miss legacy condition Type values after
renaming constants like ConditionServerMaintenanceCreated,
ConditionServerMaintenanceDeleted, ConditionServerMaintenanceWaiting,
ConditionResetIssued, ConditionVersionUpgradeIssued, etc., so add a
normalization/migration step: implement a small helper (e.g.,
NormalizeConditionTypes or migrateLegacyConditionTypes) that scans an object's
status.Conditions and rewrites legacy Type strings to the new constant values,
use this helper in places that call GetCondition (or in the controller Reconcile
before any condition reads/writes) so existing objects are normalized at
runtime; alternatively provide a one-shot migration controller that performs the
same update on all objects and then removes itself.

---

Outside diff comments:
In `@internal/controller/biosversion_controller_test.go`:
- Around line 603-622: Replace the two assertions that look up
ConditionVersionUpgradeCompleted for the reboot checkpoints with the new reboot
condition names: when validating the pre-reboot checkpoint currently stored in
variable rebootStart use ConditionUpgradePowerOff, and when validating the
post-reboot checkpoint stored in rebootComplete use ConditionUpgradePowerOn;
keep the same pattern of using acc.FindSlice(...) and asserting the condition's
Status == metav1.ConditionTrue so the test asserts the actual reboot checkpoints
instead of the renamed completion condition.

In `@internal/controller/biosversion_controller.go`:
- Around line 305-327: GetCondition lookups against
BIOSVersion.Status.Conditions must tolerate legacy condition names/types before
deciding to call upgradeBIOSVersion or resetBMCOfServer; update the code around
the GetCondition(...) calls (e.g., where ConditionVersionUpgradeIssued and
ConditionVersionUpgradeCompleted are checked) to first search for legacy
condition keys or migrate legacy entries into the new condition names (or treat
legacy matches as equivalent) so old in-flight BIOSVersion objects won’t slip
past the gate; ensure this compatibility lookup/migration happens prior to
branching (before calling upgradeBIOSVersion, resetBMCOfServer, or returning)
and apply the same pattern to the other blocks noted (around lines checking
ConditionVersionUpgradeCompleted and the reset logic).

In `@internal/controller/bmcversion_controller.go`:
- Around line 294-363: The checks for ConditionVersionUpgradeIssued,
ConditionVersionUpgradeCompleted, ConditionVersionUpgradeReboot and
ConditionVersionUpgradeVerification will treat existing BMCVersion resources
with legacy condition Type strings as "not started" and may re-issue upgrades;
to fix this, add a compatibility/migration step that runs before these
GetCondition calls (e.g., a function MigrateLegacyConditionTypes or Extend
GetCondition to accept legacy aliases) which scans bmcVersion.Status.Conditions,
maps legacy Type values to the current constants (ConditionVersionUpgradeIssued,
ConditionVersionUpgradeCompleted, ConditionVersionUpgradeReboot,
ConditionVersionUpgradeVerification) and updates the resource status (or treats
legacy names as equivalent at read time) so the existing in-flight upgrades are
recognized; ensure this migration is idempotent and runs once per resource
before issuing upgrades or resets, and reference the existing symbols in this
file (GetCondition, r.Conditions.Update, r.patchBMCVersionStatusAndCondition,
and the ConditionVersionUpgrade* constants) when implementing it.

---

Nitpick comments:
In `@internal/controller/bmc_controller.go`:
- Around line 163-166: The code uses the raw string "ResetComplete" as the
terminal reason when calling updateConditions for ConditionReset; introduce a
package-level constant ReasonResetComplete (matching the existing
ReasonConnected/ReasonXXX pattern) and replace the literal "ResetComplete" with
ReasonResetComplete in the updateConditions call (and any other
occurrences/tests) so the reset reason is centralized and compile-time-safe; add
the new ReasonResetComplete constant next to the other reason constants and run
tests to update any assertions referencing the raw string.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7496651c-e543-4bf6-badf-74769565f2b9

📥 Commits

Reviewing files that changed from the base of the PR and between 87a9fe2 and a324c52.

📒 Files selected for processing (22)
  • internal/controller/biossettings_controller.go
  • internal/controller/biossettings_controller_test.go
  • internal/controller/biossettingsset_controller.go
  • internal/controller/biosversion_controller.go
  • internal/controller/biosversion_controller_test.go
  • internal/controller/biosversionset_controller.go
  • internal/controller/bmc_controller.go
  • internal/controller/bmc_controller_test.go
  • internal/controller/bmcsettings_controller.go
  • internal/controller/bmcsettingsset_controller.go
  • internal/controller/bmcuser_controller.go
  • internal/controller/bmcversion_controller.go
  • internal/controller/bmcversion_controller_test.go
  • internal/controller/bmcversionset_controller.go
  • internal/controller/conditions.go
  • internal/controller/endpoint_controller.go
  • internal/controller/helper.go
  • internal/controller/server_controller.go
  • internal/controller/server_controller_test.go
  • internal/controller/serverclaim_controller.go
  • internal/controller/serverclaim_controller_test.go
  • internal/controller/servermaintenance_controller.go
💤 Files with no reviewable changes (1)
  • internal/controller/helper.go

@afritzler
Copy link
Copy Markdown
Member Author

@coderabbitai create an issue to remove the condition migration logic in the next release.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 10, 2026

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

Let me first look for the condition migration logic in the codebase.


🏁 Script executed:

#!/bin/bash
# Search for condition migration logic
rg -n "migration\|migrate\|MigrateCondition\|migrateCondition\|conditionMigrat" --type=go -C3

# Also search for any legacy condition handling
rg -n "legacy\|Legacy\|LegacyCondition\|legacyCondition" --type=go -C3

# Search for backward compat condition logic
rg -n "backwardCompat\|BackwardCompat\|compat.*condition\|Condition.*compat" --type=go -C3

Length of output: 0


Let me search more broadly for any condition-related migration or transition logic.


🏁 Script executed:

#!/bin/bash
# Look for any condition migration helpers or transition functions
rg -n "OldCondition\|oldCondition\|deprecatedCondition\|DeprecatedCondition\|conditionTransition\|renameCondition\|mapCondition" --type=go -C3

# Check helper.go for any migration-related logic
fd "helper.go" --type=f | xargs cat

# Check conditions.go for any migration-related logic
fd "conditions.go" --type=f | xargs cat

Length of output: 21020


Found the migration logic. Let me now find all its call sites before creating the issue.


🏁 Script executed:

#!/bin/bash
# Find all usages of migrateConditionTypes
rg -n "migrateConditionTypes" --type=go -C5

Length of output: 5537


Now I have all the details. Let me create the GitHub issue.


🏁 Script executed:

#!/bin/bash
gh issue create \
  --repo ironcore-dev/metal-operator \
  --title "Remove condition migration logic after next release" \
  --body "## Summary

As part of PR `#795` (centralize and harmonize condition/reason constants across controllers), a temporary condition migration layer was introduced to rename legacy condition type strings on existing CRs in-place during reconciliation. This migration logic is marked with \`TODO: Remove this function in the next release once all CRs have been reconciled.\` and should be cleaned up once all CRs in the field have been reconciled with the new condition naming scheme.

## What needs to be removed

The following items are marked for removal in the next release:

1. **\`migrateConditionTypes\` helper function** in \`internal/controller/helper.go\` (Lines 88–97)
2. **\`legacyBMCSettingsConditionTypes\` map + migration call** in \`internal/controller/bmcsettings_controller.go\` (Line 81)
3. **\`legacyBMCVersionConditionTypes\` map + migration call** in \`internal/controller/bmcversion_controller.go\` (Line 72)
4. **\`legacyBIOSVersionConditionTypes\` map + migration call** in \`internal/controller/biosversion_controller.go\` (Line 81)
5. **\`legacyBIOSSettingsConditionTypes\` map + \`migrateLegacyConditions\` method** in \`internal/controller/biossettings_controller.go\` (Lines 114–126)

## Prerequisites

Before removing the migration logic, ensure that:
- Sufficient time has passed for all existing CRs to be reconciled with the updated condition type strings introduced in PR `#795`.
- Any documentation or migration guides referencing the old condition names have been updated.

## References

- PR `#795`: https://github.com/ironcore-dev/metal-operator/pull/795
- Requested by: `@afritzler`" \
  --assignee afritzler

Length of output: 57


@afritzler: Done! I've created issue #796"Remove condition migration logic after next release".

The issue covers all five items marked with TODO: Remove this ... in the next release once all CRs have been reconciled:

File Item to Remove
internal/controller/helper.go migrateConditionTypes helper function
internal/controller/bmcsettings_controller.go legacyBMCSettingsConditionTypes map + migration call (Line 81)
internal/controller/bmcversion_controller.go legacyBMCVersionConditionTypes map + migration call (Line 72)
internal/controller/biosversion_controller.go legacyBIOSVersionConditionTypes map + migration call (Line 81)
internal/controller/biossettings_controller.go legacyBIOSSettingsConditionTypes map + migrateLegacyConditions method

🧠 Learnings used
Learnt from: nagadeesh-nagaraja
Repo: ironcore-dev/metal-operator PR: 794
File: api/v1alpha1/bmc_types.go:19-20
Timestamp: 2026-04-09T09:55:17.938Z
Learning: In ironcore-dev/metal-operator, the string constants `ProtocolRedfish`, `ProtocolRedfishLocal`, and `ProtocolRedfishWithRegistryPatch` (formerly `ProtocolRedfishKube`) in `api/v1alpha1/bmc_types.go` are purely Go-level identifiers used in controller switch-case logic (e.g., `internal/controller/endpoint_controller.go`, `internal/bmcutils/bmcutils.go`). They are NOT referenced by any `+kubebuilder:validation:Enum` markers and are not baked into the CRD OpenAPI schema, so renaming them does not affect the CRD manifests and `make manifests` produces no change for such renames. `ProtocolRedfishWithRegistryPatch` is a dev/tilt-only protocol only used in `config/dev/`.

Learnt from: nagadeesh-nagaraja
Repo: ironcore-dev/metal-operator PR: 695
File: internal/controller/bmcsettings_controller.go:720-730
Timestamp: 2026-03-04T10:32:24.468Z
Learning: In `internal/controller/bmcsettings_controller.go` (and sibling controllers), the `RetryOfFailedResourceConditionIssued` condition is intentionally left unchanged when its Status is already `metav1.ConditionTrue`. The guard `if retryCondition.Status != metav1.ConditionTrue` is by design — existing condition metadata (reason/message) is preserved on re-entrant reconciliations to avoid redundant updates.

Learnt from: CR
Repo: ironcore-dev/metal-operator PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-02-17T13:12:50.124Z
Learning: Applies to api/**/*_types.go : Use `metav1.Condition` for status fields instead of custom string fields

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (2)
internal/controller/bmcsettings_controller.go (1)

58-62: ⚠️ Potential issue | 🔴 Critical

Migrate the renamed BMCSettings checkpoint types too.

Line 61 only rewrites BMCResetIssued, but this controller now uses other renamed persisted BMCSettings condition types as workflow checkpoints as well (ConditionBMCResetPostSettingApply, ConditionBMCPoweredOff, ConditionBMCSettingsChangesIssued, ConditionBMCSettingsChangesVerified). Existing InProgress CRs that already passed one of those steps can look unfinished after rollout and re-issue settings or the post-apply reset.

As per coding guidelines "Implement idempotent reconciliation logic - safe to run the same reconciliation multiple times without side effects".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/controller/bmcsettings_controller.go` around lines 58 - 62, Update
the legacyBMCSettingsConditionTypes migration map to include the other renamed
checkpoint condition types so persisted CRs are rewritten to the new constants
and reconciliation stays idempotent; specifically add mappings for the old
string names corresponding to ConditionBMCResetPostSettingApply,
ConditionBMCPoweredOff, ConditionBMCSettingsChangesIssued, and
ConditionBMCSettingsChangesVerified into the existing
legacyBMCSettingsConditionTypes map and ensure the reconciliation code that
applies this map (the logic using legacyBMCSettingsConditionTypes) will
translate any of those legacy keys to the new constants before deciding workflow
checkpoints.
internal/controller/biossettings_controller.go (1)

66-77: ⚠️ Potential issue | 🔴 Critical

Complete the BIOSSettings legacy map for the flow-state checkpoints.

This map only migrates part of the renamed serialized condition types. The later flow-state gates still read renamed persisted checkpoints like ConditionSettingsUpdateIssued, ConditionSettingsRebootPowerOff, ConditionSettingsRebootPowerOn, ConditionSettingsVerify, and ConditionSettingsInvalid. An existing InProgress BIOSSettings can therefore fall back into earlier phases after upgrade and replay setting writes or reboot steps.

As per coding guidelines "Implement idempotent reconciliation logic - safe to run the same reconciliation multiple times without side effects".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/controller/biossettings_controller.go` around lines 66 - 77, The
legacyBIOSSettingsConditionTypes map is missing mappings for later flow-state
checkpoint condition names, causing upgraded InProgress BIOSSettings to replay
earlier phases; update the map in internal/controller/biossettings_controller.go
(legacyBIOSSettingsConditionTypes) to include the old serialized keys for
ConditionSettingsUpdateIssued, ConditionSettingsRebootPowerOff,
ConditionSettingsRebootPowerOn, ConditionSettingsVerify, and
ConditionSettingsInvalid mapped to their corresponding new constants
(ConditionSettingsUpdateIssued, ConditionSettingsRebootPowerOff,
ConditionSettingsRebootPowerOn, ConditionSettingsVerify,
ConditionSettingsInvalid) so deserialization uses the new names and
reconciliation remains idempotent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@internal/controller/biossettings_controller.go`:
- Around line 66-77: The legacyBIOSSettingsConditionTypes map is missing
mappings for later flow-state checkpoint condition names, causing upgraded
InProgress BIOSSettings to replay earlier phases; update the map in
internal/controller/biossettings_controller.go
(legacyBIOSSettingsConditionTypes) to include the old serialized keys for
ConditionSettingsUpdateIssued, ConditionSettingsRebootPowerOff,
ConditionSettingsRebootPowerOn, ConditionSettingsVerify, and
ConditionSettingsInvalid mapped to their corresponding new constants
(ConditionSettingsUpdateIssued, ConditionSettingsRebootPowerOff,
ConditionSettingsRebootPowerOn, ConditionSettingsVerify,
ConditionSettingsInvalid) so deserialization uses the new names and
reconciliation remains idempotent.

In `@internal/controller/bmcsettings_controller.go`:
- Around line 58-62: Update the legacyBMCSettingsConditionTypes migration map to
include the other renamed checkpoint condition types so persisted CRs are
rewritten to the new constants and reconciliation stays idempotent; specifically
add mappings for the old string names corresponding to
ConditionBMCResetPostSettingApply, ConditionBMCPoweredOff,
ConditionBMCSettingsChangesIssued, and ConditionBMCSettingsChangesVerified into
the existing legacyBMCSettingsConditionTypes map and ensure the reconciliation
code that applies this map (the logic using legacyBMCSettingsConditionTypes)
will translate any of those legacy keys to the new constants before deciding
workflow checkpoints.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 01928ccd-9998-468b-b52e-890eadadb257

📥 Commits

Reviewing files that changed from the base of the PR and between a324c52 and 04881ee.

📒 Files selected for processing (5)
  • internal/controller/biossettings_controller.go
  • internal/controller/biosversion_controller.go
  • internal/controller/bmcsettings_controller.go
  • internal/controller/bmcversion_controller.go
  • internal/controller/helper.go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants