Skip to content

Commit

Permalink
Merge pull request #22 from loxilb-io/lb-err-chk
Browse files Browse the repository at this point in the history
PR - Specific error status check moved out from REST request/resp handling
  • Loading branch information
TrekkieCoder authored Jul 24, 2023
2 parents bf59315 + ea60426 commit 40b8e9d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
17 changes: 13 additions & 4 deletions pkg/agent/manager/loadbalancer/loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -621,8 +621,12 @@ func (m *Manager) addLoadBalancer(svc *corev1.Service) error {
var err error
for _, lbModel := range lbModelList {
if err = c.LoadBalancer().Create(ctx, &lbModel); err != nil {
klog.Errorf("failed to create load-balancer(%s) :%v", c.Url, err)
break
if !strings.Contains(err.Error(), "exist") {
klog.Errorf("failed to create load-balancer(%s) :%v", c.Url, err)
break
} else {
err = nil
}
}
}
h <- err
Expand Down Expand Up @@ -1196,8 +1200,13 @@ loop:
isSuccess = true
break
} else {
klog.Infof("reinstallLoxiLbRules: lbModel: %v retry(%d)", lbModel, retry)
time.Sleep(1 * time.Second)
if !strings.Contains(err.Error(), "exist") {
klog.Infof("reinstallLoxiLbRules: lbModel: %v retry(%d)", lbModel, retry)
time.Sleep(1 * time.Second)
} else {
isSuccess = true
break
}
}
}
if !isSuccess {
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func (l *LoxiRequest) Do(ctx context.Context) *LoxiResponse {
return &LoxiResponse{err: err}
}

if result.Result != "Success" && !strings.Contains(result.Result, "exist") {
if result.Result != "Success" {
return &LoxiResponse{err: errors.New(result.Result)}
}
}
Expand Down

0 comments on commit 40b8e9d

Please sign in to comment.