CMP-4478: Fix ProfileBundle reversion on operator restart using Subscription patch#79
Open
yuumasato wants to merge 1 commit into
Open
Conversation
ProfileBundles with custom content images are reverted to default images when the compliance-operator restarts (e.g., node reboots, pod crashes). This happened because the operator's ensureDefaultProfileBundles() runs at startup and unconditionally patches existing ProfileBundles with the image from the RELATED_IMAGE_PROFILE env var, which defaults to the CSV's default image. Solution: Add RELATED_IMAGE_PROFILE to Subscription.spec.config.env before creating the Subscription, so the operator uses the custom content image from startup. Changes: - Modified ensureSubscriptionExists() to add RELATED_IMAGE_PROFILE env var to Subscription before creating it (if using custom image) - Added addSubscriptionEnvVar() helper to safely add env vars to spec.config.env - Removed ensureTestProfileBundles() - Simplified Setup() flow: install → wait for valid ProfileBundles How it works: 1. ensureSubscriptionExists() reads Subscription YAML template 2. If custom image specified, adds RELATED_IMAGE_PROFILE to spec.config.env 3. Creates Subscription with correct configuration 4. OLM merges Subscription env vars into Deployment 5. Operator starts with custom env var and creates ProfileBundles with custom image 6. Changes survive operator restarts (node reboots, pod crashes) Why add to Subscription before creation: - Subscription.spec.config.env is the designed OLM mechanism for env overrides - Subscription config persists across OLM reconciliation and operator upgrades - Subscription env vars take precedence over CSV defaults - Solves both initial setup AND restart/reboot cases Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
fa30229 to
02de6a2
Compare
Member
Author
|
/retest |
|
@yuumasato: The following tests failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
|
/lgtm |
vickeybrown
approved these changes
Jul 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
ProfileBundles with custom content images are reverted to default images when the compliance-operator restarts (e.g., node reboots, pod crashes).
Root cause: The operator's
ensureDefaultProfileBundles()runs at startup and unconditionally patches existing ProfileBundles with the image from theRELATED_IMAGE_PROFILEenv var, which defaults to the CSV's default image.Impact: Tests using custom content images, from PRs for example, failed intermittently when the operator pod restarted during test execution.
Solution
Add
RELATED_IMAGE_PROFILEtoSubscription.spec.config.envbefore creating the Subscription, so the operator uses the custom content image from startup.Why add to Subscription before creation:
Subscription.spec.config.envis the designed OLM mechanism for env var overridesChanges
ensureSubscriptionExists()to addRELATED_IMAGE_PROFILEenv var to Subscription before creating it (if using custom image)addSubscriptionEnvVar()helper to safely add env vars tospec.config.envensureTestProfileBundles()(no longer needed - 74 lines removed)Setup()flow: install → wait for valid ProfileBundlesTesting
Run this script to reproduce the original problem and verify the fix: