Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix resource refs #137

Merged
merged 3 commits into from
Dec 12, 2023
Merged

fix resource refs #137

merged 3 commits into from
Dec 12, 2023

Conversation

avalanche123
Copy link
Collaborator

Description of your changes

crossplane/crossplane#4858 changed crossplane behavior to generate resource
names purely client-side, which can lead to a resource ref not resolving for
a time. This PR handles not found error and skips pending resource refs from
responses.

I have:

  • Read and followed Upbound's contribution process.
  • Run make reviewable to ensure this PR is ready for review.
  • Added backport release-x.y labels to auto-backport this PR, as appropriate.

How has this code been tested

Going to test in a live cluster.

Signed-off-by: Bulat Shakirzyanov <83289+avalanche123@users.noreply.github.com>
Signed-off-by: Bulat Shakirzyanov <83289+avalanche123@users.noreply.github.com>
Signed-off-by: Bulat Shakirzyanov <83289+avalanche123@users.noreply.github.com>
@avalanche123 avalanche123 merged commit 0a1d4ae into main Dec 12, 2023
8 checks passed
@avalanche123 avalanche123 deleted the fix-resource-refs branch December 12, 2023 15:44
Copy link

@jastang jastang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @avalanche123 !

"""
The `ObjectReference`s for the resources composed by this composite resources.
"""
resourceRefs: [ObjectReference!]!
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thephred @miloszsobczak does the console need to use this new field?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this for parity with other ref fields, but console could always use it using fieldPath or json fields

Comment on lines +218 to +220
if !apierrors.IsNotFound(err) {
graphql.AddError(ctx, errors.Wrap(err, errGetComposed))
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: add comment to xref the change in Crossplane's behaviour for context

@@ -215,7 +215,9 @@ func (r *compositeResourceSpec) Resources(ctx context.Context, obj *model.Compos
xrc.SetKind(ref.Kind)
nn := types.NamespacedName{Namespace: ref.Namespace, Name: ref.Name}
if err := c.Get(ctx, nn, xrc); err != nil {
graphql.AddError(ctx, errors.Wrap(err, errGetComposed))
if !apierrors.IsNotFound(err) {
Copy link
Member

@thephred thephred Dec 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An alternative would be to not consider not found a GraphQL error. We could either return a union that is the found object or not found maybe including the object ref or we could just not include not found refs as you have it here and rely on the consumer to compare with the objectrefs field to see what wasn't fetched.

The reason I'm saying all this is because for the console to consume this we'll have to turn on the feature that shows data even when there is an error and parse the error to see if it is this one somehow to keep from showing the user an error.

Copy link
Collaborator Author

@avalanche123 avalanche123 Dec 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sttts
Copy link
Collaborator

sttts commented Dec 15, 2023

Don't think crossplane/crossplane#4858 changed anything here. It was server side before, but with dry-run. So it was a two-phase commit before as well, with the short chance to see dangling references. There are more such places in Crossplane with that pattern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants