You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit b1c6da9
Browse filesBrowse the repository at this point in the historyBrowse files
CM-1040: Extract shared ApplyResource helper and migrate istiocsr to SSA
- Adds common.ApplyResource[T]() in pkg/controller/common/applier.go
- Migrates trustmanager's 11 createOrApply methods to the shared helper
- Migrates istiocsr's 8 simple createOrApply methods from Create/UpdateWithRetry
to SSA via the shared helper
- Uses SSA with force ownership for both creation and drift correction; when a
drift-correction apply fails (SSA cannot replace a granular list entry whose
key fields were drifted - Service spec.ports is keyed by port and protocol),
falls back to a JSON merge patch, which replaces lists wholesale
- Handles RoleBinding roleRef immutability with delete-and-recreate, shared by
both istiocsr RoleBindings in applyRoleBinding
- Adds CtrlClient.Apply, which server-side applies through client.Client.Apply
(converting the typed object to an unstructured apply configuration and
copying the response back), replacing the deprecated Patch(obj, client.Apply)
in ApplyResource and the trustmanager default CA package ConfigMap
- Updates AGENTS.md and the harness docs (ADR-0002, components, testing and
controller guidelines, istiocsr/trustmanager domain docs) for the mixed
istiocsr apply strategy and the Apply-based SSA call and fake assertions
- Net -402 lines of non-test controller code (duplicated reconciliation boilerplate)
Includes unit tests for:
- ApplyResource (create, no-op, drift via SSA, merge-patch fallback on apply
failure, both-writes-fail error, Exists error, apply error, write type per
branch)
- Network policy asset decoding and apply
- CtrlClient wrapper methods (Exists, Get, Create, Update, Delete, List,
UpdateWithRetry with conflict retry, Patch, Apply, StatusUpdate)
- ApplyResource drift correction against a real API server (test/apis,
envtest): port drift on a list-map key field, label drift, annotation
pruning, no-op
Co-authored-by: Cursor <cursoragent@cursor.com>
1.**Never assume uniform SSA** — CertManager library-go; IstioCSR Create+`UpdateWithRetry`; TrustManager only SSA + field owner `trust-manager-controller`. [components.md](harness-evals/harness-docs/architecture/components.md)
28
+
1.**Never assume uniform SSA** — CertManager library-go; IstioCSR mixed (SSA via `common.ApplyResource` for Service/SA/Certificate/Role/RoleBinding/NetworkPolicy; Create+`UpdateWithRetry` for Deployment, CA ConfigMap, ClusterRole/Binding); TrustManager all SSA + field owner `trust-manager-controller`. [components.md](harness-evals/harness-docs/architecture/components.md)
4.**Feature gates** — `--unsupported-addon-features`; five touchpoints; no cluster FeatureSet for TrustManager (CM-1141). [ADR-0003](harness-evals/harness-docs/decisions/adr-0003-feature-gates.md)
32
32
5.**Ignore**`certmanager_controller.go` placeholder — RBAC markers only, never started.
A TrustManager test asserting `UpdateCallCount`(or IstioCSR asserting `PatchCallCount`) is the wrong path even if green. Regenerate fakes with `make generate-fakes` after changing `CtrlClient` — never hand-edit `pkg/controller/common/fakes/`.
23
+
A test asserting `UpdateCallCount`for an SSA resource, or `ApplyCallCount` for a Create/Update resource, is the wrong path even if green. `PatchCallCount` only counts the JSON merge-patch fallback `ApplyResource` uses when a drift-correcting apply fails. Regenerate fakes with `make generate-fakes` after changing `CtrlClient` — never hand-edit `pkg/controller/common/fakes/`.
2. IstioCSR uses SSA via `common.ApplyResource` for Service, ServiceAccount, Certificate, Role/RoleBinding and NetworkPolicy. Deployment, CA ConfigMap and ClusterRole/ClusterRoleBinding (generated names tracked in status) keep Create+Update until explicitly migrated.
18
+
3.**New controller-runtime operand reconcilers must follow TrustManager SSA** (`common.ApplyResource` → `CtrlClient.Apply` + `FieldOwner` + `ForceOwnership`, with a JSON merge-patch fallback when a drift-correcting apply fails).
18
19
4. Status updates for IstioCSR/TrustManager may still use `UpdateWithRetry` on the CR object.
19
20
20
21
## Consequences
@@ -34,10 +35,11 @@ Documenting a single “we use SSA everywhere” claim is a known hallucination
Copy file name to clipboardExpand all lines: harness-evals/harness-docs/domain/istiocsr.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@
10
10
11
11
Deploys and configures the **cert-manager-istio-csr** operand so Istio mesh workloads can obtain certificates via cert-manager issuers.
12
12
13
-
**Key Principle**: Enabled by operator feature gate `IstioCSR` (GA, default **true**) via `--unsupported-addon-features`. Controller uses**Create + UpdateWithRetry**, not SSA.
13
+
**Key Principle**: Enabled by operator feature gate `IstioCSR` (GA, default **true**) via `--unsupported-addon-features`. Controller is**mixed**: SSA via `common.ApplyResource` for most resources, Create + `UpdateWithRetry` for the rest (see Apply below).
0 commit comments