You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
VPCs with subnets do not have finalizers set on them so can be immediately deleted without waiting for their subnets. This results in repeated logs of:
If the subnet is unable to be deleted at the same time, for example if there is still a pod running using an IP address then it's very easy to hit #5028
If the kube-ovn-controller leader is restarted, gc is triggered and the underlying OVN logical router is deleted
To address the issue where VPCs in Kube-OVN version 1.13.2 are deleted without waiting for their child subnets to be removed, you can implement a webhook that prevents the deletion of a VPC if it has associated subnets. The VpcDeleteHook in the webhook package is designed for this purpose. It checks if there are any subnets associated with the VPC and denies the deletion request if subnets exist. This ensures that VPCs are not deleted before their child subnets, effectively preventing the issue you're experiencing.
Here's the relevant code snippet for the VpcDeleteHook:
func (v*ValidatingHook) VpcDeleteHook(_ context.Context, req admission.Request) admission.Response {
vpc:= ovnv1.Vpc{}
iferr:=v.decoder.DecodeRaw(req.OldObject, &vpc); err!=nil {
returnctrlwebhook.Errored(http.StatusBadRequest, err)
}
iflen(vpc.Status.Subnets) !=0 {
returnctrlwebhook.Denied("can't delete vpc when any subnet in the vpc")
}
returnctrlwebhook.Allowed("by pass")
}
This function ensures that the VPC deletion is blocked if there are any subnets present, thus preventing the premature deletion of VPCs [1].
Kube-OVN Version
v1.13.2
Kubernetes Version
v1.28.6
Operation-system/Kernel Version
"Ubuntu 22.04.5 LTS" 6.8.0-47-generic
Description
VPCs with subnets do not have finalizers set on them so can be immediately deleted without waiting for their subnets. This results in repeated logs of:
If the subnet is unable to be deleted at the same time, for example if there is still a pod running using an IP address then it's very easy to hit #5028
If the kube-ovn-controller leader is restarted, gc is triggered and the underlying OVN logical router is deleted
Steps To Reproduce
Create a VPC and subnet:
Delete VPC:
Logs then repeatedly show:
The VPC is no longer present in etcd:
Current Behavior
VPC CR deletion happens immediately even though it is referenced by a subnet but controller is unable to process.
Expected Behavior
VPC deletion is blocked by a finalizer until all subnets are removed
The text was updated successfully, but these errors were encountered: