mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 12:18:16 +00:00 
			
		
		
		
	Remove EndpointSliceNodeName feature gate logic
- feature gate has graduated to GA and will always be enabled, so no longer need to check if enabled
This commit is contained in:
		@@ -45,10 +45,6 @@ func podToEndpoint(pod *corev1.Pod, node *corev1.Node, service *corev1.Service,
 | 
				
			|||||||
	// zone, and region, but this will be expanded in the future.
 | 
						// zone, and region, but this will be expanded in the future.
 | 
				
			||||||
	topology := map[string]string{}
 | 
						topology := map[string]string{}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if pod.Spec.NodeName != "" {
 | 
					 | 
				
			||||||
		topology["kubernetes.io/hostname"] = pod.Spec.NodeName
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if node != nil {
 | 
						if node != nil {
 | 
				
			||||||
		topologyLabels := []string{
 | 
							topologyLabels := []string{
 | 
				
			||||||
			"topology.kubernetes.io/zone",
 | 
								"topology.kubernetes.io/zone",
 | 
				
			||||||
@@ -72,7 +68,6 @@ func podToEndpoint(pod *corev1.Pod, node *corev1.Node, service *corev1.Service,
 | 
				
			|||||||
		Conditions: discovery.EndpointConditions{
 | 
							Conditions: discovery.EndpointConditions{
 | 
				
			||||||
			Ready: &ready,
 | 
								Ready: &ready,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		Topology: topology,
 | 
					 | 
				
			||||||
		TargetRef: &corev1.ObjectReference{
 | 
							TargetRef: &corev1.ObjectReference{
 | 
				
			||||||
			Kind:            "Pod",
 | 
								Kind:            "Pod",
 | 
				
			||||||
			Namespace:       pod.ObjectMeta.Namespace,
 | 
								Namespace:       pod.ObjectMeta.Namespace,
 | 
				
			||||||
@@ -87,7 +82,10 @@ func podToEndpoint(pod *corev1.Pod, node *corev1.Node, service *corev1.Service,
 | 
				
			|||||||
		ep.Conditions.Terminating = &terminating
 | 
							ep.Conditions.Terminating = &terminating
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if pod.Spec.NodeName != "" && utilfeature.DefaultFeatureGate.Enabled(features.EndpointSliceNodeName) {
 | 
						if pod.Spec.NodeName != "" {
 | 
				
			||||||
 | 
							topology["kubernetes.io/hostname"] = pod.Spec.NodeName
 | 
				
			||||||
 | 
							ep.Topology = topology
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		ep.NodeName = &pod.Spec.NodeName
 | 
							ep.NodeName = &pod.Spec.NodeName
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -27,12 +27,10 @@ import (
 | 
				
			|||||||
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 | 
						metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 | 
				
			||||||
	"k8s.io/apimachinery/pkg/runtime/schema"
 | 
						"k8s.io/apimachinery/pkg/runtime/schema"
 | 
				
			||||||
	utilruntime "k8s.io/apimachinery/pkg/util/runtime"
 | 
						utilruntime "k8s.io/apimachinery/pkg/util/runtime"
 | 
				
			||||||
	utilfeature "k8s.io/apiserver/pkg/util/feature"
 | 
					 | 
				
			||||||
	"k8s.io/client-go/tools/cache"
 | 
						"k8s.io/client-go/tools/cache"
 | 
				
			||||||
	"k8s.io/client-go/tools/leaderelection/resourcelock"
 | 
						"k8s.io/client-go/tools/leaderelection/resourcelock"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/apis/discovery/validation"
 | 
						"k8s.io/kubernetes/pkg/apis/discovery/validation"
 | 
				
			||||||
	endpointutil "k8s.io/kubernetes/pkg/controller/util/endpoint"
 | 
						endpointutil "k8s.io/kubernetes/pkg/controller/util/endpoint"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/features"
 | 
					 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// addrTypePortMapKey is used to uniquely identify groups of endpoint ports and
 | 
					// addrTypePortMapKey is used to uniquely identify groups of endpoint ports and
 | 
				
			||||||
@@ -140,10 +138,8 @@ func addressToEndpoint(address corev1.EndpointAddress, ready bool) *discovery.En
 | 
				
			|||||||
		endpoint.Topology = map[string]string{
 | 
							endpoint.Topology = map[string]string{
 | 
				
			||||||
			"kubernetes.io/hostname": *address.NodeName,
 | 
								"kubernetes.io/hostname": *address.NodeName,
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if utilfeature.DefaultFeatureGate.Enabled(features.EndpointSliceNodeName) {
 | 
					 | 
				
			||||||
		endpoint.NodeName = address.NodeName
 | 
							endpoint.NodeName = address.NodeName
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if address.Hostname != "" {
 | 
						if address.Hostname != "" {
 | 
				
			||||||
		endpoint.Hostname = &address.Hostname
 | 
							endpoint.Hostname = &address.Hostname
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -18,15 +18,14 @@ package reconcilers
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"context"
 | 
						"context"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	corev1 "k8s.io/api/core/v1"
 | 
						corev1 "k8s.io/api/core/v1"
 | 
				
			||||||
	discovery "k8s.io/api/discovery/v1beta1"
 | 
						discovery "k8s.io/api/discovery/v1beta1"
 | 
				
			||||||
	apiequality "k8s.io/apimachinery/pkg/api/equality"
 | 
						apiequality "k8s.io/apimachinery/pkg/api/equality"
 | 
				
			||||||
	"k8s.io/apimachinery/pkg/api/errors"
 | 
						"k8s.io/apimachinery/pkg/api/errors"
 | 
				
			||||||
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 | 
						metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 | 
				
			||||||
	utilfeature "k8s.io/apiserver/pkg/util/feature"
 | 
					 | 
				
			||||||
	corev1client "k8s.io/client-go/kubernetes/typed/core/v1"
 | 
						corev1client "k8s.io/client-go/kubernetes/typed/core/v1"
 | 
				
			||||||
	discoveryclient "k8s.io/client-go/kubernetes/typed/discovery/v1beta1"
 | 
						discoveryclient "k8s.io/client-go/kubernetes/typed/discovery/v1beta1"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/features"
 | 
					 | 
				
			||||||
	utilnet "k8s.io/utils/net"
 | 
						utilnet "k8s.io/utils/net"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -178,10 +177,8 @@ func endpointFromAddress(address corev1.EndpointAddress, ready bool) discovery.E
 | 
				
			|||||||
		ep.Topology = map[string]string{
 | 
							ep.Topology = map[string]string{
 | 
				
			||||||
			"kubernetes.io/hostname": *address.NodeName,
 | 
								"kubernetes.io/hostname": *address.NodeName,
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if utilfeature.DefaultFeatureGate.Enabled(features.EndpointSliceNodeName) {
 | 
					 | 
				
			||||||
		ep.NodeName = address.NodeName
 | 
							ep.NodeName = address.NodeName
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return ep
 | 
						return ep
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -23,13 +23,11 @@ import (
 | 
				
			|||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
	"sync"
 | 
						"sync"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"k8s.io/api/core/v1"
 | 
						v1 "k8s.io/api/core/v1"
 | 
				
			||||||
	discovery "k8s.io/api/discovery/v1beta1"
 | 
						discovery "k8s.io/api/discovery/v1beta1"
 | 
				
			||||||
	"k8s.io/apimachinery/pkg/types"
 | 
						"k8s.io/apimachinery/pkg/types"
 | 
				
			||||||
	utilfeature "k8s.io/apiserver/pkg/util/feature"
 | 
					 | 
				
			||||||
	"k8s.io/client-go/tools/record"
 | 
						"k8s.io/client-go/tools/record"
 | 
				
			||||||
	"k8s.io/klog/v2"
 | 
						"k8s.io/klog/v2"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/features"
 | 
					 | 
				
			||||||
	utilproxy "k8s.io/kubernetes/pkg/proxy/util"
 | 
						utilproxy "k8s.io/kubernetes/pkg/proxy/util"
 | 
				
			||||||
	utilnet "k8s.io/utils/net"
 | 
						utilnet "k8s.io/utils/net"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
@@ -136,9 +134,7 @@ func newEndpointSliceInfo(endpointSlice *discovery.EndpointSlice, remove bool) *
 | 
				
			|||||||
				Terminating: endpoint.Conditions.Terminating != nil && *endpoint.Conditions.Terminating,
 | 
									Terminating: endpoint.Conditions.Terminating != nil && *endpoint.Conditions.Terminating,
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if utilfeature.DefaultFeatureGate.Enabled(features.EndpointSliceNodeName) {
 | 
					 | 
				
			||||||
			epInfo.NodeName = endpoint.NodeName
 | 
								epInfo.NodeName = endpoint.NodeName
 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
			esInfo.Endpoints = append(esInfo.Endpoints, epInfo)
 | 
								esInfo.Endpoints = append(esInfo.Endpoints, epInfo)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -105,14 +105,10 @@ func (endpointSliceStrategy) AllowUnconditionalUpdate() bool {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// dropDisabledConditionsOnCreate will drop any fields that are disabled.
 | 
					// dropDisabledConditionsOnCreate will drop any fields that are disabled.
 | 
				
			||||||
func dropDisabledFieldsOnCreate(endpointSlice *discovery.EndpointSlice) {
 | 
					func dropDisabledFieldsOnCreate(endpointSlice *discovery.EndpointSlice) {
 | 
				
			||||||
	dropNodeName := !utilfeature.DefaultFeatureGate.Enabled(features.EndpointSliceNodeName)
 | 
					 | 
				
			||||||
	dropTerminating := !utilfeature.DefaultFeatureGate.Enabled(features.EndpointSliceTerminatingCondition)
 | 
						dropTerminating := !utilfeature.DefaultFeatureGate.Enabled(features.EndpointSliceTerminatingCondition)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if dropNodeName || dropTerminating {
 | 
						if dropTerminating {
 | 
				
			||||||
		for i := range endpointSlice.Endpoints {
 | 
							for i := range endpointSlice.Endpoints {
 | 
				
			||||||
			if dropNodeName {
 | 
					 | 
				
			||||||
				endpointSlice.Endpoints[i].NodeName = nil
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			if dropTerminating {
 | 
								if dropTerminating {
 | 
				
			||||||
				endpointSlice.Endpoints[i].Conditions.Serving = nil
 | 
									endpointSlice.Endpoints[i].Conditions.Serving = nil
 | 
				
			||||||
				endpointSlice.Endpoints[i].Conditions.Terminating = nil
 | 
									endpointSlice.Endpoints[i].Conditions.Terminating = nil
 | 
				
			||||||
@@ -124,16 +120,6 @@ func dropDisabledFieldsOnCreate(endpointSlice *discovery.EndpointSlice) {
 | 
				
			|||||||
// dropDisabledFieldsOnUpdate will drop any disable fields that have not already
 | 
					// dropDisabledFieldsOnUpdate will drop any disable fields that have not already
 | 
				
			||||||
// been set on the EndpointSlice.
 | 
					// been set on the EndpointSlice.
 | 
				
			||||||
func dropDisabledFieldsOnUpdate(oldEPS, newEPS *discovery.EndpointSlice) {
 | 
					func dropDisabledFieldsOnUpdate(oldEPS, newEPS *discovery.EndpointSlice) {
 | 
				
			||||||
	dropNodeName := !utilfeature.DefaultFeatureGate.Enabled(features.EndpointSliceNodeName)
 | 
					 | 
				
			||||||
	if dropNodeName {
 | 
					 | 
				
			||||||
		for _, ep := range oldEPS.Endpoints {
 | 
					 | 
				
			||||||
			if ep.NodeName != nil {
 | 
					 | 
				
			||||||
				dropNodeName = false
 | 
					 | 
				
			||||||
				break
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	dropTerminating := !utilfeature.DefaultFeatureGate.Enabled(features.EndpointSliceTerminatingCondition)
 | 
						dropTerminating := !utilfeature.DefaultFeatureGate.Enabled(features.EndpointSliceTerminatingCondition)
 | 
				
			||||||
	if dropTerminating {
 | 
						if dropTerminating {
 | 
				
			||||||
		for _, ep := range oldEPS.Endpoints {
 | 
							for _, ep := range oldEPS.Endpoints {
 | 
				
			||||||
@@ -144,11 +130,8 @@ func dropDisabledFieldsOnUpdate(oldEPS, newEPS *discovery.EndpointSlice) {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if dropNodeName || dropTerminating {
 | 
						if dropTerminating {
 | 
				
			||||||
		for i := range newEPS.Endpoints {
 | 
							for i := range newEPS.Endpoints {
 | 
				
			||||||
			if dropNodeName {
 | 
					 | 
				
			||||||
				newEPS.Endpoints[i].NodeName = nil
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			if dropTerminating {
 | 
								if dropTerminating {
 | 
				
			||||||
				newEPS.Endpoints[i].Conditions.Serving = nil
 | 
									newEPS.Endpoints[i].Conditions.Serving = nil
 | 
				
			||||||
				newEPS.Endpoints[i].Conditions.Terminating = nil
 | 
									newEPS.Endpoints[i].Conditions.Terminating = nil
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user