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

crossplane render does not work with this function #53

Open
MichelJansen91 opened this issue Nov 29, 2024 · 7 comments · May be fixed by #58
Open

crossplane render does not work with this function #53

MichelJansen91 opened this issue Nov 29, 2024 · 7 comments · May be fixed by #58
Labels
bug Something isn't working

Comments

@MichelJansen91
Copy link

What happened?

Crossplane render command does not seem to work when using this function

How can we reproduce it?

  1. Take https://github.com/upbound/composition-testing/tree/main/crossplane-cli/render/extra_resources as basis
  2. Migrate Environment config from v1alpha1 to v1beta1 (are locatedextraresources/resources.yaml)
  3. Add function-environment-configs function to functions.yaml
  4. Add following snippet to the composition:
    - step: from-environment
      functionRef:
        name: function-environment-configs
      input:
        apiVersion: environmentconfigs.fn.crossplane.io/v1beta1
        kind: Input
        spec:
          environmentConfigs:
          - type: Reference
            ref:
              name: webdev-dev
  1. Try to render with:
crossplane render \                                                                                            128 х  4s  07:37:47
  --extra-resources extra-resources \
  --include-full-xr \
  --include-context \
  xr.yaml composition.yaml functions.yaml

Then you will get:

crossplane: error: cannot render composite resource: pipeline step "from-environment" returned a fatal result: cannot get selected environment configs: Required environment config "environment-config-0" not found

What environment did it happen in?

Function version: v0.1.0
Crossplane version v1.18.0 running locally on MacOS Sequoia

@MichelJansen91 MichelJansen91 added the bug Something isn't working label Nov 29, 2024
@phisco
Copy link
Collaborator

phisco commented Nov 29, 2024

The problem is just with the migration to v1beta1 of EnvironmentConfigs, the function only knows about v1alpha1 still. In a real cluster that would be fine, because both versions are still defined and crossplane would be able to find it as v1alpha1 whatever version you created. But crossplane beta render is doing an exact match and is not able to automatically convert the v1beta1 you provided to the requested v1alpha1.

@olvesh
Copy link

olvesh commented Dec 4, 2024

Just stumbled upon this as well. Will this work the other way as well, i.e. if I updated all references to apiextensions.crossplane.io/v1alpha1 in this repo, would also the v1alpha1 resources in crossplane-clusters still work?

It is a bit cumbersome that all versions here reference v1beta1, and when used for our testing setup it fails because it internally expects v1alpha1...

I am a bit new and have not completely understood how to upgrade functions etc and keeping cross version compatibility.

@olvesh olvesh linked a pull request Dec 5, 2024 that will close this issue
2 tasks
@olvesh
Copy link

olvesh commented Dec 11, 2024

@phisco - is this something that will be fixed? I use this function in our test-pipeline, and this issue blocks running the pipeline...

@phisco
Copy link
Collaborator

phisco commented Dec 12, 2024

@olvesh
We tried thinking about this, but a solution to the problem would be probably not worth it. Right now both alpha and beta EnvironmentConfigs are supported by Crossplane, as I was saying above, in a real Cluster this would work fine, it's just crossplane beta render that doesn't know how to convert the available versions and how to convert between the two. I'd suggest you to just stick to alpha EnvironmentConfigs for now, there is no difference in the schema. In a few releases we'll bump the storage version in Crossplane and possibly drop alpha altogether and we'll then mark the required Crossplane version for this function and switch to use beta.

@olvesh
Copy link

olvesh commented Dec 13, 2024

Thanks @phisco - I have been trying that as well, it works using the render testing, but not when starting the function in my kind test setup, it fails with

Warning  ComposeResources   25s (x12 over 3m51s)  defined/compositeresourcedefinition.apiextensions.crossplane.io  cannot compose resources: cannot run Composition pipeline step "environmentConfigs": cannot get
 gRPC client connection for Function "function-environment-configs": cannot find an active FunctionRevision (a FunctionRevision with spec.desiredState: Active)

even though the Function and FunctionRevision is deployed and reports no errors.

NAME                                                                         INSTALLED   HEALTHY   PACKAGE                                                                  AGE
function.pkg.crossplane.io/crossplane-contrib-function-environment-configs   True        True      xpkg.upbound.io/crossplane-contrib/function-environment-configs:v0.1.0   8m53s
function.pkg.crossplane.io/crossplane-contrib-function-go-templating         True        True      xpkg.upbound.io/crossplane-contrib/function-go-templating:v0.8.0         8m58s
function.pkg.crossplane.io/crossplane-contrib-function-patch-and-transform   True        True      xpkg.upbound.io/crossplane-contrib/function-patch-and-transform:v0.7.0   9m2s

NAME                                                                                              HEALTHY   REVISION   IMAGE                                                                    STATE    DEP-FOUND   DEP-INSTALLED   AGE
functionrevision.pkg.crossplane.io/crossplane-contrib-function-environment-configs-b8662fdf279f   True      1          xpkg.upbound.io/crossplane-contrib/function-environment-configs:v0.1.0   Active                               8m52s
functionrevision.pkg.crossplane.io/crossplane-contrib-function-go-templating-ca77dfff64bf         True      1          xpkg.upbound.io/crossplane-contrib/function-go-templating:v0.8.0         Active                               8m57s
functionrevision.pkg.crossplane.io/crossplane-contrib-function-patch-and-transform-6a1ab24d2512   True      1          xpkg.upbound.io/crossplane-contrib/function-patch-and-transform:v0.7.0   Active                               9m1s

Thats why I tried to push forward.. Not sure if it is related though, but being relatively new to Crossplane I thought it might be.

@phisco
Copy link
Collaborator

phisco commented Dec 13, 2024

Your function is named crossplane-contrib-function-environment-configs, not just function-environment-configs. That's because it was installed as a dependency, so the org is used in the name. If you update your composition to reference the function by the right name, it should work

@olvesh
Copy link

olvesh commented Dec 13, 2024

Yes, I just found that as well. Lots of paper cuts with crossplane 😅
I haven't seen that covered in the docs yet, and it is easy to get blinded by all the labels and names... I initially thought they were selected by use of labels, but I discovered there were no labels on the functions...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants