cluster-operator icon indicating copy to clipboard operation
cluster-operator copied to clipboard

Refactor updates to `spec` to use patches and Server-Side Apply (SSA)

Open Zerpet opened this issue 7 months ago • 1 comments

Summary

The operator currently updates spec fields in the RabbitmqCluster custom resource using full Update() calls, and in some cases performs updates even when no change is needed. This can:

  • Cause unnecessary updates
  • Take field ownership from users or tools such as Helm (see issue #2098)
  • Lead to conflicts, especially with fields that have both int and string representations (e.g., resource quantities)

Proposal

  • Refactor all operator logic updating spec to use targeted patches with Server-Side Apply (SSA)
  • Assign granular field ownership (with appropriate fieldManager names) only to the fields the operator is responsible for
  • Avoid taking ownership of fields the operator does not intend to manage
  • Update only fields that truly need to change, bypassing updates when the desired and current state are identical

Benefits

  • Minimizes risk of SSA and Helm/Argo conflicts
  • Ensures clean and predictable field ownership
  • Reduces risk of breaking user expectations by overwriting fields
  • Streamlines and documents proper patch and field ownership usage for contributors

Context

This change follows the lessons from issue #2098 (SSA conflicts on Helm upgrades) and recommendations emerging from recent code and process discussions. See Kubernetes documentation on Server-Side Apply for reference.


See also: "Move defaulting logic to a mutating webhook" (separate proposal for admission-time defaults).

Zerpet avatar Apr 28 '26 11:04 Zerpet

Hi, I’m considering contributing to the remaining scope here after #2151 moved defaulting into the webhook. The image-enforcement code still updates the whole RabbitmqCluster resource, including when enforcing the Vault helper’s image. I haven’t yet tested whether these updates cause conflicts with Helm or other tools.

Before committing to an implementation, I’d like to clarify the intended scope:

  1. Would image enforcement be a useful first slice of this issue, and is anyone already working on it?
  2. Should disabling enforcement preserve the current images while releasing operator ownership? Separately, removing Vault needs to leave its subtree absent; an operator-owned image may prevent SSA omission alone from doing that. Is there an existing removal workflow to preserve?
  3. Should releasing unrelated fields held by the old update manager be part of the first change, or would a documented migration procedure be acceptable?

ajavanma avatar Sep 24 '26 11:09 ajavanma