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