Repository navigation
feat(gcp): observe on the applier's transport, not through a cluster (#1209) - #1375
Merged
Merged
Conversation
…1209) GCP applied cluster-free over direct REST (#706) and observed through a Config Connector cluster — `kubectl get <cnrm-gvk> -o json` per entity, on both read paths. That is the split #1085's principle forbids: a lexicon observed on a different transport than it is applied with can disagree with itself about what a resource is, and needed a GKE cluster to answer a question about a bucket. Both paths now read GCP's own REST APIs. Every GET is built by the same `ResourceMapper.plan().getUrl` the applier writes through, so reader and applier are structurally incapable of disagreeing about where a resource lives. ## The transport was the easy half Three things had to be re-answered, not re-pointed. **Noise, without managed fields.** The deep reader pruned by CNRM's `metadata.managedFields` — Kubernetes records which manager owns which field, so everything the CNRM controller owned was subtracted before diffing. A GCP payload never says who wrote a field. The replacement is a static table in the shape aws and azure already use: `GCP_READ_ONLY_NAMES` for server-assigned fields, `GCP_SERVICE_DEFAULTS` for per-kind defaults subtracted only where source never declared them. Hand-maintained, which is the honest cost — a server field nobody listed reads as drift until it is listed, and that is visible and fixable where an over-broad rule silently hides real drift. **The hooks were all CNRM-shaped.** Audited every rule that was there: the k8s object envelope, CNRM's observed-state annotations, k8s list-map ordering. Not one matches anything in a REST payload. Replaced wholesale rather than trimmed. **The two trees had different shapes.** Source declares Config Connector resources — `{metadata:{name}, spec:{location}}` — and REST returns `{name, location}`. Diffing one against the other makes every field drift twice. Verified against floci-gcp before the fix: a bucket matching its declaration exactly reported SEVEN property drifts, all of them shape. chant has met this before — #1207 records the same thing for AWS, where Cloud Control lines up for free and the EC2 API does not. `restToCnrmShape` maps identity and labels to `metadata` and everything else to `spec`, which is CNRM's own convention rather than a per-kind table that would be a second place to forget a field. Also: chant's own ownership labels are no longer reported as drift, the correction #1301 made for AWS once the emulator started applying tags. ## Verified live on floci-gcp 0.5.0 With a booby-trapped `kubectl` first on PATH that exits 97 if anything spawns it. It never fired. clean apply 0 property drift (was 7 before the shape fix) out-of-band spec.storageClass: NEARLINE -> COLDLINE ## Coverage, stated rather than implied Reads reach the kinds the applier has a mapper for. kubectl could fetch any CNRM kind the cluster knew about, so this is narrower on paper and not in practice: a kind with no mapper cannot be applied either, so observing it produced a live tree nothing could reconcile against. Anything outside the table reports NOT-OBSERVED with `unsupported-kind` rather than being dropped. `--owned` degrades to detect-only for kinds whose payload carries no labels (a Pub/Sub topic has none), rather than withholding what it cannot prove — the same posture the AWS thin path takes when describe-stack-resources returns no tags. 429 gcp tests pass; the repo's typecheck baseline is unchanged at 91 pre-existing errors (#1366). Closes #1209 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FBkcXzqjyY1YKWdaDFuqKs
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1209 — O·gcp, the heaviest of the three O slots. Unblocks D·gcp and behold#101.
GCP applied cluster-free over direct REST (#706) and observed through a Config Connector cluster, on both read paths. That's the split #1085's principle forbids — and it meant needing a GKE cluster to answer a question about a bucket.
Both paths now read GCP's own REST APIs, with every GET built by the same
ResourceMapper.plan().getUrlthe applier writes through. Reader and applier are structurally incapable of disagreeing about where a resource lives.The transport was the easy half
Three things had to be re-answered, not re-pointed:
1. Noise, without managed fields. The deep reader pruned by CNRM's
metadata.managedFields— Kubernetes records which manager owns which field. A GCP payload never says who wrote a field. Replaced with a static table in the shape aws and azure already use:GCP_READ_ONLY_NAMESplus per-kindGCP_SERVICE_DEFAULTS, subtracted only where source never declared them. Hand-maintained, which is the honest cost — an unlisted server field reads as drift until listed, and that's visible and fixable where an over-broad rule silently hides real drift.2. Every hook was CNRM-shaped. Audited all of them — the k8s object envelope, CNRM observed-state annotations, k8s list-map ordering. Not one matches anything in a REST payload. Replaced wholesale.
3. The two trees had different shapes. This is the one I didn't expect. Source declares Config Connector resources (
{metadata:{name}, spec:{location}}); REST returns{name, location}. Diffing one against the other makes every field drift twice. Verified on floci-gcp before fixing: a bucket matching its declaration exactly reported 7 property drifts, all of them shape.chant has met this before — #1207 records it for AWS, where Cloud Control lines up for free and the EC2 API doesn't.
restToCnrmShapemaps identity and labels tometadata, everything else tospec— CNRM's own convention, rather than a per-kind table that would be a second place to forget a field.Also: chant's own ownership labels no longer read as drift, the correction #1301 made for AWS.
Verified live on floci-gcp 0.5.0
With a booby-trapped
kubectlfirst onPATHthat exits 97 if anything spawns it. It never fired.Coverage, stated rather than implied
Reads reach the kinds the applier has a mapper for. kubectl could fetch any CNRM kind the cluster knew about, so this is narrower on paper and not in practice: a kind with no mapper can't be applied either, so observing it produced a live tree nothing could reconcile against. Anything outside the table reports
unsupported-kindrather than being dropped.--owneddegrades to detect-only for kinds whose payload carries no labels (a Pub/Sub topic has none) rather than withholding what it can't prove — the same posture the AWS thin path takes.429 gcp tests pass. Repo typecheck baseline unchanged at 91 pre-existing errors (#1366).
🤖 Generated with Claude Code
https://claude.ai/code/session_01FBkcXzqjyY1YKWdaDFuqKs