mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	@@ -449,16 +449,15 @@ func (e *Controller) syncService(ctx context.Context, key string) error {
 | 
			
		||||
	// See if there's actually an update here.
 | 
			
		||||
	currentEndpoints, err := e.endpointsLister.Endpoints(service.Namespace).Get(service.Name)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		if errors.IsNotFound(err) {
 | 
			
		||||
		if !errors.IsNotFound(err) {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
		currentEndpoints = &v1.Endpoints{
 | 
			
		||||
			ObjectMeta: metav1.ObjectMeta{
 | 
			
		||||
				Name:   service.Name,
 | 
			
		||||
				Labels: service.Labels,
 | 
			
		||||
			},
 | 
			
		||||
		}
 | 
			
		||||
		} else {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	createEndpoints := len(currentEndpoints.ResourceVersion) == 0
 | 
			
		||||
@@ -604,13 +603,12 @@ func addEndpointSubset(subsets []v1.EndpointSubset, pod *v1.Pod, epa v1.Endpoint
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func endpointPortFromServicePort(servicePort *v1.ServicePort, portNum int) *v1.EndpointPort {
 | 
			
		||||
	epp := &v1.EndpointPort{
 | 
			
		||||
	return &v1.EndpointPort{
 | 
			
		||||
		Name:        servicePort.Name,
 | 
			
		||||
		Port:        int32(portNum),
 | 
			
		||||
		Protocol:    servicePort.Protocol,
 | 
			
		||||
		AppProtocol: servicePort.AppProtocol,
 | 
			
		||||
	}
 | 
			
		||||
	return epp
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// capacityAnnotationSetCorrectly returns false if number of endpoints is greater than maxCapacity or
 | 
			
		||||
 
 | 
			
		||||
@@ -317,15 +317,16 @@ func (c *Controller) syncService(key string) error {
 | 
			
		||||
 | 
			
		||||
	service, err := c.serviceLister.Services(namespace).Get(name)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		if apierrors.IsNotFound(err) {
 | 
			
		||||
		if !apierrors.IsNotFound(err) {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		c.triggerTimeTracker.DeleteService(namespace, name)
 | 
			
		||||
		c.reconciler.deleteService(namespace, name)
 | 
			
		||||
		c.endpointSliceTracker.DeleteService(namespace, name)
 | 
			
		||||
		// The service has been deleted, return nil so that it won't be retried.
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if service.Spec.Selector == nil {
 | 
			
		||||
		// services without a selector receive no endpoint slices from this controller;
 | 
			
		||||
 
 | 
			
		||||
@@ -781,7 +781,10 @@ func TestPodOrphaningAndAdoptionWhenLabelsChange(t *testing.T) {
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			// If the pod is not found, it means the RS picks the pod for deletion (it is extra)
 | 
			
		||||
			// Verify there is only one pod in namespace and it has ControllerRef to the RS
 | 
			
		||||
			if apierrors.IsNotFound(err) {
 | 
			
		||||
			if !apierrors.IsNotFound(err) {
 | 
			
		||||
				return false, err
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			pods := getPods(t, podClient, labelMap())
 | 
			
		||||
			if len(pods.Items) != 1 {
 | 
			
		||||
				return false, fmt.Errorf("Expected 1 pod in current namespace, got %d", len(pods.Items))
 | 
			
		||||
@@ -790,8 +793,6 @@ func TestPodOrphaningAndAdoptionWhenLabelsChange(t *testing.T) {
 | 
			
		||||
			pod = &pods.Items[0]
 | 
			
		||||
			return true, nil
 | 
			
		||||
		}
 | 
			
		||||
			return false, err
 | 
			
		||||
		}
 | 
			
		||||
		// Always update the pod so that we can save a GET call to API server later
 | 
			
		||||
		pod = newPod
 | 
			
		||||
		// If the pod is found, verify the pod has a ControllerRef
 | 
			
		||||
 
 | 
			
		||||
@@ -682,7 +682,10 @@ func TestPodOrphaningAndAdoptionWhenLabelsChange(t *testing.T) {
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			// If the pod is not found, it means the RC picks the pod for deletion (it is extra)
 | 
			
		||||
			// Verify there is only one pod in namespace and it has ControllerRef to the RC
 | 
			
		||||
			if apierrors.IsNotFound(err) {
 | 
			
		||||
			if !apierrors.IsNotFound(err) {
 | 
			
		||||
				return false, err
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			pods := getPods(t, podClient, labelMap())
 | 
			
		||||
			if len(pods.Items) != 1 {
 | 
			
		||||
				return false, fmt.Errorf("Expected 1 pod in current namespace, got %d", len(pods.Items))
 | 
			
		||||
@@ -691,8 +694,6 @@ func TestPodOrphaningAndAdoptionWhenLabelsChange(t *testing.T) {
 | 
			
		||||
			pod = &pods.Items[0]
 | 
			
		||||
			return true, nil
 | 
			
		||||
		}
 | 
			
		||||
			return false, err
 | 
			
		||||
		}
 | 
			
		||||
		// Always update the pod so that we can save a GET call to API server later
 | 
			
		||||
		pod = newPod
 | 
			
		||||
		// If the pod is found, verify the pod has a ControllerRef
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user