Normalise controller logs

Change structure logging labels to match the controller runtime format
This commit is contained in:
stefanprodan 2020-07-15 16:02:11 +03:00
parent ba362287ac
commit 3112e18378
3 changed files with 3 additions and 5 deletions

View File

@ -48,7 +48,7 @@ func (r *AlertReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
return ctrl.Result{}, client.IgnoreNotFound(err)
}
log := r.Log.WithValues(strings.ToLower(alert.Kind), req.NamespacedName)
log := r.Log.WithValues("controller", strings.ToLower(alert.Kind), "request", req.NamespacedName)
init := true
for _, condition := range alert.Status.Conditions {

View File

@ -48,7 +48,7 @@ func (r *ProviderReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
return ctrl.Result{}, client.IgnoreNotFound(err)
}
log := r.Log.WithValues(strings.ToLower(provider.Kind), req.NamespacedName)
log := r.Log.WithValues("controller", strings.ToLower(provider.Kind), "request", req.NamespacedName)
init := true
for _, condition := range provider.Status.Conditions {

View File

@ -55,13 +55,12 @@ func (r *ReceiverReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
return ctrl.Result{}, client.IgnoreNotFound(err)
}
log := r.Log.WithValues(strings.ToLower(receiver.Kind), req.NamespacedName)
log := r.Log.WithValues("controller", strings.ToLower(receiver.Kind), "request", req.NamespacedName)
token, err := r.token(ctx, receiver)
if err != nil {
receiver = v1alpha1.ReceiverNotReady(receiver, v1alpha1.TokenNotFoundReason, err.Error())
if err := r.Status().Update(ctx, &receiver); err != nil {
log.Error(err, "unable to update Receiver status")
return ctrl.Result{Requeue: true}, err
}
}
@ -85,7 +84,6 @@ func (r *ReceiverReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
"Receiver initialised with URL: "+receiverURL,
receiverURL)
if err := r.Status().Update(ctx, &receiver); err != nil {
log.Error(err, "unable to update Receiver status")
return ctrl.Result{Requeue: true}, err
}