Skip to content

Commit cd1da12

Browse files
committed
re-queue and ignore error when batch delete listener failed
Signed-off-by: roc <[email protected]>
1 parent 273d05e commit cd1da12

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

internal/controller/clbbinding.go

+4
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,10 @@ func (r *CLBBindingReconciler[T]) cleanup(ctx context.Context, bd T) (result ctr
526526
if e == clb.ErrListenerNotFound { // 监听器不存在,忽略
527527
continue
528528
}
529+
if e == clb.ErrOtherListenerNotFound { // 其它监听器不存在导致本批次删除失败,忽略错误重新入队重试
530+
result.Requeue = true
531+
return result, nil
532+
}
529533
if clb.IsLbIdNotFoundError(e) { // lb 不存在,忽略
530534
continue
531535
}

internal/controller/pod_controller.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ func (r *PodReconciler) syncCLBHostPortMapping(ctx context.Context, pod *corev1.
138138
}
139139
for _, bd := range cbd.Status.PortBindings {
140140
if bd.Protocol == string(port.Protocol) {
141-
if lbPort, ok := matchHostPort(uint16(port.HostPort), bd.Port, bd.LoadbalancerPort, util.GetValue(bd.LoadbalancerEndPort)); ok {
141+
lbEndPort := util.GetValue(bd.LoadbalancerEndPort)
142+
if lbPort, ok := matchHostPort(uint16(port.HostPort), bd.Port, bd.LoadbalancerPort, lbEndPort); ok {
142143
mappings = append(mappings, HostPortMapping{
143144
ContainerPort: uint16(port.ContainerPort),
144145
HostPort: uint16(port.HostPort),

pkg/clb/batch-listener.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,9 @@ func (t *DeleteListenerTask) GetRegion() string {
214214
}
215215

216216
var (
217-
DeleteListenerChan = make(chan *DeleteListenerTask, 100)
218-
ErrListenerNotFound = errors.New("listener not found")
217+
DeleteListenerChan = make(chan *DeleteListenerTask, 100)
218+
ErrListenerNotFound = errors.New("listener not found")
219+
ErrOtherListenerNotFound = errors.New("other listener not found")
219220
)
220221

221222
func startDeleteListenerProccessor(concurrent int) {
@@ -238,11 +239,9 @@ func startDeleteListenerProccessor(concurrent int) {
238239
if strings.Contains(err.Error(), "Code=InvalidParameter") && strings.Contains(err.Error(), "some ListenerId") && strings.Contains(err.Error(), "not found") {
239240
for _, task := range tasks {
240241
if strings.Contains(err.Error(), task.ListenerId) { // 返回不存在的错误,让上层不要重试
241-
clbLog.V(10).Info("listener not found", "listenerId", task.ListenerId, "rawErr", err.Error())
242242
task.Result <- ErrListenerNotFound
243243
} else { // 因其它监听器不存在导致本批次监听器没有删除,需要重试
244-
clbLog.V(10).Info("other error", "listenerId", task.ListenerId, "rawErr", err.Error())
245-
task.Result <- err
244+
task.Result <- ErrOtherListenerNotFound
246245
}
247246
}
248247
} else {

0 commit comments

Comments
 (0)