Skip to content

Commit

Permalink
Merge pull request #1325 from vincepri/better-reference-error-handling
Browse files Browse the repository at this point in the history
✨ Improve ErrorMessage from referenced resources
  • Loading branch information
k8s-ci-robot authored Sep 4, 2019
2 parents 5713990 + 11c5525 commit b9b33c7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion controllers/cluster_controller_phases.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package controllers

import (
"context"
"fmt"
"time"

"github.com/pkg/errors"
Expand Down Expand Up @@ -120,7 +121,10 @@ func (r *ClusterReconciler) reconcileExternal(ctx context.Context, cluster *clus
cluster.Status.ErrorReason = &clusterStatusError
}
if errorMessage != "" {
cluster.Status.ErrorMessage = pointer.StringPtr(errorMessage)
cluster.Status.ErrorMessage = pointer.StringPtr(
fmt.Sprintf("Failure detected from referenced resource %v with name %q: %s",
obj.GroupVersionKind(), obj.GetName(), errorMessage),
)
}

return obj, nil
Expand Down
6 changes: 5 additions & 1 deletion controllers/machine_controller_phases.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package controllers

import (
"context"
"fmt"
"time"

"github.com/pkg/errors"
Expand Down Expand Up @@ -128,7 +129,10 @@ func (r *MachineReconciler) reconcileExternal(ctx context.Context, m *clusterv1.
m.Status.ErrorReason = &machineStatusError
}
if errorMessage != "" {
m.Status.ErrorMessage = pointer.StringPtr(errorMessage)
m.Status.ErrorMessage = pointer.StringPtr(
fmt.Sprintf("Failure detected from referenced resource %v with name %q: %s",
obj.GroupVersionKind(), obj.GetName(), errorMessage),
)
}

return obj, nil
Expand Down

0 comments on commit b9b33c7

Please sign in to comment.