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

Update to the latest upjet and crossplane-runtime versions #29

Closed
displague opened this issue Aug 31, 2023 · 10 comments
Closed

Update to the latest upjet and crossplane-runtime versions #29

displague opened this issue Aug 31, 2023 · 10 comments
Labels
enhancement New feature or request

Comments

@displague
Copy link
Collaborator

displague commented Aug 31, 2023

What problem are you facing?

This issue was originally created to track Equinix TF Provider updates. Crossplane and TF are now in sync with v1.18.0. https://github.com/equinix/terraform-provider-equinix/releases

Reframing this issue to deal with problems encountered when trying to update upjet, crossplane-runtime, and other aspects of the upjet provider template: https://github.com/upbound/upjet-provider-template/

How could Equinix Provider help solve your problem?

Update per #25

@displague displague added the enhancement New feature or request label Aug 31, 2023
@displague
Copy link
Collaborator Author

While updating to 1.17.0:

# git clone --recursive ...; cd provider-jet-equinix
# update Terraform provider version in Makefile
$ make clean
$ make generate
...
go: downloading github.com/josharian/intern v1.0.0
panic: cannot store examples: cannot store example manifest for resource: equinix_metal_port_vlan_attachment.*: cannot resolve references of resource: failed to resolve references of paved: cannot get string value from paved: spec.forProvider.vxlan: spec.forProvider.vxlan: not a string

goroutine 1 [running]:
github.com/upbound/upjet/pkg/pipeline.Run(0x40005af700, {0x40000485c0, 0x29})
        /home/mjohansson/go/pkg/mod/github.com/upbound/[email protected]/pkg/pipeline/run.go:104 +0xb8c
main.main()
        /home/mjohansson/dev/provider-jet-equinix/cmd/generator/main.go:39 +0x5c
exit status 2
apis/generate.go:37: running "go": exit status 1
generate: open /home/mjohansson/dev/provider-jet-equinix/apis/ecx/v1alpha1/zz_generated.deepcopy.go: no such file or directory
17:51:53 [FAIL]
make[1]: *** [build/makelib/golang.mk:240: go.generate] Error 1
make: *** [build/makelib/common.mk:434: generate] Error 2

@displague
Copy link
Collaborator Author

displague commented Oct 1, 2023

@displague
Copy link
Collaborator Author

displague commented Oct 24, 2023

The paved example parsing issues in #31 are narrowed down to changes introduced between the TF Provider v1.13 and v1.14:
equinix/terraform-provider-equinix@v1.13.0...v1.14.0 (patch)

make clean; make generate works with the Makefile TF provider version set to v1.13.0 (nothing changed, current main branch) but not with v1.14.0 (the only change).

I do not see any changes related to VLAN / VXLAN fields here, not in schema.json and not in the equinix_metal_port_vlan_attachment examples:
https://gist.github.com/displague/52b7dffce2e7560757dce1589340ce21

@displague
Copy link
Collaborator Author

displague commented Oct 25, 2023

I've discovered that examples can be skipped by modifying or removing the .md file from the working path where the docs have been fetched as part of the pull-docs task (.work/equinix/equinix/docs/resources in this case).

diff --git a/Makefile b/Makefile
index aa21d62..fbc41ab 100644
--- a/Makefile
+++ b/Makefile
@@ -125,6 +125,7 @@ pull-docs:
 		git clone -c advice.detachedHead=false --depth 1 --filter=blob:none --branch "v$(TERRAFORM_PROVIDER_VERSION)" --sparse "$(TERRAFORM_PROVIDER_REPO)" "$(WORK_DIR)/$(TERRAFORM_PROVIDER_SOURCE)"; \
 	fi
 	@git -C "$(WORK_DIR)/$(TERRAFORM_PROVIDER_SOURCE)" sparse-checkout set "$(TERRAFORM_DOCS_PATH)"
+	rm -f "$(WORK_DIR)/$(TERRAFORM_PROVIDER_SOURCE)/$(TERRAFORM_DOCS_PATH)/equinix_metal_port_vlan_attachment.md"
 
 generate.init: $(TERRAFORM_PROVIDER_SCHEMA) pull-docs
 

This has allowed for experimentation with the examples to narrow down what is causing the problem.

resource "equinix_metal_port_vlan_attachment" "test" {
  device_id = equinix_metal_device_network_type.test.id
  port_name = "eth1"
  vlan_vnid = equinix_metal_vlan.test.vxlan
}

The equinix_metal_vlan.test.vxlan field is the only part of both examples present in equinix_metal_port_vlan_attachment.md that is not handled well. If this is changed to 1234, "1234", or equinix_metal_vlan.test.vlan (an invalid field for this resource) the parser moves along and succeeds. I suspect that this being a TypeInt, Computed, and Optional field may be related.

@displague
Copy link
Collaborator Author

After the problem with this example, the next hurdle is:

Generated 34 resources!
angryjet: error: error loading packages using pattern ./...: /home/marques/src/provider-jet-equinix/apis/ecx/v1alpha1/zz_generated.managedlist.go:26:14: cannot use &l.Items[i] (value of type *L2ConnectionAccepter) as "github.com/crossplane/crossplane-runtime/pkg/resource".Managed value in assignment: *L2ConnectionAccepter does not implement "github.com/crossplane/crossplane-runtime/pkg/resource".Managed (missing method GetManagementPolicies)

I'm going to open a PR that only updates the provider to 1.18.0 while removing the example that can't be handled. Any other updates will follow in another PR.

@displague displague mentioned this issue Oct 25, 2023
2 tasks
@displague displague changed the title Update to the latest TF provider Update to the latest upjet and crossplane-runtime versions Oct 26, 2023
@AtzeDeVries
Copy link

Any updates here? I am running into the same problem as described here

@AtzeDeVries
Copy link

AtzeDeVries commented Feb 6, 2024

@displague i managed to solve it through some help of the crossplane slack channel. It boils down to

go get github.com/crossplane/crossplane-tools@master && go mod tidy
make generate
go get github.com/crossplane/[email protected] && go mod tidy
make generate

I also need to sync internal/features/features.go and cmd/provider/main.go with the upstream upjet template.

ref: https://crossplane.slack.com/archives/C05T19TB729/p1707151183413049

@displague
Copy link
Collaborator Author

displague commented Feb 6, 2024

@AtzeDeVries could you open a PR with your changes?

I have a couple local deviations from this branch in the #34, I applied the above changes and neither ran make generate successfully.

apis/ecx/v1alpha1/zz_generated.managed.go:42:17: mg.Spec.ProviderReference undefined (type L2ConnectionSpec has no field or method ProviderReference)

@displague
Copy link
Collaborator Author

I've split out some of the changes into #39. Make generate is working in this branch. I'm looking to get those changes merged first and then revisit the other changes from #34 which applied other upstream template changes.

@displague
Copy link
Collaborator Author

Closed by #52

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment