-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add better error handling and logging for misconfigured ingress and i… #479
Conversation
88f5d09
to
d9f7514
Compare
case internalerrors.IsErrInvalidIngressSpec(err): | ||
log.Info("Ingress is not valid so skipping it") | ||
log.Info(fmt.Sprintf("Ingress is not valid so skipping it: %v", err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q. Do we emit an event onto the Ingress resouce too so users can see this problem with their Ingress definition?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't look like we do. I can update this function to record events instead of log statements so we get those. Good idea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I generally like both, that way we as devs can see the logs and users can see the formatted events. Up to you though :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well any event recorded automatically gets added as a log statement, so we can have both
gd
───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ STDIN
───────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
1 │ diff --git a/internal/controller/ingress/domain_controller.go b/internal/controller/ingress/domain_controller.go
2 │ index c1ffe51..71ba3a1 100644
3 │ --- a/internal/controller/ingress/domain_controller.go
4 │ +++ b/internal/controller/ingress/domain_controller.go
5 │ @@ -106,6 +106,7 @@ func (r *DomainReconciler) SetupWithManager(mgr ctrl.Manager) error {
6 │ // For more details, check Reconcile and its Result here:
7 │ // - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile
8 │ func (r *DomainReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
9 │ + r.Recorder.Event(new(ingressv1alpha1.Domain), v1.EventTypeNormal, "TEST EVENT RECORDER FROM EVENT", fmt.Sprintf("Reconciling Domain %s", req.Name))
10 │ return r.controller.Reconcile(ctx, req, new(ingressv1alpha1.Domain))
11 │ }
12 │
───────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
❯ k get events --sort-by='.lastTimestamp' -A | grep 'TEST EVENT RECORDER'
default 97s Normal TEST EVENT RECORDER FROM EVENT domain Reconciling Domain bezek-different-142345232-ngrok-io
default 97s Normal TEST EVENT RECORDER FROM EVENT domain Reconciling Domain my-operator-based-cloud-endpoint-alexbezek-different.ngrok.io
default 97s Normal TEST EVENT RECORDER FROM EVENT domain Reconciling Domain test-alex-bezek-ngrok-io
default 97s Normal TEST EVENT RECORDER FROM EVENT domain Reconciling Domain bezek-different-1423450293-ngrok-io
default 97s Normal TEST EVENT RECORDER FROM EVENT domain Reconciling Domain my-operator-based-cloud-endpoint-alexbezek-different-ngrok-io
default 96s Normal TEST EVENT RECORDER FROM EVENT domain Reconciling Domain conflict-test-alex-bezek-ngrok-io
default 96s Normal TEST EVENT RECORDER FROM EVENT domain Reconciling Domain example-com
❯ k logs ngrok-operator-manager-7d79944c7d-z2p7c | grep 'TEST EVENT RECORDER'
2024-10-31T15:03:58Z DEBUG events Reconciling Domain test-alex-bezek-ngrok-io {"type": "Normal", "object": {"kind":"Domain","apiVersion":"ingress.k8s.ngrok.com/v1alpha1"}, "reason": "TEST EVENT RECORDER FROM EVENT"}
2024-10-31T15:03:58Z DEBUG events Reconciling Domain bezek-different-1423450293-ngrok-io {"type": "Normal", "object": {"kind":"Domain","apiVersion":"ingress.k8s.ngrok.com/v1alpha1"}, "reason": "TEST EVENT RECORDER FROM EVENT"}
2024-10-31T15:03:58Z DEBUG events Reconciling Domain bezek-different-142345232-ngrok-io {"type": "Normal", "object": {"kind":"Domain","apiVersion":"ingress.k8s.ngrok.com/v1alpha1"}, "reason": "TEST EVENT RECORDER FROM EVENT"}
2024-10-31T15:03:58Z DEBUG events Reconciling Domain my-operator-based-cloud-endpoint-alexbezek-different-ngrok-io {"type": "Normal", "object": {"kind":"Domain","apiVersion":"ingress.k8s.ngrok.com/v1alpha1"}, "reason": "TEST EVENT RECORDER FROM EVENT"}
2024-10-31T15:03:58Z DEBUG events Reconciling Domain my-operator-based-cloud-endpoint-alexbezek-different.ngrok.io {"type": "Normal", "object": {"kind":"Domain","apiVersion":"ingress.k8s.ngrok.com/v1alpha1"}, "reason": "TEST EVENT RECORDER FROM EVENT"}
2024-10-31T15:03:59Z DEBUG events Reconciling Domain conflict-test-alex-bezek-ngrok-io {"type": "Normal", "object": {"kind":"Domain","apiVersion":"ingress.k8s.ngrok.com/v1alpha1"}, "reason": "TEST EVENT RECORDER FROM EVENT"}
2024-10-31T15:03:59Z DEBUG events Reconciling Domain example-com {"type": "Normal", "object": {"kind":"Domain","apiVersion":"ingress.k8s.ngrok.com/v1alpha1"}, "reason": "TEST EVENT RECORDER FROM EVENT"}
…ngress classes
What
Updates the operator to handle logging helpful error messages for situations it can't resolve ingress for
Resolves:
How
Validation
Got nice logs like these after recreating some of the error cases
Recreated and tested with these cases