crossplane-contrib / function-kcl

Crossplane Composition Functions using KCL Programming Language
Apache License 2.0
42 stars 17 forks source link

Composite resource error "encountered composed resource without required "crossplane.io/composition-resource-name" when not specifying any metadata.name in a resource #199

Open spastorclovr opened 5 days ago

spastorclovr commented 5 days ago

What happened?

In a composition, I am creating a Helm Release using the Helm provider. There is only one resource that needs to be created (the Release object) so I am not specifying any metadata.name to let the function generate a unique name.

This is the output of crossplane beta trace :point_down:

NAME                                    SYNCED   READY   STATUS
WebserviceClaim/contour-app (default)   True     False   Waiting: Claim is waiting for composite resource to become Ready
└─ Webservice/contour-app-h4sf5         False    False   ReconcileError: ...ut required "crossplane.io/composition-resource-name" annotation
   └─ Release/contour-app-h4sf5-d9m2b   True     True    Available

and the error

cannot compose resources: cannot get existing composed resources: encountered composed resource without required "crossplane.io/composition-resource-name" annotation

-> The Managed resource is being created -> The Composite resource is complaining about the "crossplane.io/composition-resource-name being missing.

Indeed looking at the Labels of the composed resource :point_down:

 Labels:       
              crossplane.io/claim-name=contour-app
              crossplane.io/claim-namespace=default
              crossplane.io/composite=contour-app-9wrft
Annotations:  
               crossplane.io/external-create-pending: 2024-11-22T11:20:03Z
              crossplane.io/external-create-succeeded: 2024-11-22T11:20:05Z
              crossplane.io/external-name: contour-app-9wrft-d9tj5
API Version:  helm.crossplane.io/v1beta1

When specifying a name this is the labels/annotations I get for one managed resource

Labels:  
              crossplane.io/claim-name=contour-app
              crossplane.io/claim-namespace=default
              crossplane.io/composite=contour-app-hb94c
Annotations:  
              crossplane.io/composition-resource-name: release2
              crossplane.io/external-create-pending: 2024-11-22T11:33:11Z
              crossplane.io/external-create-succeeded: 2024-11-22T11:33:13Z
              crossplane.io/external-name: release2

But then, when setting up a name for the resources I realize this would conflict with new resources created by the same claim. I may be missing something here. It feels like there is always a need to specify a name for each resources and thus take care of its uniqueness?

Thanks!

What environment did it happen in?

Function version: 0.10.10