feat(agent): add CRD gate implementation and tests#3839
Conversation
- Introduce `crdGate` to enhance CRD processing with conditional resources - Implement CRD gate tests including eligibility checks and wait strategies - Enhance database store with CRD establishment tracking - Update insert and update logic to include CRD establishment field
Soffi AI SummaryThis PR introduces a CRD gate mechanism in the deployment operator's streamline applier to solve a multi-pass problem: when a service deployment contains both CRD definitions and Custom Resource (CR) instances, the CRs cannot be applied until the CRDs are fully established in the Kubernetes API server. Without gating, a single-pass apply would fail because the API server doesn't yet recognize the new resource types. The CRD gate (
Complementary changes include: a new Commits
Updated: 2026-07-16 12:50 UTC |
Greptile SummaryThis PR introduces a
Confidence Score: 5/5Safe to merge; gate logic, schema change, and profiling wrappers are all correct with thorough test coverage. The new crdGate correctly identifies only newly-applied CRDs as gate candidates, deduplicates concurrent waits, and uses an exact UID match so a watch row from a deleted-and-re-created CRD cannot spuriously unblock the gate. The established column is backward-compatible. The variadic spread fix eliminates a real SQL argument mismatch. The resolve function in crd_gate.go has a minor error-message cosmetic issue but no logic defects.
|
| Filename | Overview |
|---|---|
| go/deployment-operator/pkg/streamline/applier/crd_gate.go | New CRD gate that deduplicates REST-mapping waits via singleflight; error message in resolve always says "timed out" even on cancellation, and duplicates the error string when no backoff iterations ran. |
| go/deployment-operator/pkg/streamline/applier/applier.go | Gate wiring added before SyncServiceComponents so GetAppliedComponent correctly reads previous-cycle state; import ordering and gate option building look correct. |
| go/deployment-operator/pkg/streamline/store/db_store.go | Adds IsCRDEstablished with exact UID+name match; SaveComponent and SaveComponents now track the established column consistently. |
| go/deployment-operator/pkg/streamline/store/db_queries.go | Adds established column (NOT NULL DEFAULT 0) and getCRDEstablished query; setComponentWithSHA and setComponentUnsynced updated consistently. |
| go/deployment-operator/pkg/streamline/applier/wave.go | Gate slice, WithWaveGates option, runGates, gatesEnabled, and pre/post-apply gate invocations all added cleanly; clientForMapping refactored out of clientForResource. |
| go/deployment-operator/pkg/common/crd.go | New shared CRD utilities (IsCRD, CRDEstablished, ServedCRDGVKs) extracted to common package; correctly removes the duplicate crdGK var from template/common.go. |
Reviews (4): Last reviewed commit: "Merge remote-tracking branch 'origin/mas..." | Re-trigger Greptile
…message - Adjust error message formatting to properly nest error details
- Reorder imports for better readability and maintainability - Fix variadic argument usage in `SaveComponentAttributes` function
…-services-with-crds-and-cr-instances-need-multiple-passes-to
|
@greptileai ignore Go's |
crdGateto enhance CRD processing with conditional resourcesTest Plan
Test environment: https://console.plrl-dev-aws.onplural.sh/
Checklist
Plural Flow: console