好问题!你发现了关键点。 看日志:
I1208 13:24:25.492714 pod.go:1195] delete ip CR pod3-178740344.vip-7842
I1208 13:24:25.494865 ip.go:280] deleting ip pod3-178740344.vip-7842 ← handleDelIP
I1208 13:24:25.494869 subnet.go:569] release v4 10.241.51.7 ... add ip to released list
关键发现:
- 只有 ip.go:280 的日志(handleDelIP)
- 没有 ip.go:236 的日志(handleUpdateIP 中的 "handle deleting ip")
- 没有 ip.go:269 的日志("ip cr xxx release ipam pod key")
这说明什么? handleUpdateIP 根本没有被调用! 为什么 handleUpdateIP 没被调用?
因为 xx IP CR 有|没有 finalizer,Kubernetes 的删除行为不同: 没有 finalizer 的资源:
- 调用 Delete() → 直接从 etcd 删除
- 只触发 DELETE 事件
- 只调用 handleDelIP
有 finalizer 的资源:
- 调用 Delete() → 设置 DeletionTimestamp
- 触发 UPDATE 事件(带 DeletionTimestamp)
- 调用 handleUpdateIP 清理资源
- 移除 finalizer
- 触发 DELETE 事件
- 调用 handleDelIP