Skip to content

Commit 3a70619

Browse files
committed
Include draining endpoints when persistent-drainable
I believe that this is the only place that needs to check for `Serving` Endpoint objects to implement this feature. There are 6 total invocations of `getEndpointsFromSlices` in the repo, all in `controller.go`. 2 of them are relating to `L4Service`. I'm assuming L4 is referring to the OSI model and these seem to relate to TCP and UDP, which have no knowledge of HTTP cookies, which `persistent-drainable` relies on, so these can't be required. (They appear to be for controller level config instead of ingress rules). A third is in `getDefaultUpstream`. My understanding is this is for a fallback service should all of the primary services in the ingress rules be down. This seems like a fallback service handler and not useful for `persistent-drainable`. A fourth one is used in `getBackendServers` when building the `custom-default-backend-` upstream when no Endpoints are available for the service. Again, this doesn't seem intended for the primary application that needs session affinity, so exluding the draining Endpoints in the default backend seems desirable. The last two are used in `serviceEndpoints`, which itself is called in two places, both in `createUpstreams`. One of them is for the default backend service, which discussed above, should not be included. The other one is for our main ingress rules and **is** the one that we want to update.
1 parent 031c5e5 commit 3a70619

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

internal/ingress/controller/controller.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1114,8 +1114,13 @@ func (n *NGINXController) createUpstreams(data []*ingress.Ingress, du *ingress.B
11141114
}
11151115

11161116
if len(upstreams[name].Endpoints) == 0 {
1117+
epSelectionMode := ReadyEndpoints
1118+
if anns.SessionAffinity.Mode == "persistent-drainable" {
1119+
epSelectionMode = ServingEndpoints
1120+
}
1121+
11171122
_, port := upstreamServiceNameAndPort(path.Backend.Service)
1118-
endp, err := n.serviceEndpoints(svcKey, port.String(), ReadyEndpoints)
1123+
endp, err := n.serviceEndpoints(svcKey, port.String(), epSelectionMode)
11191124

11201125
if err != nil {
11211126
klog.Warningf("Error obtaining Endpoints for Service %q: %v", svcKey, err)

0 commit comments

Comments
 (0)