Update kubernetes plugin for Job selectors#138
Conversation
Addressing The output.yaml Job spec contains manualSelector: false with an explicit spec.selector bearing source cluster UIDs (batch.kubernetes.io/controller-uid, controller-uid). This configuration fails Kubernetes API validation with: Job.batch "wordpress-install" is invalid: spec.selector: Invalid value: ... : selector not auto-generated. When manualSelector: false, Kubernetes rejects explicit selectors; it only accepts auto-generated ones. Related to migtools/crane#308 Signed-off-by: Marek Aufart <maufart@redhat.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe transform now strips both ChangesJob Controller-UID Removal
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related issues
Poem
🚥 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 unit tests (beta)
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)
transform/kubernetes/kubernetes.go (1)
925-979: The PR description lists both label formats; consider whether legacycontroller-uid(withoutbatch.kubernetes.io/prefix) needs handling.The PR description mentions both
batch.kubernetes.io/controller-uidandcontroller-uid, but the implementation only removes the prefixed version. If the tool must process Job specs exported from pre-1.12 Kubernetes clusters during migration, the legacycontroller-uidlabel should also be removed frommatchLabelsand template labels for consistency.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@transform/kubernetes/kubernetes.go` around lines 925 - 979, removeJobControllerUID currently only removes the prefixed label "batch.kubernetes.io/controller-uid"; update it to also detect and remove the legacy "controller-uid" key in both selector.matchLabels and spec.template.metadata.labels. In the manualSelector true branch (function removeJobControllerUID) and in the template-labels removal block, check for both "batch.kubernetes.io/controller-uid" and "controller-uid" (use unstructured.NestedString or NestedMap presence checks), build the JSON pointer paths via escapeJSONPointer for each key, decode the remove patch and append to patches for each found key, and preserve existing error handling and return behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@transform/kubernetes/kubernetes.go`:
- Around line 925-979: removeJobControllerUID currently only removes the
prefixed label "batch.kubernetes.io/controller-uid"; update it to also detect
and remove the legacy "controller-uid" key in both selector.matchLabels and
spec.template.metadata.labels. In the manualSelector true branch (function
removeJobControllerUID) and in the template-labels removal block, check for both
"batch.kubernetes.io/controller-uid" and "controller-uid" (use
unstructured.NestedString or NestedMap presence checks), build the JSON pointer
paths via escapeJSONPointer for each key, decode the remove patch and append to
patches for each found key, and preserve existing error handling and return
behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: c4d021cc-578c-421b-b3fb-dbe9d188675d
📒 Files selected for processing (2)
transform/kubernetes/kubernetes.gotransform/kubernetes/kubernetes_test.go
Signed-off-by: Marek Aufart <maufart@redhat.com>
There was a recent change in KubernetesPlugin regarding to Job resource cleanup in migtools/crane-lib#138 Updating crane-lib dependency to get this update into crane. Related to migtools/crane-lib#138 Signed-off-by: Marek Aufart <maufart@redhat.com>
Addressing The output.yaml Job spec contains manualSelector: false with an explicit spec.selector bearing source cluster UIDs (batch.kubernetes.io/controller-uid, controller-uid). This configuration fails Kubernetes API validation with: Job.batch "wordpress-install" is invalid: spec.selector: Invalid value: ... : selector not auto-generated. When manualSelector: false, Kubernetes rejects explicit selectors; it only accepts auto-generated ones.
Related to migtools/crane#308
Summary by CodeRabbit
Bug Fixes
Tests