fix(operator): preserve metadata in partial conversion responses - #12432
Conversation
WalkthroughChangesMetadata preservation
Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
deploy/operator/api/conversion_webhook_test.go (1)
25-107: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueAdd
t.Logheadings for each test step.
deploy/operator/api/conversion_webhook_test.go#L25-L107: add headings before scheme setup, request construction/execution, and response validation.deploy/operator/api/v1beta1/marshal_test.go#L52-L115: add headings before marshaling and metadata assertions in each subtest.As per coding guidelines, “Use
t.Logto tell each Go test's story, with one heading before every block implementing a test step.”🤖 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 `@deploy/operator/api/conversion_webhook_test.go` around lines 25 - 107, The tests lack step headings describing their execution flow. In deploy/operator/api/conversion_webhook_test.go:25-107, add t.Log headings before scheme setup, request construction and execution, and response validation; in deploy/operator/api/v1beta1/marshal_test.go:52-115, add t.Log headings before marshaling and metadata assertions in each subtest, using one heading for each test-step block.Source: Coding guidelines
🤖 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 `@deploy/operator/api/conversion_webhook_test.go`:
- Around line 25-107: The tests lack step headings describing their execution
flow. In deploy/operator/api/conversion_webhook_test.go:25-107, add t.Log
headings before scheme setup, request construction and execution, and response
validation; in deploy/operator/api/v1beta1/marshal_test.go:52-115, add t.Log
headings before marshaling and metadata assertions in each subtest, using one
heading for each test-step block.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: b6ae6db3-0399-4c2d-ad97-92d86f640c23
📒 Files selected for processing (3)
deploy/operator/api/conversion_webhook_test.godeploy/operator/api/v1beta1/marshal.godeploy/operator/api/v1beta1/marshal_test.go
Summary
Fixes #12351.
Kubernetes Server-Side Apply can send partial objects through the CRD conversion webhook while reconciling fields owned under another API version. The v1beta1 JSON normalizer removed the empty top-level
metadata: {}object, causing the API server to reject the conversion response with:This change:
runtime.Objectvalues;podTemplate.metadata: {};Validation
All Operator API tests pass.
Summary by CodeRabbit
Bug Fixes
metadatafield as an empty object when converting Kubernetes objects with minimal metadata.Tests