mirror of
				https://github.com/k3s-io/kubernetes.git
				synced 2025-10-30 21:30:16 +00:00 
			
		
		
		
	cleanup: remove duplicate import
Signed-off-by: Abirdcfly <fp544037857@gmail.com>
This commit is contained in:
		| @@ -20,8 +20,7 @@ import ( | ||||
| 	"fmt" | ||||
| 	"time" | ||||
|  | ||||
| 	corev1 "k8s.io/api/core/v1" | ||||
| 	v1 "k8s.io/api/core/v1" | ||||
| 	"k8s.io/api/core/v1" | ||||
| 	discovery "k8s.io/api/discovery/v1" | ||||
| 	apiequality "k8s.io/apimachinery/pkg/api/equality" | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| @@ -33,7 +32,7 @@ import ( | ||||
| 	"k8s.io/klog/v2" | ||||
| 	podutil "k8s.io/kubernetes/pkg/api/v1/pod" | ||||
| 	api "k8s.io/kubernetes/pkg/apis/core" | ||||
| 	helper "k8s.io/kubernetes/pkg/apis/core/v1/helper" | ||||
| 	"k8s.io/kubernetes/pkg/apis/core/v1/helper" | ||||
| 	"k8s.io/kubernetes/pkg/apis/discovery/validation" | ||||
| 	endpointutil "k8s.io/kubernetes/pkg/controller/util/endpoint" | ||||
| 	"k8s.io/kubernetes/pkg/features" | ||||
| @@ -41,7 +40,7 @@ import ( | ||||
| ) | ||||
|  | ||||
| // podToEndpoint returns an Endpoint object generated from a Pod, a Node, and a Service for a particular addressType. | ||||
| func podToEndpoint(pod *corev1.Pod, node *corev1.Node, service *corev1.Service, addressType discovery.AddressType) discovery.Endpoint { | ||||
| func podToEndpoint(pod *v1.Pod, node *v1.Node, service *v1.Service, addressType discovery.AddressType) discovery.Endpoint { | ||||
| 	serving := podutil.IsPodReady(pod) | ||||
| 	terminating := pod.DeletionTimestamp != nil | ||||
| 	// For compatibility reasons, "ready" should never be "true" if a pod is terminatng, unless | ||||
| @@ -52,7 +51,7 @@ func podToEndpoint(pod *corev1.Pod, node *corev1.Node, service *corev1.Service, | ||||
| 		Conditions: discovery.EndpointConditions{ | ||||
| 			Ready: &ready, | ||||
| 		}, | ||||
| 		TargetRef: &corev1.ObjectReference{ | ||||
| 		TargetRef: &v1.ObjectReference{ | ||||
| 			Kind:      "Pod", | ||||
| 			Namespace: pod.ObjectMeta.Namespace, | ||||
| 			Name:      pod.ObjectMeta.Name, | ||||
| @@ -69,8 +68,8 @@ func podToEndpoint(pod *corev1.Pod, node *corev1.Node, service *corev1.Service, | ||||
| 		ep.NodeName = &pod.Spec.NodeName | ||||
| 	} | ||||
|  | ||||
| 	if node != nil && node.Labels[corev1.LabelTopologyZone] != "" { | ||||
| 		zone := node.Labels[corev1.LabelTopologyZone] | ||||
| 	if node != nil && node.Labels[v1.LabelTopologyZone] != "" { | ||||
| 		zone := node.Labels[v1.LabelTopologyZone] | ||||
| 		ep.Zone = &zone | ||||
| 	} | ||||
|  | ||||
| @@ -83,7 +82,7 @@ func podToEndpoint(pod *corev1.Pod, node *corev1.Node, service *corev1.Service, | ||||
|  | ||||
| // getEndpointPorts returns a list of EndpointPorts generated from a Service | ||||
| // and Pod. | ||||
| func getEndpointPorts(service *corev1.Service, pod *corev1.Pod) []discovery.EndpointPort { | ||||
| func getEndpointPorts(service *v1.Service, pod *v1.Pod) []discovery.EndpointPort { | ||||
| 	endpointPorts := []discovery.EndpointPort{} | ||||
|  | ||||
| 	// Allow headless service not to have ports. | ||||
| @@ -115,7 +114,7 @@ func getEndpointPorts(service *corev1.Service, pod *corev1.Pod) []discovery.Endp | ||||
| } | ||||
|  | ||||
| // getEndpointAddresses returns a list of addresses generated from a pod status. | ||||
| func getEndpointAddresses(podStatus corev1.PodStatus, service *corev1.Service, addressType discovery.AddressType) []string { | ||||
| func getEndpointAddresses(podStatus v1.PodStatus, service *v1.Service, addressType discovery.AddressType) []string { | ||||
| 	addresses := []string{} | ||||
|  | ||||
| 	for _, podIP := range podStatus.PodIPs { | ||||
| @@ -134,7 +133,7 @@ func getEndpointAddresses(podStatus corev1.PodStatus, service *corev1.Service, a | ||||
|  | ||||
| // newEndpointSlice returns an EndpointSlice generated from a service and | ||||
| // endpointMeta. | ||||
| func newEndpointSlice(service *corev1.Service, endpointMeta *endpointMeta) *discovery.EndpointSlice { | ||||
| func newEndpointSlice(service *v1.Service, endpointMeta *endpointMeta) *discovery.EndpointSlice { | ||||
| 	gvk := schema.GroupVersionKind{Version: "v1", Kind: "Service"} | ||||
| 	ownerRef := metav1.NewControllerRef(service, gvk) | ||||
| 	epSlice := &discovery.EndpointSlice{ | ||||
| @@ -166,7 +165,7 @@ func getEndpointSlicePrefix(serviceName string) string { | ||||
|  | ||||
| // ownedBy returns true if the provided EndpointSlice is owned by the provided | ||||
| // Service. | ||||
| func ownedBy(endpointSlice *discovery.EndpointSlice, svc *corev1.Service) bool { | ||||
| func ownedBy(endpointSlice *discovery.EndpointSlice, svc *v1.Service) bool { | ||||
| 	for _, o := range endpointSlice.OwnerReferences { | ||||
| 		if o.UID == svc.UID && o.Kind == "Service" && o.APIVersion == "v1" { | ||||
| 			return true | ||||
| @@ -222,9 +221,9 @@ func addTriggerTimeAnnotation(endpointSlice *discovery.EndpointSlice, triggerTim | ||||
| 	} | ||||
|  | ||||
| 	if !triggerTime.IsZero() { | ||||
| 		endpointSlice.Annotations[corev1.EndpointsLastChangeTriggerTime] = triggerTime.UTC().Format(time.RFC3339Nano) | ||||
| 		endpointSlice.Annotations[v1.EndpointsLastChangeTriggerTime] = triggerTime.UTC().Format(time.RFC3339Nano) | ||||
| 	} else { // No new trigger time, clear the annotation. | ||||
| 		delete(endpointSlice.Annotations, corev1.EndpointsLastChangeTriggerTime) | ||||
| 		delete(endpointSlice.Annotations, v1.EndpointsLastChangeTriggerTime) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @@ -244,7 +243,7 @@ func serviceControllerKey(endpointSlice *discovery.EndpointSlice) (string, error | ||||
| // setEndpointSliceLabels returns a map with the new endpoint slices labels and true if there was an update. | ||||
| // Slices labels must be equivalent to the Service labels except for the reserved IsHeadlessService, LabelServiceName and LabelManagedBy labels | ||||
| // Changes to IsHeadlessService, LabelServiceName and LabelManagedBy labels on the Service do not result in updates to EndpointSlice labels. | ||||
| func setEndpointSliceLabels(epSlice *discovery.EndpointSlice, service *corev1.Service) (map[string]string, bool) { | ||||
| func setEndpointSliceLabels(epSlice *discovery.EndpointSlice, service *v1.Service) (map[string]string, bool) { | ||||
| 	updated := false | ||||
| 	epLabels := make(map[string]string) | ||||
| 	svcLabels := make(map[string]string) | ||||
| @@ -308,7 +307,7 @@ func (sl endpointSliceEndpointLen) Less(i, j int) bool { | ||||
| } | ||||
|  | ||||
| // returns a map of address types used by a service | ||||
| func getAddressTypesForService(service *corev1.Service) map[discovery.AddressType]struct{} { | ||||
| func getAddressTypesForService(service *v1.Service) map[discovery.AddressType]struct{} { | ||||
| 	serviceSupportedAddresses := make(map[discovery.AddressType]struct{}) | ||||
| 	// TODO: (khenidak) when address types are removed in favor of | ||||
| 	// v1.IPFamily this will need to be removed, and work directly with | ||||
| @@ -317,11 +316,11 @@ func getAddressTypesForService(service *corev1.Service) map[discovery.AddressTyp | ||||
| 	// IMPORTANT: we assume that IP of (discovery.AddressType enum) is never in use | ||||
| 	// as it gets deprecated | ||||
| 	for _, family := range service.Spec.IPFamilies { | ||||
| 		if family == corev1.IPv4Protocol { | ||||
| 		if family == v1.IPv4Protocol { | ||||
| 			serviceSupportedAddresses[discovery.AddressTypeIPv4] = struct{}{} | ||||
| 		} | ||||
|  | ||||
| 		if family == corev1.IPv6Protocol { | ||||
| 		if family == v1.IPv6Protocol { | ||||
| 			serviceSupportedAddresses[discovery.AddressTypeIPv6] = struct{}{} | ||||
| 		} | ||||
| 	} | ||||
| @@ -345,7 +344,7 @@ func getAddressTypesForService(service *corev1.Service) map[discovery.AddressTyp | ||||
| 	// this ensures that traffic is not disrupted  until then. But *may* | ||||
| 	// include undesired families for headless services until then. | ||||
|  | ||||
| 	if len(service.Spec.ClusterIP) > 0 && service.Spec.ClusterIP != corev1.ClusterIPNone { // headfull | ||||
| 	if len(service.Spec.ClusterIP) > 0 && service.Spec.ClusterIP != v1.ClusterIPNone { // headfull | ||||
| 		addrType := discovery.AddressTypeIPv4 | ||||
| 		if utilnet.IsIPv6String(service.Spec.ClusterIP) { | ||||
| 			addrType = discovery.AddressTypeIPv6 | ||||
| @@ -385,9 +384,9 @@ func unchangedSlices(existingSlices, slicesToUpdate, slicesToDelete []*discovery | ||||
| } | ||||
|  | ||||
| // hintsEnabled returns true if the provided annotations include a | ||||
| // corev1.AnnotationTopologyAwareHints key with a value set to "Auto" or "auto". | ||||
| // v1.AnnotationTopologyAwareHints key with a value set to "Auto" or "auto". | ||||
| func hintsEnabled(annotations map[string]string) bool { | ||||
| 	val, ok := annotations[corev1.AnnotationTopologyAwareHints] | ||||
| 	val, ok := annotations[v1.AnnotationTopologyAwareHints] | ||||
| 	if !ok { | ||||
| 		return false | ||||
| 	} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user