From 505c00e2afbc26ccda9d5f4cb280fee5cef7edfa Mon Sep 17 00:00:00 2001 From: Ciara Stacke Date: Wed, 27 Sep 2023 11:14:48 +0100 Subject: [PATCH 1/2] Don't block owner deletion for extdns --- internal/externaldns/sync.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/externaldns/sync.go b/internal/externaldns/sync.go index 96d2273c24..2aaa4694a5 100644 --- a/internal/externaldns/sync.go +++ b/internal/externaldns/sync.go @@ -155,13 +155,16 @@ func buildDNSEndpoint(extdnsLister extdnslisters.DNSEndpointLister, vs *vsapi.Vi return nil, nil, err } var controllerGVK schema.GroupVersionKind = vsGVK + ownerRef := *metav1.NewControllerRef(vs, controllerGVK) + blockOwnerDeletion := false + ownerRef.BlockOwnerDeletion = &blockOwnerDeletion dnsEndpoint := &extdnsapi.DNSEndpoint{ ObjectMeta: metav1.ObjectMeta{ Name: vs.ObjectMeta.Name, Namespace: vs.Namespace, Labels: vs.Labels, - OwnerReferences: []metav1.OwnerReference{*metav1.NewControllerRef(vs, controllerGVK)}, + OwnerReferences: []metav1.OwnerReference{ownerRef}, }, Spec: extdnsapi.DNSEndpointSpec{ Endpoints: []*extdnsapi.Endpoint{ From 5a8ddf243d7542b116bfb7b5b32df29f6a13dd1f Mon Sep 17 00:00:00 2001 From: Ciara Stacke Date: Wed, 11 Oct 2023 16:09:53 +0100 Subject: [PATCH 2/2] Add rate limiting to extdns retries, return nil when VS deleted --- internal/certmanager/cm_controller.go | 6 ++++++ internal/externaldns/controller.go | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/internal/certmanager/cm_controller.go b/internal/certmanager/cm_controller.go index 59a75ef904..4cbbe59146 100644 --- a/internal/certmanager/cm_controller.go +++ b/internal/certmanager/cm_controller.go @@ -40,6 +40,7 @@ import ( k8s_nginx "github.com/nginxinc/kubernetes-ingress/pkg/client/clientset/versioned" vsinformers "github.com/nginxinc/kubernetes-ingress/pkg/client/informers/externalversions" listers_v1 "github.com/nginxinc/kubernetes-ingress/pkg/client/listers/configuration/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" ) const ( @@ -146,6 +147,11 @@ func (c *CmController) processItem(ctx context.Context, key string) error { var vs *conf_v1.VirtualServer vs, err = nsi.vsLister.VirtualServers(namespace).Get(name) + // VS has been deleted + if apierrors.IsNotFound(err) { + return nil + } + if err != nil { return err } diff --git a/internal/externaldns/controller.go b/internal/externaldns/controller.go index 57d258bf96..02c38ce16f 100644 --- a/internal/externaldns/controller.go +++ b/internal/externaldns/controller.go @@ -13,6 +13,7 @@ import ( listersV1 "github.com/nginxinc/kubernetes-ingress/pkg/client/listers/configuration/v1" extdnslisters "github.com/nginxinc/kubernetes-ingress/pkg/client/listers/externaldns/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/runtime" "k8s.io/client-go/tools/cache" @@ -165,10 +166,11 @@ func (c *ExtDNSController) runWorker(ctx context.Context) { if err := c.processItem(ctx, key); err != nil { glog.V(3).Infof("Re-queuing item due to error processing: %v", err) - c.queue.Add(obj) + c.queue.AddRateLimited(obj) return } glog.V(3).Infof("finished processing work item") + c.queue.Forget(obj) }() } } @@ -183,6 +185,11 @@ func (c *ExtDNSController) processItem(ctx context.Context, key string) error { nsi := getNamespacedInformer(namespace, c.informerGroup) vs, err = nsi.vsLister.VirtualServers(namespace).Get(name) + // VS has been deleted + if apierrors.IsNotFound(err) { + return nil + } + if err != nil { return err }