Skip to content

feat(edge): Admit EdgeListeners and report their backends - #1521

Merged
privateip merged 12 commits into
fix/issue-1509-ingressfrom
fix/issue-1509-admission
Nov 29, 2026
Merged

privateip merged 12 commits into
fix/issue-1509-ingressfrom
fix/issue-1509-admission

Conversation

@privateip

@privateip privateip commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Each refusal reason appears for the case that causes it, and clears once the cause is fixed
  • A project service on the same address never blocks a listener, and a service the gateway refused claims nothing
  • An instance whose lease stops renewing stops serving when the lease expires
  • CI passes

Related to #1509

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
@privateip privateip self-assigned this Nov 29, 2026
@privateip
privateip added this pull request to stack #1524 November 29, 2026 03:43
# 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
@privateip

Copy link
Copy Markdown
Contributor Author

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.

@privateip
privateip marked this pull request as ready for review November 29, 2026 04:55
@privateip
privateip requested a review from a team as a code owner November 29, 2026 04:55
@privateip
privateip requested a review from scotwells November 29, 2026 04:55

@scotwells scotwells left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 keeps serving=true and Programmed=True indefinitely. 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 with VIPOutsidePool. A tenant who creates a NetworkService on the listener's VIP and port before the listener exists gets the listener refused with AddressClaimed. Match the gateway's own precedence, where the gateway namespace wins and refused services claim nothing.

Smaller points:

  • checkGrant ignores the EdgeService's own Admitted condition. A refused grant still reads Accepted=True, then shows NoBackends.
  • edgelisteners/status only needs patch, not update.
  • The controller watches EdgeListener whenever --edge is 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
@privateip

Copy link
Copy Markdown
Contributor Author

All six points are addressed at 702fc07.

  • A backend now serves only until its lease's renew time plus duration, less the clock skew allowance, and core requeues at the earliest expiry. The provider contract said those fields were never read, and it is corrected.
  • Claims now follow the gateway's precedence. A project-namespace service never claims against a listener, and a service the gateway refused claims nothing. One deliberate difference: between two gateway-namespace services the gateway serves both, so core keeps refusing the newer listener rather than letting two services program one address.
  • A listener whose EdgeService is not admitted for its current generation is refused with CapabilityNotGranted.
  • The Role grants only patch on edgelisteners/status.
  • Core checks discovery for EdgeListener at startup and skips the listener controllers when it is not served, so a cell that gets the image first keeps running. The controller docs now say to apply the CRDs and RBAC before the image.
  • Both rules, one listener per EdgeService and the claim precedence, are in the design's Decisions table, marked as proposed and awaiting review. Please sign off on them there or say what to change.

@privateip
privateip requested review from a team and scotwells November 29, 2026 14:09

@ecv ecv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.MaxSkew in instanceHolds: TestListenerLeaseExpiry only 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.NodeName check: 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.ProviderRef check also survives removal, but it is defence in depth: provider writes are pinned to their own provider by the galactic-edge-provider policy, 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 is patch only, 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, Setup also 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
@privateip

Copy link
Copy Markdown
Contributor Author

The points are addressed at 0377f19, and merged up into #1522.

  • TestListenerLeaseExpiry now reads the lease's expiry and requires the backend to stop serving between expiry less MaxSkew and half a skew after that. Without -r.MaxSkew the backend stops about 2 s late, and the test fails.
  • TestListenerBackendInstance puts three attachments behind one instance's lease: one from a replaced pod, one reported on another node and one from another provider. None of them may serve while the instance's own attachment does. The attachment on the other node starts serving once it reports the instance's node. In feat(edge): Advertise serving listener backends to gateways #1522 both nodes get a VRF, so only the instance checks keep these attachments from serving.
  • I checked each guard by removing it and running the test against it. Removing the skew subtraction, the pod check, the node check, both pod and node checks, or the providerRef check each fails its test, on this branch and on feat(edge): Advertise serving listener backends to gateways #1522.
  • When EdgeListener is not served, Setup now logs an error that names both the ingress gVPC and the listener controllers, and the docstring says only a restart starts them.

task ci passes at 0377f19.

The two proposed contract rules still need scotwells to sign off on them in the design's Decisions table.

@privateip
privateip requested a review from ecv November 29, 2026 15:31
ecv
ecv previously approved these changes Nov 29, 2026

@ecv ecv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve.

My hold is addressed at 0377f19:

  • TestListenerLeaseExpiry now reads the lease's expiry and requires the backend to stop between expiry less MaxSkew and half a skew later, so serving until the expiry itself fails it.
  • TestListenerBackendInstance puts 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.

@privateip
privateip requested a review from ecv November 29, 2026 17:08

@ecv ecv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve.

Merge of fix/issue-1509-ingress only, with no conflict; this PR's own commits are unchanged since my last approval.

@scotwells scotwells left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@privateip
privateip merged commit 81e9f5b into main Nov 29, 2026
30 checks passed
@privateip
privateip deleted the fix/issue-1509-admission branch November 29, 2026 21:27
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.

3 participants