Skip to content

feat(gcp): observe on the applier's transport, not through a cluster (#1209) - #1375

Merged
lex00 merged 1 commit into
mainfrom
feat/1209-gcp-native-observer
Aug 3, 2026
Merged

lex00 merged 1 commit into
mainfrom
feat/1209-gcp-native-observer

Conversation

@lex00

@lex00 lex00 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

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().getUrl the 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_NAMES plus per-kind GCP_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. restToCnrmShape maps identity and labels to metadata, everything else to spec — 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 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 can't be applied either, so observing it produced a live tree nothing could reconcile against. Anything outside the table reports 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 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

…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
@lex00
lex00 merged commit 7f4e985 into main Aug 3, 2026
5 checks passed
@lex00
lex00 deleted the feat/1209-gcp-native-observer branch August 3, 2026 03:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(gcp): native observer -- direct-REST -> floci-gcp

1 participant