Skip to content

Commit

Permalink
1.11 ip delete lsp (#3562)
Browse files Browse the repository at this point in the history
* delete lsp and ipam with ip

* clean ip crd after clean all ip

---------

Signed-off-by: bobz965 <zhangbingbing2_yewu@cmss.chinamobile.com>
  • Loading branch information
bobz965 committed Dec 22, 2023
1 parent e27aced commit ad3e369
Show file tree
Hide file tree
Showing 5 changed files with 361 additions and 57 deletions.
19 changes: 15 additions & 4 deletions dist/images/cleanup.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash
set -eu
set -eux
export PS4='+ $(date "+%Y-%m-%d %H:%M:%S")\011 '

kubectl delete --ignore-not-found ds kube-ovn-pinger -n kube-system
# ensure kube-ovn-pinger has been deleted
Expand Down Expand Up @@ -109,12 +110,22 @@ kubectl delete --ignore-not-found clusterrole system:vpc-dns
kubectl delete --ignore-not-found clusterrolebinding vpc-dns
kubectl delete --ignore-not-found sa vpc-dns -n kube-system


# delete CRD
kubectl delete --ignore-not-found crd htbqoses.kubeovn.io security-groups.kubeovn.io ips.kubeovn.io subnets.kubeovn.io \
vpc-nat-gateways.kubeovn.io vpcs.kubeovn.io vlans.kubeovn.io provider-networks.kubeovn.io \
iptables-dnat-rules.kubeovn.io iptables-eips.kubeovn.io iptables-fip-rules.kubeovn.io \
kubectl delete --ignore-not-found crd security-groups.kubeovn.io subnets.kubeovn.io vpcs.kubeovn.io \
vlans.kubeovn.io provider-networks.kubeovn.io vpc-nat-gateways.kubeovn.io \
iptables-dnat-rules.kubeovn.io iptables-eips.kubeovn.io iptables-fip-rules.kubeovn.io \
iptables-snat-rules.kubeovn.io vips.kubeovn.io switch-lb-rules.kubeovn.io vpc-dnses.kubeovn.io \
ovn-eips.kubeovn.io ovn-fips.kubeovn.io ovn-snat-rules.kubeovn.io
# in case of ip not delete
set +e
for ip in $(kubectl get ip -o name); do
kubectl patch "$ip" --type='json' -p '[{"op": "replace", "path": "/metadata/finalizers", "value": []}]'
kubectl delete --ignore-not-found "$ip"
done
kubectl delete --ignore-not-found crd ips.kubeovn.io
set -e


# Remove annotations/labels in namespaces and nodes
kubectl annotate no --all ovn.kubernetes.io/cidr-
Expand Down
26 changes: 20 additions & 6 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,11 @@ type Controller struct {
syncVirtualPortsQueue workqueue.RateLimitingInterface
subnetStatusKeyMutex *keymutex.KeyMutex

ipsLister kubeovnlister.IPLister
ipSynced cache.InformerSynced
ipsLister kubeovnlister.IPLister
ipSynced cache.InformerSynced
addIPQueue workqueue.RateLimitingInterface
updateIPQueue workqueue.RateLimitingInterface
delIPQueue workqueue.RateLimitingInterface

virtualIpsLister kubeovnlister.VipLister
virtualIpsSynced cache.InformerSynced
Expand Down Expand Up @@ -288,8 +291,11 @@ func NewController(config *Configuration) *Controller {
syncVirtualPortsQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "SyncVirtualPort"),
subnetStatusKeyMutex: keymutex.New(97),

ipsLister: ipInformer.Lister(),
ipSynced: ipInformer.Informer().HasSynced,
ipsLister: ipInformer.Lister(),
ipSynced: ipInformer.Informer().HasSynced,
addIPQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "AddIP"),
updateIPQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "UpdateIP"),
delIPQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "DeleteIP"),

virtualIpsLister: virtualIpInformer.Lister(),
virtualIpsSynced: virtualIpInformer.Informer().HasSynced,
Expand Down Expand Up @@ -485,9 +491,9 @@ func NewController(config *Configuration) *Controller {
}

if _, err = ipInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
AddFunc: controller.enqueueAddOrDelIP,
AddFunc: controller.enqueueAddIP,
UpdateFunc: controller.enqueueUpdateIP,
DeleteFunc: controller.enqueueAddOrDelIP,
DeleteFunc: controller.enqueueDelIP,
}); err != nil {
util.LogFatalAndExit(err, "failed to add ips event handler")
}
Expand Down Expand Up @@ -763,6 +769,10 @@ func (c *Controller) shutdown() {
c.delVpcDnsQueue.ShutDown()
}

c.addIPQueue.ShutDown()
c.updateIPQueue.ShutDown()
c.delIPQueue.ShutDown()

c.addVirtualIpQueue.ShutDown()
c.updateVirtualIpQueue.ShutDown()
c.delVirtualIpQueue.ShutDown()
Expand Down Expand Up @@ -977,6 +987,10 @@ func (c *Controller) startWorkers(ctx context.Context) {

go wait.Until(c.syncVmLiveMigrationPort, 15*time.Second, ctx.Done())

go wait.Until(c.runAddIPWorker, time.Second, ctx.Done())
go wait.Until(c.runUpdateIPWorker, time.Second, ctx.Done())
go wait.Until(c.runDelIPWorker, time.Second, ctx.Done())

go wait.Until(c.runAddVirtualIpWorker, time.Second, ctx.Done())
go wait.Until(c.runUpdateVirtualIpWorker, time.Second, ctx.Done())
go wait.Until(c.runDelVirtualIpWorker, time.Second, ctx.Done())
Expand Down

0 comments on commit ad3e369

Please sign in to comment.