Repository navigation
feat(edge): Admit EdgeListeners and report their backends - #1521
Conversation
Core now reconciles each EdgeListener's status. Accepted is True only while the provider exists, is approved and lists PublicListener at a version core implements (ProviderNotApproved); the EdgeService exists, names the provider, grants SocketAccess and PublicListener on the provider's ingress gVPC, has not expired and serves no older listener (CapabilityNotGranted); every address is in the cell's gateway VIP prefixes (AddressOutsidePool); and nothing older serves an address on one of the listener's protocols and ports (AddressClaimed). The oldest claim wins. An older listener, the NetworkServices of an older listener even while they linger, and any other NetworkService created no later than the listener claim against it. A younger listener's NetworkServices never do, whatever its status, so an older listener that becomes admissible takes its addresses back while the younger refuses itself, instead of both refusing each other while the gateways tear their services down. A listener refused at its current generation holds neither its service nor its addresses against a newer one. status.backends lists the attachments made against the listener's EdgeService. One serves while the listener is accepted and the attachment is Allocated, Programmed and Ready with its placement reported, is Admitted or Draining before its drain deadline, and its instance holds its lease. A backend on a NetworkGateway's node never serves, since a gateway cannot deliver to its own node. Programmed reports BackendsReady, LocalBackendsExcluded or NoBackends, and core decides the listener again at the earliest drain deadline. Listeners outside the gateway namespace are ignored. Lease renewals, EdgeInstance status and NetworkGateway status do not trigger a pass, and instances and leases are read from the cache. The new galactic-controller flag --edge-listener-vip-prefixes gives the cell's gateway VIP prefixes. provider.HoldsLease is the lease test the backends use. Refs #1509
# Conflicts: # docs/controller/README.md
Merging the ingress gVPC tests brought the literal namespace name to the count goconst refuses; the listener tests now share one constant. Refs #1509
|
Review verdicts at head b3b3531: the correctness re-review says merge, and the conventions review held only on the merge commits. The merge commits stay. This stack carries the lower branch up with signed merges and never force-pushes, and the repository lands stacks as merge commits. The re-review settled the other two points. The stack order is ingress, then admission, then publication, then services. The cluster-wide read on listeners is needed because the controller's informer lists cluster-wide, and the admission policy already refuses any listener outside the gateway namespace. |
scotwells
left a comment
There was a problem hiding this comment.
Two problems would let a listener report the wrong state to the gateways that will rely on it.
- A provider that hangs still counts as serving.
HoldsLease(internal/edge/provider/provider.go:316) checks only that the lease names a holder and isn't released. It never checks renew time, and the lease predicate drops renewals, so nothing re-checks once a lease expires. A provider process that hangs without releasing keepsserving=trueandProgrammed=Trueindefinitely. Phase 4 gateways will send traffic to it. Count a backend as serving only while its lease is unexpired, and requeue at the expiry time. - A project namespace can block a platform listener.
claimedBy(internal/edge/listener/admit.go:240) counts every older NetworkService in any namespace, including ones the gateway refused, for example withVIPOutsidePool. A tenant who creates a NetworkService on the listener's VIP and port before the listener exists gets the listener refused withAddressClaimed. Match the gateway's own precedence, where the gateway namespace wins and refused services claim nothing.
Smaller points:
checkGrantignores the EdgeService's ownAdmittedcondition. A refused grant still readsAccepted=True, then showsNoBackends.edgelisteners/statusonly needspatch, notupdate.- The controller watches EdgeListener whenever
--edgeis set. A cell that gets this image before the EdgeListener CRD and RBAC fails its cache sync and exits, taking the cell's webhooks down with it. Ship the CRD and rules in the bundle before the image, or gate the watch on the CRD being present. - One EdgeService serving at most one listener, and the oldest-claim rule between listeners and NetworkServices, are new contract rules the design never settled. They read sensibly, but they need sign-off rather than arriving inside an implementation PR.
A listener backend counted as serving while its instance lease named a holder and was not released, so a provider that hung and stopped renewing kept serving. Nothing looked again either, because renewals do not trigger a pass. A backend now serves only until its lease expires by the wall clock: the Lease's spec.renewTime plus spec.leaseDurationSeconds, both written from the holder's wall clock on every renewal, less the cell's maximum skew, as the grant expiry check does. A Lease that records no duration uses the cell's lease duration. Core decides the listener again at the earliest expiry, and a renewal of an expired lease triggers a pass. The holder's monotonic clock is not used. The provider contract said these Lease fields are never read; it now says core reads them for listener backends only. Refs #1509
claimedBy counted every older NetworkService in any namespace, so a project-namespace service, or one the gateway itself refused, could keep a platform listener refused. It now follows the gateway's precedence (tenantVIPConflicts in internal/controller/servicescope.go): a gateway-namespace service never loses to a project-namespace one, so a project-namespace service never claims against a listener; a service the gateway refused (VIPClaimed, VIPOutsidePool, OwnershipDenied or ProjectServicesOff, on Accepted or a node's Programmed condition) claims nothing; and a gateway-namespace service claims only when it was created no later than the listener. The gateway does not choose between two gateway-namespace services without an address group and serves both, so core keeps refusing the newer listener there. Oldest-wins between listeners is unchanged. Refs #1509
checkGrant read the EdgeService's spec but ignored the service's own Admitted condition, which the EdgeService reconciler sets from its provider, VPC, client pool and expiry. A listener is now refused with CapabilityNotGranted unless its service reports Admitted True for the service's current generation; a condition not yet written, False, or written for an older generation refuses it. Refs #1509
Core writes an EdgeListener's status only by merge patch, so the galactic-controller-edge-listener Role no longer grants get or update on edgelisteners/status. The envtests run under the shipped RBAC. Refs #1509
A controller image with the listener controllers, rolled out before the bundle's CRDs and RBAC, failed its cache sync on the missing EdgeListener kind and exited. listener.Setup now asks discovery whether the API server serves galactic.datumapis.com/v1alpha1 EdgeListener and, when it does not, logs that the public listener controllers are not started and registers neither, leaving the manager to run everything else. The ingress gVPC reconciler is skipped too: its gVPCs serve only listeners, and the Role that grants its VPC writes ships in the same bundle as the CRD. The controller docs now say to apply the bundle's CRDs and RBAC before the image. Refs #1509
Two contract rules came with the listener controllers without sign-off: one EdgeService serves at most one listener, and which claim on a listener address wins. The design's Decisions table now lists both, marked as proposed in this change and awaiting review, each with its reason. Behaviour is unchanged. The table is aligned per the coding conventions. Refs #1509
|
All six points are addressed at 702fc07.
|
ecv
left a comment
There was a problem hiding this comment.
Request changes.
scotwells's two blocking points are fixed in code at 702fc07, but the lease fix and the instance check it relies on are not pinned by any test. Each of these mutants passes the full internal/edge/listener suite with envtest (about 100s each):
- Dropping
-r.MaxSkewininstanceHolds:TestListenerLeaseExpiryonly asserts the listener stops serving within 8s of an 8s lease, so serving into the skew window goes unnoticed. Tighten the bound to duration minus skew, or drive the clock, so the test fails without the subtraction. - Dropping the
inst.Spec.PodUID != att.Spec.PodUID || inst.Spec.NodeName != att.Status.NodeNamecheck: nothing puts an attachment behind an instance of another pod or node and asserts it does not serve. Without it, a replaced pod's attachment can serve on its successor's lease. Add that case.
These are the guards that decide which backend the gateways will send traffic to, so they should be pinned before the stack is wired.
- The
att.Spec.ProviderRef == l.Spec.ProviderRefcheck also survives removal, but it is defence in depth: provider writes are pinned to their own provider by thegalactic-edge-providerpolicy, the attachment spec is immutable, and core refuses an attachment whose provider differs from its service's. A test is still cheap; the other gVPC case in #1522 shows the shape. - The rest looks right: the service grant reads the EdgeService's own
Admitted, a project-namespace service claims an address only as the gateway would, status RBAC ispatchonly, and the controllers skip when the kind is not served. - Agree with scotwells that the two new contract rules (one EdgeService serves at most one listener; oldest claim wins between listeners and NetworkServices) need his sign-off; they are now worded as proposed decisions in
docs/designs/edge-public-listener.md.
Follow-ups:
- When the EdgeListener kind is not served,
Setupalso skips the ingress gVPC reconciler and only a restart recovers. Log it at error level or expose it as a metric.
The guards that decide which backend a listener serves were not pinned: each of these could be removed with the listener suite still passing. - TestListenerLeaseExpiry now reads the lease's expiry and requires the backend to stop serving between expiry less MaxSkew and half a skew later. Serving until the expiry itself, without the skew allowance, now fails. - TestListenerBackendInstance puts three attachments behind one instance's lease: one of a replaced pod, one reported on another node and one of another provider. None may serve, while the instance's own attachment does, and the one on another node serves once it reports its instance's node. The fixture's newBackend is split so a test can create an attachment against an existing instance. Refs #1509
When the API server does not serve EdgeListener, Setup skips both the ingress gVPC and the listener controllers, and only a restart after the CRD is installed starts them. That was logged at info level and named only the listener controllers, so the cell could run without them unnoticed. It is now logged as an error naming both. Refs #1509
|
The points are addressed at 0377f19, and merged up into #1522.
The two proposed contract rules still need scotwells to sign off on them in the design's Decisions table. |
ecv
left a comment
There was a problem hiding this comment.
Approve.
My hold is addressed at 0377f19:
TestListenerLeaseExpirynow reads the lease's expiry and requires the backend to stop between expiry lessMaxSkewand half a skew later, so serving until the expiry itself fails it.TestListenerBackendInstanceputs a replaced pod's attachment, one reported on another node and one of another provider behind one instance's lease, asserts none serves while the instance's own does, and that the moved one serves once back on its instance's node. That pins the pod/node check and the provider check.- Setup now logs an error when the EdgeListener kind is not served.
scotwells's CHANGES_REQUESTED still stands on this PR; the two contract rules are worded as proposed decisions pending his sign-off.
ecv
left a comment
There was a problem hiding this comment.
Approve.
Merge of fix/issue-1509-ingress only, with no conflict; this PR's own commits are unchanged since my last approval.
scotwells
left a comment
There was a problem hiding this comment.
Approved both contract rules: one listener per EdgeService, and the oldest eligible claim wins an address conflict. Project-namespace services and gateway-refused services do not block a listener.
Summary
An operator who writes a public listener today gets no answer on whether it can be served.
Core now checks each listener and says why it was refused: an unapproved provider, a grant its service has not admitted, an address outside the cell's gateway prefixes, or an address and port a gateway service already holds under the gateway's own precedence.
It also lists every provider instance behind the listener, counting one as serving only while it is programmed, ready, within its drain time and holding an unexpired lease.
Two new rules, one listener per service and the claim precedence, are proposed in the design document for sign-off, and core skips all listener work on a cluster that does not serve the listener API yet.
Test plan
Related to #1509