Setting Hostname from Pods on EndpointSlice to match Endpoints behavior.

This was an oversight in the initial EndpointSlice release. This update
will ensure that Endpoints and EndpointSlices use the same logic to set
the Hostname attribute.
This commit is contained in:
Rob Scott
2019-10-22 15:39:49 -07:00
parent f7c3fa8324
commit 0c7548f020
8 changed files with 151 additions and 38 deletions

View File

@@ -427,11 +427,10 @@ func (e *EndpointController) syncService(key string) error {
klog.V(2).Infof("failed to find endpoint for service:%v with ClusterIP:%v on pod:%v with error:%v", service.Name, service.Spec.ClusterIP, pod.Name, err)
continue
}
epa := *ep
hostname := pod.Spec.Hostname
if len(hostname) > 0 && pod.Spec.Subdomain == service.Name && service.Namespace == pod.Namespace {
epa.Hostname = hostname
epa := *ep
if endpointutil.ShouldSetHostname(pod, service) {
epa.Hostname = pod.Spec.Hostname
}
// Allow headless service not to have ports.