From 2f9cd08831c802b7755741d1b48cc7b6c0494a2c Mon Sep 17 00:00:00 2001 From: "Khaled (Kal) Henidak" Date: Thu, 19 Aug 2021 23:06:17 +0000 Subject: [PATCH] fix 104329: check for headless before trying to release the ClusterIPs --- pkg/registry/core/service/storage/rest.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pkg/registry/core/service/storage/rest.go b/pkg/registry/core/service/storage/rest.go index 313a41417eb..d2cd8cc9a17 100644 --- a/pkg/registry/core/service/storage/rest.go +++ b/pkg/registry/core/service/storage/rest.go @@ -759,6 +759,12 @@ func (rs *REST) handleClusterIPsForUpdatedService(oldService *api.Service, servi } // CASE B: + + // if headless service then we bail out early (no clusterIPs management needed) + if len(oldService.Spec.ClusterIPs) > 0 && oldService.Spec.ClusterIPs[0] == api.ClusterIPNone { + return nil, nil, nil + } + // Update service from non-ExternalName to ExternalName, should release ClusterIP if exists. if oldService.Spec.Type != api.ServiceTypeExternalName && service.Spec.Type == api.ServiceTypeExternalName { toRelease = make(map[api.IPFamily]string) @@ -775,11 +781,6 @@ func (rs *REST) handleClusterIPsForUpdatedService(oldService *api.Service, servi return nil, toRelease, nil } - // if headless service then we bail out early (no clusterIPs management needed) - if len(oldService.Spec.ClusterIPs) > 0 && oldService.Spec.ClusterIPs[0] == api.ClusterIPNone { - return nil, nil, nil - } - // upgrade and downgrade are specific to dualstack if !utilfeature.DefaultFeatureGate.Enabled(features.IPv6DualStack) { return nil, nil, nil