From da05e3a963b5aa5e63c6c32d9270a806f3edd3c1 Mon Sep 17 00:00:00 2001 From: killianmuldoon Date: Tue, 27 Sep 2022 14:26:11 +0100 Subject: [PATCH] Log full object name and creation error for topology template reconcile Signed-off-by: killianmuldoon --- internal/controllers/topology/cluster/reconcile_state.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/controllers/topology/cluster/reconcile_state.go b/internal/controllers/topology/cluster/reconcile_state.go index 748f00b01763..844f9e2fbe56 100644 --- a/internal/controllers/topology/cluster/reconcile_state.go +++ b/internal/controllers/topology/cluster/reconcile_state.go @@ -28,6 +28,8 @@ import ( "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apiserver/pkg/storage/names" + "k8s.io/klog/v2" + ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" @@ -801,7 +803,9 @@ func (r *Reconciler) reconcileReferencedTemplate(ctx context.Context, in reconci // createErrorWithoutObjectName removes the name of the object from the error message. As each new Create call involves an // object with a unique generated name each error appears to be a different error. As the errors are being surfaced in a condition // on the Cluster, the name is removed here to prevent each creation error from triggering a new reconciliation. -func createErrorWithoutObjectName(err error, obj client.Object) error { +func createErrorWithoutObjectName(ctx context.Context, err error, obj client.Object) error { + log := ctrl.LoggerFrom(ctx) + log.Info("Failed to create object", "object", klog.KObj(obj), "error", err.Error()) var statusError *apierrors.StatusError if errors.As(err, &statusError) { var msg string