Skip to content

Commit

Permalink
fix ovn lb not updated due to service update failure (#4280)
Browse files Browse the repository at this point in the history
Signed-off-by: zhangzujian <[email protected]>
  • Loading branch information
zhangzujian authored Jul 11, 2024
1 parent 78fe1f9 commit f21c9c3
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions pkg/controller/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,17 +190,6 @@ func (c *Controller) handleUpdateEndpoint(key string) error {
return err
}

if svcVpc = svc.Annotations[util.VpcAnnotation]; svcVpc != vpcName {
if svc.Annotations == nil {
svc.Annotations = make(map[string]string, 1)
}
svc.Annotations[util.VpcAnnotation] = vpcName
if _, err = c.config.KubeClient.CoreV1().Services(namespace).Update(context.Background(), svc, metav1.UpdateOptions{}); err != nil {
klog.Errorf("failed to update service %s: %v", key, err)
return err
}
}

tcpLb, udpLb, sctpLb := vpc.Status.TCPLoadBalancer, vpc.Status.UDPLoadBalancer, vpc.Status.SctpLoadBalancer
oldTCPLb, oldUDPLb, oldSctpLb := vpc.Status.TCPSessionLoadBalancer, vpc.Status.UDPSessionLoadBalancer, vpc.Status.SctpSessionLoadBalancer
if svc.Spec.SessionAffinity == v1.ServiceAffinityClientIP {
Expand Down Expand Up @@ -267,6 +256,18 @@ func (c *Controller) handleUpdateEndpoint(key string) error {
}
}
}

if svcVpc = svc.Annotations[util.VpcAnnotation]; svcVpc != vpcName {
if svc.Annotations == nil {
svc.Annotations = make(map[string]string, 1)
}
svc.Annotations[util.VpcAnnotation] = vpcName
if _, err = c.config.KubeClient.CoreV1().Services(namespace).Update(context.Background(), svc, metav1.UpdateOptions{}); err != nil {
klog.Errorf("failed to update service %s: %v", key, err)
return err
}
}

return nil
}

Expand Down

0 comments on commit f21c9c3

Please sign in to comment.