Skip to content

Commit

Permalink
[discuss] fail annotation parsing fast and report errors as events (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jrudolph authored Nov 20, 2024
1 parent 6ceccbd commit 5fa1102
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/ingress/controller/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ type k8sStore struct {
backendConfigMu *sync.RWMutex

defaultSSLCertificate string

recorder record.EventRecorder
}

// New creates a new object store to be used in the ingress controller.
Expand Down Expand Up @@ -279,6 +281,7 @@ func New(
recorder := eventBroadcaster.NewRecorder(scheme.Scheme, corev1.EventSource{
Component: "nginx-ingress-controller",
})
store.recorder = recorder

// k8sStore fulfills resolver.Resolver interface
store.annotations = annotations.NewAnnotationExtractor(store)
Expand Down Expand Up @@ -938,6 +941,9 @@ func (s *k8sStore) syncIngress(ing *networkingv1.Ingress) {
klog.Error(err)
return
}
if parsed.Denied != nil {
s.recorder.Eventf(ing, corev1.EventTypeWarning, "AnnotationParsingFailed", fmt.Sprintf("Error parsing annotations: %v", *parsed.Denied))
}
err = s.listers.IngressWithAnnotation.Update(&ingress.Ingress{
Ingress: *copyIng,
ParsedAnnotations: parsed,
Expand Down

0 comments on commit 5fa1102

Please sign in to comment.