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 committed Jul 11, 2024
1 parent e4b4142 commit 54aa76f
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 @@ -189,17 +189,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/%s: %v", namespace, svc.Name, 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 @@ -266,6 +255,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/%s: %v", namespace, svc.Name, err)
return err
}
}

return nil
}

Expand Down

0 comments on commit 54aa76f

Please sign in to comment.