Skip to content

Commit 64d5608

Browse files
committed
fix: add selector to shared dataplane Service for reliable endpoint discovery
The infrastructure reconciler creates the shared dataplane Service without a selector and manages EndpointSlices directly via node snapshot version matching. When the dataplane has not acknowledged the current snapshot version, no EndpointSlices are created, leaving the Service without endpoints and blocking Gateway convergence indefinitely. Add the DataplaneSelector (app: nantian-gw-dataplane) to the shared Service spec so the Kubernetes EndpointSlice controller creates endpoints independently. Foreign EndpointSlices are no longer deleted for the shared Service, allowing them to serve as a fallback when managed slices are not yet ready. This fixes Gateway Programmed=False with 'Waiting for derived frontend EndpointSlices to converge' on fresh deployments.
1 parent eb12748 commit 64d5608

4 files changed

Lines changed: 11 additions & 5 deletions

File tree

internal/infrastructure/reconciler.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,10 @@ func (r *Reconciler) reconcileSharedService(
359359
); err != nil {
360360
return err
361361
}
362-
return deleteFrontendEndpointSlices(ctx, r.client, state.foreignSlices[serviceID])
362+
// Foreign EndpointSlices (e.g. created by the Kubernetes EndpointSlice controller
363+
// when the shared Service has a selector) are kept as a fallback; they ensure the
364+
// Service has endpoints even when the dataplane snapshot version has not converged.
365+
return nil
363366
}
364367

365368
func (r *Reconciler) reconcileGatewayServices(

internal/infrastructure/reconciler_core_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ func TestReconcileCreatesGatewayInfrastructureServiceAndUpdatesSharedPorts(t *te
111111
if shared.Spec.Type != corev1.ServiceTypeNodePort {
112112
t.Fatalf("shared service type = %s, want NodePort", shared.Spec.Type)
113113
}
114-
if shared.Spec.Selector != nil {
115-
t.Fatalf("shared service selector = %#v, want nil with managed EndpointSlices", shared.Spec.Selector)
114+
if shared.Spec.Selector == nil || shared.Spec.Selector["app"] != "nantian-gw-dataplane" {
115+
t.Fatalf("shared service selector = %#v, want map[app:nantian-gw-dataplane]", shared.Spec.Selector)
116116
}
117117
assertServicePort(t, shared.Spec.Ports, 80, corev1.ProtocolTCP, 30080)
118118
assertServicePort(t, shared.Spec.Ports, 8080, corev1.ProtocolTCP, 32080)

internal/infrastructure/reconciler_mesh_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -970,8 +970,8 @@ func TestReconcileFrontsSharedAndGatewayServicesOnlyWithAckedCurrentSnapshotNode
970970
if err != nil {
971971
t.Fatalf("Get shared Service returned error: %v", err)
972972
}
973-
if sharedService.Spec.Selector != nil {
974-
t.Fatalf("shared service selector = %#v, want nil with managed EndpointSlices", sharedService.Spec.Selector)
973+
if sharedService.Spec.Selector == nil || sharedService.Spec.Selector["app"] != "nantian-gw-dataplane" {
974+
t.Fatalf("shared service selector = %#v, want map[app:nantian-gw-dataplane]", sharedService.Spec.Selector)
975975
}
976976

977977
gatewayService, err := mustGetService(

internal/infrastructure/services.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ func desiredSharedService(
5959
desired.Spec.SessionAffinity = current.Spec.SessionAffinity
6060
}
6161

62+
if len(options.DataplaneSelector) > 0 {
63+
desired.Spec.Selector = options.DataplaneSelector
64+
}
6265
desired.Spec.Ports = assignSharedNodePorts(mergeServicePorts(current.Spec.Ports, ports, true))
6366
return desired
6467
}

0 commit comments

Comments
 (0)