Skip to content

Commit

Permalink
Log full object name and creation error for topology template reconcile
Browse files Browse the repository at this point in the history
Signed-off-by: killianmuldoon <[email protected]>
  • Loading branch information
killianmuldoon committed Sep 27, 2022
1 parent c7c0c59 commit da05e3a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/controllers/topology/cluster/reconcile_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit da05e3a

Please sign in to comment.