We recently simplified the cross resource reference implementation. During this refactor we lost the ability to determine which specific reference is unready or broken.
https://github.com/crossplane/provider-gcp/blob/0e59ca/apis/container/v1beta1/referencers.go#L60
For example if the above resource reference from a GKE cluster to the subnetwork it lives in is not yet ready the GKE cluster will emit an event and update its Ready condition with the message:
status:
conditions:
- lastTransitionTime: "2020-05-12T03:07:42Z"
message: 'cannot resolve references: referenced field was empty (reference may not yet be ready)'
reason: Encountered an error during resource reconciliation
status: "False"
type: Synced
This is ambiguous, because the GKE cluster references both a Network and a Subnetwork. It's possible to work out which is ready with a little effort, but it could be easier.
https://github.com/crossplane/provider-gcp/blob/0e59ca/apis/container/v1beta1/referencers.go#L69
if err != nil {
return errors.Wrap(err, "spec.forProvider.subnetworkRef")
}
If all referencers included the above context (i.e. wrapped the error with the fieldpath of the referenced field) the error would instead read:
cannot resolve references: spec.forProvider.subnetworkRef: referenced field was empty (reference may not yet be ready)
@negz I had remembered you feeling as though this was too verbose, does this differ because here you propose providing the field path? https://github.com/crossplane/crossplane-runtime/pull/151#issuecomment-614290886
@hasheddan If I recall correctly, the old output:
I think it was something like ReferencesBlocked: [{example: NotReady}]. So in cases like the below configuration it was difficult to determine at a glance which reference wasn't ready.
spec:
networkRef:
name: example
subnetworkRef:
name: example
I think this proposal is a good compromise because it:
With all the linked PRs in place, these errors should look something like:
cannot resolve references: spec.forProvider.subnetwork: referenced field was empty (referenced resource may not yet be ready)
cannot resolve references: spec.forProvider.subnetwork: cannot get referenced resource
cannot resolve references: spec.forProvider.subnetwork: cannot list resources that match selector
Note that we call out the 'destination' field, not the Ref or Selector variants specifically, but I'm hoping the errors are improved enough that folks will be able to join the dots.
Most helpful comment
@hasheddan If I recall correctly, the old output:
I think it was something like
ReferencesBlocked: [{example: NotReady}]. So in cases like the below configuration it was difficult to determine at a glance which reference wasn't ready.I think this proposal is a good compromise because it: