Skip to content

Commit 802db33

Browse files
committed
fix port allocator
Signed-off-by: roc <[email protected]>
1 parent c4011ba commit 802db33

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

internal/controller/clbbinding.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,9 +607,11 @@ func (r *CLBBindingReconciler[T]) cleanup(ctx context.Context, bd T) (result ctr
607607
// 确保端口从端口池被释放
608608
allocated := portpool.Allocator.IsAllocated(binding.Pool, binding.LoadbalancerId, portFromPortBindingStatus(&binding))
609609
if !allocated { // 已经清理过,忽略
610+
log.Info("ignore already released port", "port", binding.LoadbalancerPort, "protocol", binding.Protocol, "pool", binding.Pool, "lb", binding.LoadbalancerId)
610611
continue
611612
}
612613
releasePort := func() {
614+
log.V(3).Info("release allocated port", "port", binding.LoadbalancerPort, "protocol", binding.Protocol, "pool", binding.Pool, "lb", binding.LoadbalancerId)
613615
portpool.Allocator.Release(binding.Pool, binding.LoadbalancerId, portFromPortBindingStatus(&binding))
614616
}
615617
// 解绑 lb

internal/portpool/portpool.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func (pp *PortPool) IsAllocated(lbId string, port ProtocolPort) bool {
139139
if cache == nil {
140140
return false
141141
}
142-
_, ok := cache[port]
142+
_, ok := cache[port.Key()]
143143
return ok
144144
}
145145

@@ -151,7 +151,7 @@ func (pp *PortPool) ReleasePort(lbId string, port ProtocolPort) bool {
151151
if cache == nil {
152152
return false
153153
}
154-
delete(cache, port)
154+
delete(cache, port.Key())
155155
return true
156156
}
157157

0 commit comments

Comments
 (0)