Skip to content

Commit

Permalink
Improve owner missing error message
Browse files Browse the repository at this point in the history
  • Loading branch information
matthchr committed Aug 26, 2021
1 parent cfb25c0 commit 5cec45a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion hack/generated/controllers/generic_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func (gr *GenericReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
// (actually a reference or shallow copy) of an object, you'll mess up other controllers (not just your own).
obj = obj.DeepCopyObject().(client.Object)

gr.Log.V(0).Info(
gr.Log.V(1).Info(
"Reconcile invoked",
"kind", fmt.Sprintf("%T", obj),
"resourceVersion", obj.GetResourceVersion(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Licensed under the MIT license.

package conditions

import "fmt"

const (
ReasonReconciling = "Reconciling"
ReasonWaitingForOwner = "WaitingForOwner"
Expand All @@ -29,12 +31,12 @@ func (b *ReadyConditionBuilder) Reconciling() Condition {
"The resource is in the process of being reconciled by the operator")
}

func (b *ReadyConditionBuilder) WaitingForOwner() Condition {
func (b *ReadyConditionBuilder) WaitingForOwner(ownerDetails string) Condition {
return b.builder.MakeFalseCondition(
ConditionTypeReady,
ConditionSeverityWarning,
ReasonWaitingForOwner,
"The owner of this resource cannot be found in Kubernetes. Process is blocked until the owner is created.")
fmt.Sprintf("Owner %q cannot be found. Progress is blocked until the owner is created.", ownerDetails))
}

func (b *ReadyConditionBuilder) Deleting() Condition {
Expand Down
2 changes: 1 addition & 1 deletion hack/generated/pkg/genruntime/resource_reference.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (ref ResourceReference) String() string {
}

if ref.IsKubernetesReference() {
return fmt.Sprintf("Group: %q, Kind: %q, Namespace: %q, Name: %q", ref.Group, ref.Kind, ref.Namespace, ref.Name)
return fmt.Sprintf("%s/%s, GroupKind: %s/%s", ref.Namespace, ref.Name, ref.Group, ref.Kind)
}

// Printing all the fields here just in case something weird happens and we have an ARMID and also Kubernetes reference stuff
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -707,10 +707,7 @@ func (r *AzureDeploymentReconciler) ManageOwnership(ctx context.Context) (ctrl.R
}

if !isOwnerReady {
// TODO: We need to figure out how we're handing these sorts of errors.
// TODO: See https://github.com/Azure/azure-service-operator/issues/1448
// TODO: For now just set an error so we at least see something
conditions.SetCondition(r.obj, r.PositiveConditions.Ready.WaitingForOwner())
conditions.SetCondition(r.obj, r.PositiveConditions.Ready.WaitingForOwner(r.obj.Owner().String()))
err = r.CommitUpdate(ctx)

err = client.IgnoreNotFound(err)
Expand Down

0 comments on commit 5cec45a

Please sign in to comment.