Skip to content

Commit 856c06f

Browse files
authored
Use the previously ingress in the error messages (#500)
1 parent 4955cf6 commit 856c06f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

internal/controller/ingress/ingress_controller.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ func (r *IngressReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
9191
return ctrl.Result{}, err
9292
}
9393

94+
// Store the originally found ingress separately to use later
95+
// incase there is an error updating and finding it below
96+
originalFoundIngress := ingress
97+
9498
// Ensure the ingress object is up to date in the store
9599
// Leverage the store to ensure this works off the same data as everything else
96100
ingress, err = r.Driver.UpdateIngress(ingress)
@@ -101,13 +105,13 @@ func (r *IngressReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
101105
log.Info("Ingress is not of type ngrok so skipping it")
102106
return ctrl.Result{}, nil
103107
case internalerrors.IsErrorNoDefaultIngressClassFound(err):
104-
r.Recorder.Event(ingress, "Warning", "NoDefaultIngressClassFound", "No ingress class found for this controller")
108+
r.Recorder.Event(originalFoundIngress, "Warning", "NoDefaultIngressClassFound", "No ingress class found for this controller")
105109
return ctrl.Result{}, nil
106110
case internalerrors.IsErrInvalidIngressSpec(err):
107-
r.Recorder.Eventf(ingress, "Warning", "InvalidIngressSpec", "Ingress is not valid so skipping it: %v", err)
111+
r.Recorder.Eventf(originalFoundIngress, "Warning", "InvalidIngressSpec", "Ingress is not valid so skipping it: %v", err)
108112
return ctrl.Result{}, nil
109113
default:
110-
r.Recorder.Event(ingress, "Warning", "FailedGetIngress", "Failed to get ingress from store")
114+
r.Recorder.Event(originalFoundIngress, "Warning", "FailedGetIngress", "Failed to get ingress from store")
111115
return ctrl.Result{}, err
112116
}
113117

0 commit comments

Comments
 (0)