@@ -139,7 +139,7 @@ func New(
139
139
UpdateFunc : func (old , cur interface {}) {
140
140
oldSvc , ok1 := old .(* v1.Service )
141
141
curSvc , ok2 := cur .(* v1.Service )
142
- if ok1 && ok2 && (s . needsUpdate (oldSvc , curSvc ) || needsCleanup (curSvc )) {
142
+ if ok1 && ok2 && (needsUpdate (oldSvc , curSvc ) || needsCleanup (curSvc )) {
143
143
s .enqueueService (cur )
144
144
}
145
145
},
@@ -552,19 +552,17 @@ func needsCleanup(service *v1.Service) bool {
552
552
}
553
553
554
554
// needsUpdate checks if load balancer needs to be updated due to change in attributes.
555
- func ( c * Controller ) needsUpdate (oldService * v1.Service , newService * v1.Service ) bool {
555
+ func needsUpdate (oldService * v1.Service , newService * v1.Service ) bool {
556
556
if ! wantsLoadBalancer (oldService ) && ! wantsLoadBalancer (newService ) {
557
557
return false
558
558
}
559
559
if wantsLoadBalancer (oldService ) != wantsLoadBalancer (newService ) {
560
- c .eventRecorder .Eventf (newService , v1 .EventTypeNormal , "Type" , "%v -> %v" ,
561
- oldService .Spec .Type , newService .Spec .Type )
560
+ klog .V (2 ).Infof ("Service %s wants load balancer changed from %s to %s" , klog .KObj (oldService ), oldService .Spec .Type , newService .Spec .Type )
562
561
return true
563
562
}
564
563
565
564
if wantsLoadBalancer (newService ) && ! reflect .DeepEqual (oldService .Spec .LoadBalancerSourceRanges , newService .Spec .LoadBalancerSourceRanges ) {
566
- c .eventRecorder .Eventf (newService , v1 .EventTypeNormal , "LoadBalancerSourceRanges" , "%v -> %v" ,
567
- oldService .Spec .LoadBalancerSourceRanges , newService .Spec .LoadBalancerSourceRanges )
565
+ klog .V (2 ).Infof ("Service %s LoadBalancerSourceRanges changed from %v to %v" , klog .KObj (newService ), oldService .Spec .LoadBalancerSourceRanges , newService .Spec .LoadBalancerSourceRanges )
568
566
return true
569
567
}
570
568
@@ -576,47 +574,40 @@ func (c *Controller) needsUpdate(oldService *v1.Service, newService *v1.Service)
576
574
return true
577
575
}
578
576
if ! loadBalancerIPsAreEqual (oldService , newService ) {
579
- c .eventRecorder .Eventf (newService , v1 .EventTypeNormal , "LoadbalancerIP" , "%v -> %v" ,
580
- oldService .Spec .LoadBalancerIP , newService .Spec .LoadBalancerIP )
577
+ klog .V (2 ).Infof ("Service %s LoadBalancerIP changed from %s to %s" , klog .KObj (newService ), oldService .Spec .LoadBalancerIP , newService .Spec .LoadBalancerIP )
581
578
return true
582
579
}
583
580
if len (oldService .Spec .ExternalIPs ) != len (newService .Spec .ExternalIPs ) {
584
- c .eventRecorder .Eventf (newService , v1 .EventTypeNormal , "ExternalIP" , "Count: %v -> %v" ,
585
- len (oldService .Spec .ExternalIPs ), len (newService .Spec .ExternalIPs ))
581
+ klog .V (2 ).Infof ("Service %s ExternalIPs' count changed from %v to %v" , klog .KObj (newService ), len (oldService .Spec .ExternalIPs ), len (newService .Spec .ExternalIPs ))
586
582
return true
587
583
}
588
584
for i := range oldService .Spec .ExternalIPs {
589
585
if oldService .Spec .ExternalIPs [i ] != newService .Spec .ExternalIPs [i ] {
590
- c .eventRecorder .Eventf (newService , v1 .EventTypeNormal , "ExternalIP" , "Added: %v" ,
591
- newService .Spec .ExternalIPs [i ])
586
+ klog .V (2 ).Infof ("Service %s ExternalIPs[%d] changed from %v to %v" , klog .KObj (newService ), i , oldService .Spec .ExternalIPs [i ], newService .Spec .ExternalIPs [i ])
592
587
return true
593
588
}
594
589
}
595
590
if ! reflect .DeepEqual (oldService .Annotations , newService .Annotations ) {
596
591
return true
597
592
}
598
593
if oldService .UID != newService .UID {
599
- c .eventRecorder .Eventf (newService , v1 .EventTypeNormal , "UID" , "%v -> %v" ,
600
- oldService .UID , newService .UID )
594
+ klog .V (2 ).Infof ("Service %s UID changed from %s to %s" , klog .KObj (newService ), oldService .UID , newService .UID )
601
595
return true
602
596
}
603
597
if oldService .Spec .ExternalTrafficPolicy != newService .Spec .ExternalTrafficPolicy {
604
- c .eventRecorder .Eventf (newService , v1 .EventTypeNormal , "ExternalTrafficPolicy" , "%v -> %v" ,
605
- oldService .Spec .ExternalTrafficPolicy , newService .Spec .ExternalTrafficPolicy )
598
+ klog .V (2 ).Infof ("Service %s ExternalTrafficPolicy changed from %s to %s" , klog .KObj (newService ), oldService .Spec .ExternalTrafficPolicy , newService .Spec .ExternalTrafficPolicy )
606
599
return true
607
600
}
608
601
if oldService .Spec .HealthCheckNodePort != newService .Spec .HealthCheckNodePort {
609
- c .eventRecorder .Eventf (newService , v1 .EventTypeNormal , "HealthCheckNodePort" , "%v -> %v" ,
610
- oldService .Spec .HealthCheckNodePort , newService .Spec .HealthCheckNodePort )
602
+ klog .V (2 ).Infof ("Service %s HealthCheckNodePort changed from %v to %v" , klog .KObj (newService ), oldService .Spec .HealthCheckNodePort , newService .Spec .HealthCheckNodePort )
611
603
return true
612
604
}
613
605
614
606
// User can upgrade (add another clusterIP or ipFamily) or can downgrade (remove secondary clusterIP or ipFamily),
615
607
// but CAN NOT change primary/secondary clusterIP || ipFamily UNLESS they are changing from/to/ON ExternalName
616
608
// so not care about order, only need check the length.
617
609
if len (oldService .Spec .IPFamilies ) != len (newService .Spec .IPFamilies ) {
618
- c .eventRecorder .Eventf (newService , v1 .EventTypeNormal , "IPFamilies" , "Count: %v -> %v" ,
619
- len (oldService .Spec .IPFamilies ), len (newService .Spec .IPFamilies ))
610
+ klog .V (2 ).Infof ("Service %s IPFamilies' count changed from %d to %d" , klog .KObj (newService ), len (oldService .Spec .IPFamilies ), len (newService .Spec .IPFamilies ))
620
611
return true
621
612
}
622
613
0 commit comments