Skip to content

feat(client)!: write the status with server-side apply - #1354

Merged
kimpenhaus merged 1 commit into
mainfrom
feat/status-apply
Nov 27, 2026
Merged

kimpenhaus merged 1 commit into
mainfrom
feat/status-apply

Conversation

@kimpenhaus

Copy link
Copy Markdown
Collaborator

Summary

UpdateStatusAsync replaced the status with a PUT. The request carried the resourceVersion and failed with 409 Conflict whenever the resource had changed in the meantime, e.g. its spec, and the field manager owned the whole status.

UpdateStatusAsync now writes the status with server-side apply, without a new method:

  • The apply configuration contains apiVersion, kind, metadata.name, metadata.namespace (if any) and status, and goes to the /status subresource.
  • It carries no resourceVersion, so an outdated entity no longer fails with 409. The spec and the status fields that are not sent stay as they are.
  • force: true, as the Kubernetes docs recommend for controllers ("It is strongly recommended for controllers to always force conflicts on objects that they own and manage"). Without it, the first write after the upgrade would conflict with the operator's own Update entry from the PUT.
  • The field manager comes from the client, as for every other write: the FieldManagerHandler of the operator, or the one passed to new KubernetesClient(config, fieldManager). There is no fallback; without a field manager the API server rejects the apply.

Supersedes #1351, which added PatchStatusAsync overloads instead.

Breaking change

  • UpdateStatusAsync no longer fails with 409 on an outdated entity.
  • It needs a field manager. Within an operator with the default IKubernetes nothing changes; an own IKubernetes needs the FieldManagerHandler (already documented since 14.1); a KubernetesClient outside an operator needs to be created with a field manager.
  • Status fields written before the upgrade stay with the Update entry of the PUT until they are sent again.

All documented in migration.mdx (v15).

Tests

  • KubernetesClient.UpdateStatus.Test.cs: path with ?force=true, application/apply-patch+yaml, and the apply configuration for namespaced and cluster-scoped entities.
  • KubernetesClient.FieldManager.Test.cs: the status write is now a PATCH with the field manager.
  • KubernetesClient.UpdateStatus.Integration.Test.cs (cluster): an outdated entity is written without 409, the spec change of the other writer is kept, and managedFields shows Apply on status. Two existing integration tests now use a client with a field manager. Not run locally (no cluster), runs in CI.

Docs

migration.mdx, troubleshooting.mdx (409 only for UpdateAsync), field-manager.mdx, KubeOps.KubernetesClient README.

Reviews

  • /code-review: the reconcile pipeline already loads the entity fresh before each reconcile and skips a recreated object (EntityQueueBackgroundService), so a stale status is limited to a running reconcile. Documented the upgrade case (fields owned by the old Update entry) and the own-IKubernetes case. Not changed: core group types (/apis//v1/..., pre-existing, tracked in the roadmap); a type with a null status applies an empty status.
  • /simplify and /security-review by hand: no new type or method; name and namespace are escaped path parameters of the official client, the body is a JsonObject; force only affects fields of our own status, and the generated RBAC rule for <plural>/status already contains patch.

Note: migration.mdx, field-manager.mdx and the client README are also changed by #1348; whichever merges second needs a small rebase, which I will do.

UpdateStatusAsync replaced the status with a PUT that carried the resourceVersion and failed with 409 Conflict whenever the resource had changed, e.g. its spec. It now sends apiVersion, kind, name, namespace and the status as a server-side apply to the /status subresource, without the resourceVersion and with force, as recommended for controllers. It uses the field manager of the client; an operator sets it.

BREAKING CHANGE: UpdateStatusAsync no longer fails with 409 Conflict on an outdated entity, and it needs a field manager. A KubernetesClient outside an operator that writes the status has to be created with one, e.g. new KubernetesClient(config, "my-tool").
@kimpenhaus
kimpenhaus merged commit af55fb8 into main Nov 27, 2026
7 checks passed
@kimpenhaus
kimpenhaus deleted the feat/status-apply branch November 27, 2026 15:29
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 15.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant