mcp: selinux: extend annotation to stop reconciling#3989
Conversation
Add another value to the custom selinux policy annotation: if this value is set, the operand (RTE DaemonSet) will use the builtin policy and SCC v2, but the relevant MachineConfig will *stop being reconciled*. Operators can remove the annotation anytime to trigger the reconciliation, causing a MC deletion and therefore a reboot. This way, we decouple the SELinux upgrade from the MachineConfig removal, which helps (or should help) in the upgrade flow. Signed-off-by: Francesco Romani <fromani@redhat.com>
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ffromani The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
📝 WalkthroughWalkthroughThe PR adds an "ignore" annotation value for SELinux policy configuration that allows skipping custom policy application in specific node groups. It defines a core constant and check function, wraps them for operator-level use, and integrates the ignore logic into MachineConfigPool processing with conditional skipping and logging. ChangesIgnore Custom SELinux Policy Configuration
🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the 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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pkg/objectstate/rte/machineconfigpool.go (1)
148-171: LGTM - Correct implementation of ignore logic.The per-tree ignore check correctly short-circuits MachineConfig processing when the annotation is set to "ignore", which aligns with the PR objective to decouple SELinux upgrade from MachineConfig removal. The logic flow properly handles the three states:
- Ignore: skip reconciliation entirely
- Custom policy: create/update MC
- Default policy: delete MC
The V(4) log level means this skip will only appear in debug logs. Consider whether Info-level logging would provide better operational visibility when MachineConfigs are being ignored.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/objectstate/rte/machineconfigpool.go` around lines 148 - 171, The V(4) debug log in the MachineConfigPool reconciliation loop (where mustIgnore := annotations.MustIgnoreCustomPolicy(tree.NodeGroup.Annotations) and the loop over tree.MachineConfigPools short-circuits when mustIgnore is true) is too quiet for operational visibility; change the log call that currently uses klog.V(4).Infof("ignoring MachineConfig for pool %q", mcp.Name) to a higher-visibility level (for example klog.Infof) so operators can see when MachineConfigs are being skipped, keeping the existing early-return behavior and only adjusting the logging level.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@pkg/objectstate/rte/machineconfigpool.go`:
- Around line 148-171: The V(4) debug log in the MachineConfigPool
reconciliation loop (where mustIgnore :=
annotations.MustIgnoreCustomPolicy(tree.NodeGroup.Annotations) and the loop over
tree.MachineConfigPools short-circuits when mustIgnore is true) is too quiet for
operational visibility; change the log call that currently uses
klog.V(4).Infof("ignoring MachineConfig for pool %q", mcp.Name) to a
higher-visibility level (for example klog.Infof) so operators can see when
MachineConfigs are being skipped, keeping the existing early-return behavior and
only adjusting the logging level.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Enterprise
Run ID: b53e995c-0431-41f2-8511-db10130cbe13
📒 Files selected for processing (5)
internal/api/annotations/annotations.gointernal/api/annotations/annotations_test.gointernal/api/annotations/helper/helper.gointernal/api/annotations/helper/helper_test.gopkg/objectstate/rte/machineconfigpool.go
|
/cc @Tal-or tiny change, but not sure yet we want this |
Add another value to the custom selinux policy annotation: if this value is set, the operand (RTE DaemonSet) will use the builtin policy and SCC v2, but the relevant MachineConfig will stop being reconciled.
Operators can remove the annotation anytime to trigger the reconciliation, causing a MC deletion and therefore a reboot.
This way, we decouple the SELinux upgrade from the MachineConfig removal, which helps (or should help) in the upgrade flow.