Skip to content

fix default partition mapping#108

Merged
bennyz merged 1 commit into
centos-automotive-suite:mainfrom
bennyz:unmanaged-opts
Feb 13, 2026
Merged

fix default partition mapping#108
bennyz merged 1 commit into
centos-automotive-suite:mainfrom
bennyz:unmanaged-opts

Conversation

@bennyz

@bennyz bennyz commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

and do not override ConfigMap

Summary by CodeRabbit

Release Notes

  • New Features

    • Resources can now be marked as unmanaged to prevent automatic updates.
    • Added support for additional partition configurations.
  • Improvements

    • Existing configurations are preserved during updates instead of being overwritten.

and do not override ConfigMap

Signed-off-by: Benny Zlotnik <bzlotnik@redhat.com>
@coderabbitai

coderabbitai Bot commented Feb 13, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This change introduces centralized constants for unmanaged resource handling and enhances the operator config controller. It adds guards to skip updating resources marked as unmanaged, expands partition config data with new entries, and modifies ConfigMap creation to be non-destructive by only creating if not existing.

Changes

Cohort / File(s) Summary
Unmanaged Resource Handling
internal/controller/operatorconfig/controller.go
Introduces unmanagedAnnotationKey and unmanagedAnnotationTrue constants; adds guard in createOrUpdate to skip updating unmanaged resources; replaces hardcoded annotation strings with centralized constants across createOrUpdateTask, createOrUpdatePipeline, and related methods.
Partition Config Enhancement
internal/controller/operatorconfig/controller.go
Expands partition config data with five new entries (ridesx4_r3, ride4_sa8775p_sx, ride4_sa8775p_sx_legacy, ride4_sa8775p_sx_legacy_r3, ride4_sa8650p_sx_r3); changes ConfigMap creation logic to only create if not existing, preserving user modifications.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A rabbit hops through code so fine,
With constants that now align,
No more updates where hands have played,
New partitions join the parade! 🐰
This refactor makes changes glow,
Safer, cleaner, row by row.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix default partition mapping' directly relates to the main change in the PR: updating partition config data with additional entries. However, it omits the significant secondary change about preventing ConfigMap overrides, which is mentioned in the description.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@internal/controller/operatorconfig/controller.go`:
- Around line 488-492: The log call in the unmanaged-resource check uses
obj.GetObjectKind().GroupVersionKind().Kind which can be empty for in-memory
objects; change the log to use the reconciled object's GVK
(existing.GetObjectKind().GroupVersionKind().Kind) and, if that is empty, fall
back to a type string such as fmt.Sprintf("%T", obj) before calling r.Log.Info
(keep the same message and keys and still return nil); reference: existing, obj,
unmanagedAnnotationKey, unmanagedAnnotationTrue, and r.Log.Info.
🧹 Nitpick comments (1)
internal/controller/operatorconfig/controller.go (1)

605-616: Create-only semantics won't propagate new partition entries to existing clusters on upgrade.

The switch to create-only means clusters that already have the aib-partition-config ConfigMap will not receive the newly added targets (ridesx4_r3, ride4_sa8775p_sx, ride4_sa8775p_sx_legacy, etc.). If this is intentional per the PR objective ("do not override ConfigMap"), consider documenting the upgrade path (e.g., users must manually add new entries or delete the ConfigMap to get defaults).

Also, the function name createOrUpdatePartitionConfig no longer updates — a rename to ensurePartitionConfig would better reflect the new behavior.

Comment on lines +488 to +492
// Skip update if resource is marked as unmanaged
if annotations := existing.GetAnnotations(); annotations != nil && annotations[unmanagedAnnotationKey] == unmanagedAnnotationTrue {
r.Log.Info("Skipping update for unmanaged resource", "name", obj.GetName(), "kind", obj.GetObjectKind().GroupVersionKind().Kind)
return nil
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

obj.GetObjectKind().GroupVersionKind().Kind may log an empty string.

In-memory objects built by your build* helpers typically don't have TypeMeta set, so obj.GetObjectKind().GroupVersionKind().Kind will resolve to "". Consider using existing (which has GVK populated after r.Get) or use fmt.Sprintf("%T", obj) as a fallback.

Proposed fix
-		r.Log.Info("Skipping update for unmanaged resource", "name", obj.GetName(), "kind", obj.GetObjectKind().GroupVersionKind().Kind)
+		r.Log.Info("Skipping update for unmanaged resource", "name", obj.GetName(), "kind", existing.GetObjectKind().GroupVersionKind().Kind)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Skip update if resource is marked as unmanaged
if annotations := existing.GetAnnotations(); annotations != nil && annotations[unmanagedAnnotationKey] == unmanagedAnnotationTrue {
r.Log.Info("Skipping update for unmanaged resource", "name", obj.GetName(), "kind", obj.GetObjectKind().GroupVersionKind().Kind)
return nil
}
// Skip update if resource is marked as unmanaged
if annotations := existing.GetAnnotations(); annotations != nil && annotations[unmanagedAnnotationKey] == unmanagedAnnotationTrue {
r.Log.Info("Skipping update for unmanaged resource", "name", obj.GetName(), "kind", existing.GetObjectKind().GroupVersionKind().Kind)
return nil
}
🤖 Prompt for AI Agents
In `@internal/controller/operatorconfig/controller.go` around lines 488 - 492, The
log call in the unmanaged-resource check uses
obj.GetObjectKind().GroupVersionKind().Kind which can be empty for in-memory
objects; change the log to use the reconciled object's GVK
(existing.GetObjectKind().GroupVersionKind().Kind) and, if that is empty, fall
back to a type string such as fmt.Sprintf("%T", obj) before calling r.Log.Info
(keep the same message and keys and still return nil); reference: existing, obj,
unmanagedAnnotationKey, unmanagedAnnotationTrue, and r.Log.Info.

@bennyz bennyz merged commit 17b9015 into centos-automotive-suite:main Feb 13, 2026
4 checks passed
@bennyz bennyz deleted the unmanaged-opts branch February 13, 2026 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant