Skip to content

Commit

Permalink
Merge pull request #152 from backguynn/main
Browse files Browse the repository at this point in the history
Retry when service status update conflict occurs
  • Loading branch information
TrekkieCoder committed Jun 25, 2024
2 parents edee966 + 2c4f5ed commit 35db2de
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/agent/manager/loadbalancer/loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"time"

corev1 "k8s.io/api/core/v1"
k8sErrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/selection"
Expand Down Expand Up @@ -893,7 +894,14 @@ func (m *Manager) addLoadBalancer(svc *corev1.Service) error {
}

// Update service.Status.LoadBalancer.Ingress
m.updateService(svc.Namespace, svc.Name, ingSvcPairs)
for retry := 0; retry < 5; retry++ {
err := m.updateService(svc.Namespace, svc.Name, ingSvcPairs)
if !k8sErrors.IsConflict(err) {
break
}

time.Sleep(1 * time.Second)
}

return nil
}
Expand Down

0 comments on commit 35db2de

Please sign in to comment.