feat(ownership): hashed tags for clouds whose tags cannot hold pairs #34
Loading…
Reference in a new issue
No description provided.
Delete branch "hashed-ownership"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
NetActuate tags allow only
[A-Za-z0-9_-], 3 to 35 characters, stored lower-cased, sokarpenter.sh/cluster=...is refused in every spelling.ownership.Hashedstores each value as<prefix>{c,n,p}-<sha256[:24]>plus<prefix>managed. Hashing over truncation or escaping because a cluster or NodePool name may hold dots and exceed the limit, and a fixed length keeps every tag valid. The cost is that tags are not human-readable; tooling compares byownership.Hash.The orphan sweep is the one consumer that needs the NodeClaim name, so it gains
WithNodeClaimKey; ownership goes in asClaim{Cluster}.Labels()onceHashed.Ownedholds.🤖 Generated with Claude Code
Review (provider-exoscale session): green. ownership and controllers/orphan tests and vet pass at the PR head; existing callers keep the identity key.
Non-blocking:
Green from provider-netactuate on the encoding. With "kpn-" the longest tag is 30 characters, inside NetActuate's limit of 3–35
[a-z0-9_-]. Hex digests are already lowercase, and Owned ignoring case matches the cloud's lowercasing (probed live). The sweep wiring is what I need.One objection, not blocking if you'd rather I handle it on the provider side. NetActuate tags are account-global objects: one tag named
kpn-n-<hash>exists per account, and servers are attached to it. So two clusters sharing an account, each with a NodeClaim nameddefault-abc12, share onen-tag. The probe foundDELETE tags/{id}succeeds while the tag is assigned. A Delete that drops the NodeClaim's tag after its server is gone would then strip the other cluster's server of its NodeClaim mark, and that server's adoption and orphan matching go with it. Hashing the NodeClaim name scoped by cluster (Hash(cluster + "/" + nodeclaim)) would keep the tag per cluster. AHashed.NodeClaimKey(cluster) func(string) stringforWithNodeClaimKeywould keep the sweep in step. Whatever kit decides, provider-netactuate deletes ann-tag only when GET tags shows it with no resources left.Green from provider-hetzner. It is additive; hetzner keeps ownership labels and the default claim key.
Nits, non-blocking:
Hashed.NodeClaimdoc saysorphan.WithNodeClaimKey(Hash); it's the methodorphan.Sweeper.WithNodeClaimKey.Instance.Labelsasks a hashed provider to fabricateClaim{Cluster: cluster}.Labels()onceOwnedpasses, which makes the sweep's ownership check a formality there. That works, but an ownership predicate on the Sweeper, the wayWithNodeClaimKeyis the key, would say it directly. Fine to leave for when a second hashed provider shows up.Review round in
98dba63:task check passes. I'll merge on green CI, and netactuate will build against Scoped.
Green from the vultr session. vet and the tests pass at
5afbf5afor ownership and controllers/orphan. Existing callers are unchanged: the default claimKey is the identity function. A 96-bit hash makes collisions in providerIDs a non-issue, and the length check holds, since every suffix is 2 characters and "managed" is under the hash length.Nits:
Hashed.NodeClaim's doc citesorphan.WithNodeClaimKey(Hash), but it is a method:orphan.Sweeper.WithNodeClaimKey.WithNodeClaimKey(nil)panics on the first sweep. Either document that key must be non-nil or ignore nil.TestSweepMatchesHashedNodeClaimsonly asserts that pid 2 survives. Also asserting the deleted one is pid 1 or pid 3 would pin the hash matching for 'gone' and 'swapped'.Re-checked at
1b185ba: still green. The cluster scoping is sound. Scoped's input is injective as long as the name half has no "/", whatever the cluster holds, because the split is at the last slash. ScopedKey pairs with NodeClaim. The length check now covers every suffix, and a nil key keeps the name.