Skip to content

Commit

Permalink
fix(controllers) disable more IngressClass lookups
Browse files Browse the repository at this point in the history
When the IngressClass controller is disabled, disable reconciler lookups
to determine if the IngressClass is the default class.
  • Loading branch information
rainest committed Jul 19, 2022
1 parent 4a7d27a commit f157998
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 60 deletions.
14 changes: 8 additions & 6 deletions hack/generators/controllers/networking/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -581,12 +581,14 @@ func (r *{{.PackageAlias}}{{.Kind}}Reconciler) Reconcile(ctx context.Context, re
}
{{if .AcceptsIngressClassNameAnnotation}}
class := new(netv1.IngressClass)
if err := r.Get(ctx, types.NamespacedName{Name: r.IngressClassName}, class); err != nil {
// we log this without taking action to support legacy configurations that only set ingressClassName or
// used the class annotation and did not create a corresponding IngressClass. We only need this to determine
// if the IngressClass is default or to configure default settings, and can assume no/no additional defaults
// if none exists.
log.V(util.DebugLevel).Info("could not retrieve IngressClass", "ingressclass", r.IngressClassName)
if !r.DisableIngressClassLookups {
if err := r.Get(ctx, types.NamespacedName{Name: r.IngressClassName}, class); err != nil {
// we log this without taking action to support legacy configurations that only set ingressClassName or
// used the class annotation and did not create a corresponding IngressClass. We only need this to determine
// if the IngressClass is default or to configure default settings, and can assume no/no additional defaults
// if none exists.
log.V(util.DebugLevel).Info("could not retrieve IngressClass", "ingressclass", r.IngressClassName)
}
}
// if the object is not configured with our ingress.class, then we need to ensure it's removed from the cache
if !ctrlutils.MatchesIngressClass(obj, r.IngressClassName, ctrlutils.IsDefaultIngressClass(class)) {
Expand Down
126 changes: 72 additions & 54 deletions internal/controllers/configuration/zz_generated_controllers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f157998

Please sign in to comment.