Skip to content

Commit eee317d

Browse files
Techassisbernauer
andauthored
fix(webhook): Force apply the CRD in the CRD maintainer (#1116)
* fix: Force apply the CRD in the CRD maintainer This ensures the operator will be the sole manager of the CRD (and all its fields) going forward. This avoids running into conflicts when CRDs were previously deployed by helm or stackablectl. * chore: Add changelog entry * chore: Apply suggestion Co-authored-by: Sebastian Bernauer <[email protected]> --------- Co-authored-by: Sebastian Bernauer <[email protected]>
1 parent 089ff8d commit eee317d

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

crates/stackable-webhook/CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7+
### Fixed
8+
9+
- Force apply the CRD in the CRD maintainer ([#1116]).
10+
11+
This ensures the operator will be the sole manager of the CRD (and all its fields) going forward.
12+
This avoids running into conflicts when CRDs were previously deployed by helm or stackablectl.
13+
14+
[#1116]: https://github.com/stackabletech/operator-rs/pull/1116
15+
716
## [0.7.0] - 2025-10-16
817

918
### Added

crates/stackable-webhook/src/maintainer.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,27 @@ impl<'a> CustomResourceDefinitionMaintainer<'a> {
213213

214214
// Deploy the updated CRDs using a server-side apply.
215215
let patch = Patch::Apply(&crd);
216-
let patch_params = PatchParams::apply(field_manager);
216+
217+
// We force apply here, because we want to become the sole manager of the CRD. This
218+
// avoids any conflicts from previous deployments via helm or stackablectl which are
219+
// reported with the following error message:
220+
//
221+
// Apply failed with 2 conflicts: conflicts with "stackablectl" using apiextensions.k8s.io/v1:
222+
// - .spec.versions
223+
// - .spec.conversion.strategy: Conflict
224+
//
225+
// The official Kubernetes documentation provides three options on how to solve
226+
// these conflicts. Option 1 is used, which is described as follows:
227+
//
228+
// Overwrite value, become sole manager: If overwriting the value was intentional
229+
// (or if the applier is an automated process like a controller) the applier should
230+
// set the force query parameter to true [...], and make the request again. This
231+
// forces the operation to succeed, changes the value of the field, and removes the
232+
// field from all other managers' entries in managedFields.
233+
//
234+
// See https://kubernetes.io/docs/reference/using-api/server-side-apply/#conflicts
235+
let patch_params = PatchParams::apply(field_manager).force();
236+
217237
crd_api
218238
.patch(&crd_name, &patch_params, &patch)
219239
.await

0 commit comments

Comments
 (0)