Skip to content

Added witheout for operator related resources#134

Merged
msajidmansoori12 merged 2 commits into
migtools:mainfrom
stillalearner:fix_whiteout_operator_related
Mar 30, 2026
Merged

Added witheout for operator related resources#134
msajidmansoori12 merged 2 commits into
migtools:mainfrom
stillalearner:fix_whiteout_operator_related

Conversation

@stillalearner

@stillalearner stillalearner commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Default Kubernetes transform whiteouts now include OLM (Operator Lifecycle Manager) resources under operators.coreos.com. After Crane export started using ServerPreferredResources(), these types are discovered and exported reliably; they are still not safe to apply on a generic target cluster (catalogs, install state, and generated objects differ). Whiteouting them during transform keeps exports as a full snapshot while apply skips them unless the user opts in via plugin flags.

What is whiteouted

Kind Group
Subscription operators.coreos.com
InstallPlan operators.coreos.com
ClusterServiceVersion operators.coreos.com
CatalogSource operators.coreos.com
OperatorGroup operators.coreos.com
OperatorCondition operators.coreos.com

Implementation

  • transform/kubernetes/kubernetes.go: add GroupKind constants and append them to gksToWhiteout.
  • transform/kubernetes/kubernetes_test.go: table tests asserting IsWhiteOut: true for each kind (representative apiVersion per resource).

Behavior notes

  • Export is unchanged; manifests may still appear under the export directory.
  • Transform creates .wh.* files for these resources so apply does not push them.
  • Resources that were already whited out for other reasons (e.g. owner references) behave as before.
  • Users who intentionally want to carry some of these through the pipeline can use existing optional plugin flags (e.g. include-only / extra-whiteouts).

Testing

go test ./transform/kubernetes/...

Summary by CodeRabbit

  • New Features

    • Added support for additional Kubernetes OLM resources: Subscription, InstallPlan, ClusterServiceVersion, CatalogSource, OperatorGroup, and OperatorCondition.
  • Tests

    • Expanded test coverage to validate whiteout behavior for the newly supported OLM resources.

@coderabbitai

coderabbitai Bot commented Mar 30, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 51b92d60-cb83-437c-8286-235ca05b24d4

📥 Commits

Reviewing files that changed from the base of the PR and between 9c0ec1f and 48ed5bc.

📒 Files selected for processing (1)
  • transform/kubernetes/kubernetes_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • transform/kubernetes/kubernetes_test.go

📝 Walkthrough

Walkthrough

Adds six OLM (operators.coreos.com) GroupKind constants and includes them in the whiteout list; expands tests to cover these resources and fixes minor test literal issues.

Changes

Cohort / File(s) Summary
OLM Resource Constants
transform/kubernetes/kubernetes.go
Adds schema.GroupKind constants for Subscription, InstallPlan, ClusterServiceVersion, CatalogSource, OperatorGroup, and OperatorCondition, and appends them to the gksToWhiteout list.
OLM Resource Tests & Formatting
transform/kubernetes/kubernetes_test.go
Adds table-driven test cases verifying whiteout behavior for the six OLM resources across API versions. Also fixes ownerReferences key typos ("ame""name") and normalizes composite literal/spacing formatting in test requests.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐇 I nibble on code beneath the moon,

Six little operators join the tune,
Subscriptions dancing, plans in tow,
CSVs and sources start to glow,
Whiteout whispers — off they go! ✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title contains a typo ('witheout' instead of 'whiteout') and is unclear about what resources are being whiteouted without reading the full context. Correct the typo to 'whiteout' and consider clarifying the title, e.g., 'Add whiteout for OLM operator-related resources' to make the scope immediately clear.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@transform/kubernetes/kubernetes_test.go`:
- Around line 211-212: Replace the misspelled owner reference key "ame" with the
correct "name" in the test data for the ownerReferences entries used by the
GetOwnerReferences() checks; update each occurrence (the ownerReferences
literals shown in kubernetes_test.go where "ame": "PodOwner") to "name":
"PodOwner" so the test fixtures accurately reflect real Kubernetes
ownerReference fields while leaving the GetOwnerReferences() logic unchanged.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 273ca3c0-0a0b-469d-840c-f69f5baf75f5

📥 Commits

Reviewing files that changed from the base of the PR and between cb7e23c and 9c0ec1f.

📒 Files selected for processing (2)
  • transform/kubernetes/kubernetes.go
  • transform/kubernetes/kubernetes_test.go

Comment thread transform/kubernetes/kubernetes_test.go Outdated
@stillalearner

stillalearner commented Mar 30, 2026

Copy link
Copy Markdown
Contributor Author

Transform: same export, old vs new crane

Old binary — only these OLM-related whiteouts (from ownerReferences, not from explicit OLM kinds in gksToWhiteout):

level=info msg="resource file: InstallPlan_operators.coreos.com_v1alpha1_olm-whiteout-test_install-jx94r.yaml creating whiteout file: /tmp/olm-w-tf-old2/resources/olm-whiteout-test/.wh.InstallPlan_operators.coreos.com_v1alpha1_olm-whiteout-test_install-jx94r.yaml"
level=info msg="resource file: OperatorCondition_operators.coreos.com_v2_olm-whiteout-test_prometheusoperator.0.56.3.yaml creating whiteout file: /tmp/olm-w-tf-old2/resources/olm-whiteout-test/.wh.OperatorCondition_operators.coreos.com_v2_olm-whiteout-test_prometheusoperator.0.56.3.yaml"
No whiteout for Subscription, OperatorGroup, or ClusterServiceVersion → those get normal transform-*.yaml patches.

New binary (crane-lib with OLM entries in gksToWhiteout), after go build -a:

level=info msg="resource file: ClusterServiceVersion_operators.coreos.com_v1alpha1_olm-whiteout-test_prometheusoperator.0.56.3.yaml creating whiteout file: /tmp/olm-w-tf-new2/resources/olm-whiteout-test/.wh.ClusterServiceVersion_operators.coreos.com_v1alpha1_olm-whiteout-test_prometheusoperator.0.56.3.yaml"
level=info msg="resource file: InstallPlan_operators.coreos.com_v1alpha1_olm-whiteout-test_install-jx94r.yaml creating whiteout file: /tmp/olm-w-tf-new2/resources/olm-whiteout-test/.wh.InstallPlan_operators.coreos.com_v1alpha1_olm-whiteout-test_install-jx94r.yaml"
level=info msg="resource file: OperatorCondition_operators.coreos.com_v2_olm-whiteout-test_prometheusoperator.0.56.3.yaml creating whiteout file: /tmp/olm-w-tf-new2/resources/olm-whiteout-test/.wh.OperatorCondition_operators.coreos.com_v2_olm-whiteout-test_prometheusoperator.0.56.3.yaml"
level=info msg="resource file: OperatorGroup_operators.coreos.com_v1_olm-whiteout-test_og.yaml creating whiteout file: /tmp/olm-w-tf-new2/resources/olm-whiteout-test/.wh.OperatorGroup_operators.coreos.com_v1_olm-whiteout-test_og.yaml"
level=info msg="resource file: Subscription_operators.coreos.com_v1alpha1_olm-whiteout-test_test-subscription.yaml creating whiteout file: /tmp/olm-w-tf-new2/resources/olm-whiteout-test/.wh.Subscription_operators.coreos.com_v1alpha1_olm-whiteout-test_test-subscription.yaml"

New export brings in more OLM YAML; new transform + crane-lib adds explicit whiteouts for Subscription, OperatorGroup, and ClusterServiceVersion (InstallPlan / OperatorCondition were already whited out on the old path when they had owner references).

@stillalearner

Copy link
Copy Markdown
Contributor Author

Fix for migtools/crane#201

@msajidmansoori12 msajidmansoori12 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.

LGTM

@aufi aufi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

Operator-related use-cases might come later, so we'll focus on handling those when needed.

@msajidmansoori12 msajidmansoori12 merged commit b620e71 into migtools:main Mar 30, 2026
2 checks passed
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.

3 participants