Repository navigation
Fix omitted fields persisting when applying Kubernetes resources - #536
Open
thokra-nav wants to merge 4 commits into
Open
thokra-nav wants to merge 4 commits into
thokra-nav wants to merge 4 commits into
Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Raw updates can reject resources with server-assigned immutable fields and erase controller-managed metadata.
Review effort: Balanced
Findings: 1
What changed in this PR
Replaces server-side apply with create/update semantics so omitted manifest fields are removed.
Changes:
- Uses strict CREATE/UPDATE operations with resource-version conflict detection.
- Adds unit and integration coverage for replacement, removals, errors, and idempotency.
| File | Description |
|---|---|
internal/apply/client.go |
Implements create-or-replace behavior. |
internal/apply/client_test.go |
Tests replacement and concurrency behavior. |
integration_tests/apply_replace.lua |
Verifies field removal end to end. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
thokra-nav
force-pushed
the
apply_create_update
branch
from
October 29, 2026 08:57
0ff2990 to
05a0240
Compare
Replace server-side apply with create/update operations so submitted manifests define the entire desired object. Server-side apply retains omitted fields when another field manager owns them. This caused removed fields such as spec.resources.limits.cpu to remain on existing resources. Existing resources are now replaced using their current resourceVersion to detect concurrent updates. Strict field validation and before/after change reporting are preserved. This intentionally introduces replacement semantics for all supported resource types, including omitted metadata and data fields. Kubernetes defaults and validation still apply, and writes require create/update permissions. Adds regression coverage for field removal across ownership histories, full-object replacement, resource versions, error propagation, and idempotent reapplication.
Transfer Update ownership from kubectl-create, kubectl-client-side-apply, and deployd to nais-api so omitted fields can be removed while preserving other managers' ownership. Reject foreign-field conflicts and unsafe cross-version migrations, and retain caller resourceVersion preconditions across migration. Make the Kubernetes fake ownership-aware and cover omission, migration, controller ownership, and concurrency regressions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Transfer Update ownership from kubectl-create, kubectl-client-side-apply, and deployd to nais-api so omitted fields can be removed while preserving other managers' ownership. Reject foreign-field conflicts and unsafe cross-version migrations, and retain caller resourceVersion preconditions across migration. Make the Kubernetes fake ownership-aware and cover omission, migration, controller ownership, and concurrency regressions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
thokra-nav
force-pushed
the
apply_create_update
branch
from
November 6, 2026 07:58
05a0240 to
cbe9ddf
Compare
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
The replacement path preserves only resourceVersion, causing unchanged Job and bound PVC manifests to fail Kubernetes validation when they omit server-generated immutable fields.
No open issues 🎉
3 resolved since last review
Review effort: Balanced
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.


Replace server-side apply with create/update operations so submitted manifests define the entire desired object.
Server-side apply retains omitted fields when another field manager owns them. This caused removed fields such as spec.resources.limits.cpu to remain on existing resources.
Existing resources are now replaced using their current resourceVersion to detect concurrent updates. Strict field validation and before/after change reporting are preserved.
This intentionally introduces replacement semantics for all supported resource types, including omitted metadata and data fields. Kubernetes defaults and validation still apply, and writes require create/update permissions.
Adds regression coverage for field removal across ownership histories, full-object replacement, resource versions, error propagation, and idempotent reapplication.