Skip to content

Commit

Permalink
Add rate limiting to extdns retries, return nil when VS deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
ciarams87 committed Nov 7, 2023
1 parent 60f7f02 commit 0528c50
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions internal/certmanager/cm_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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
}

Check warning on line 153 in internal/certmanager/cm_controller.go

View check run for this annotation

Codecov / codecov/patch

internal/certmanager/cm_controller.go#L150-L153

Added lines #L150 - L153 were not covered by tests

if err != nil {
return err
}
Expand Down
9 changes: 8 additions & 1 deletion internal/externaldns/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)

Check warning on line 169 in internal/externaldns/controller.go

View check run for this annotation

Codecov / codecov/patch

internal/externaldns/controller.go#L169

Added line #L169 was not covered by tests
return
}
glog.V(3).Infof("finished processing work item")
c.queue.Forget(obj)

Check warning on line 173 in internal/externaldns/controller.go

View check run for this annotation

Codecov / codecov/patch

internal/externaldns/controller.go#L173

Added line #L173 was not covered by tests
}()
}
}
Expand All @@ -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
}

Check warning on line 191 in internal/externaldns/controller.go

View check run for this annotation

Codecov / codecov/patch

internal/externaldns/controller.go#L188-L191

Added lines #L188 - L191 were not covered by tests

if err != nil {
return err
}
Expand Down

0 comments on commit 0528c50

Please sign in to comment.