mirror of https://github.com/k3s-io/k3s
Merge pull request #57642 from lichuqiang/serviceEvent
Automatic merge from submit-queue (batch tested with PRs 58517, 57642). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Fix event message when processing loadbalancer update **What this PR does / why we need it**: When a service get updated, in func [processServiceUpdate](https://github.com/kubernetes/kubernetes/blob/master/pkg/controller/service/service_controller.go#L249), we process its LB accordingly, that is, create one if the service requests and no corresponding loadbalancer exists; and delete potential orphaned load balancer if the service does not need it any more. But if a service does not `wantsLoadBalancer` but get error when trying to `GetLoadBalancer`, user could find an event in format of "CreatingLoadBalancerFailed..."[here](https://github.com/kubernetes/kubernetes/blob/master/pkg/controller/service/service_controller.go#L261), which would confusing users. So we should generate event info according to service type. **Special notes for your reviewer**: /sig network **Release note**: ```release-note NONE ```pull/6/head
commit
6ec4cb107e
|
@ -250,7 +250,14 @@ func (s *ServiceController) processServiceUpdate(cachedService *cachedService, s
|
||||||
cachedService.state = service
|
cachedService.state = service
|
||||||
err := s.createLoadBalancerIfNeeded(key, service)
|
err := s.createLoadBalancerIfNeeded(key, service)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.eventRecorder.Eventf(service, v1.EventTypeWarning, "CreatingLoadBalancerFailed", "Error creating load balancer (will retry): %v", err)
|
eventType := "CreatingLoadBalancerFailed"
|
||||||
|
message := "Error creating load balancer (will retry): "
|
||||||
|
if !wantsLoadBalancer(service) {
|
||||||
|
eventType = "CleanupLoadBalancerFailed"
|
||||||
|
message = "Error cleaning up load balancer (will retry): "
|
||||||
|
}
|
||||||
|
message += err.Error()
|
||||||
|
s.eventRecorder.Event(service, v1.EventTypeWarning, eventType, message)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// Always update the cache upon success.
|
// Always update the cache upon success.
|
||||||
|
|
Loading…
Reference in New Issue