hivelocity / cluster-api-provider-hivelocity

Kubernetes Cluster API Provider Hivelocity provides a consistent deployment and day 2 operations of "self-managed" Kubernetes clusters on Hivelocity.
https://hivelocity.github.io/cluster-api-provider-hivelocity/user/introduction.html
Apache License 2.0
6 stars 3 forks source link

workload cluster fails on generate-manifests Makefile target #148

Open rgarcia opened 5 months ago

rgarcia commented 5 months ago

/kind bug

What steps did you take and what happened:

export CLUSTER_NAME=management-cluster
export CONTROL_PLANE_MACHINE_COUNT=1
export HIVELOCITY_CONTROL_PLANE_DEVICE_TYPE=vps.md.amd
export HIVELOCITY_API_KEY=<api key>
export HIVELOCITY_SSH_KEY=caphv-ssh-key
export HIVELOCITY_WORKER_DEVICE_TYPE=vps.md.amd
export KUBERNETES_VERSION=v1.29.2
export WORKER_MACHINE_COUNT=3
export HIVELOCITY_REGION=nyc1
make tilt-up

Clicked on the "Create Hivelocity Cluster" button in the top nav of the tilt web UI.

Fails with the following logs:

Running cmd: make create-workload-cluster
/Users/rafaelgarcia/gometal/examples/gometal/cluster-api-hivelocity/cluster-api-provider-hivelocity/hack/tools/bin/controller-gen \
            paths=./api/... \
            paths=./controllers/... \
            crd:crdVersions=v1 \
            rbac:roleName=manager-role \
            output:crd:dir=./config/crd/bases \
            output:webhook:dir=./config/webhook \
            webhook
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
    panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x104708604]

goroutine 165 [running]:
go/types.(*Checker).handleBailout(0x140002f8200, 0x1400215dd18)
    /opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/check.go:367 +0x9c
panic({0x1049e1a60?, 0x104f7caf0?})
    /opt/homebrew/Cellar/go/1.22.1/libexec/src/runtime/panic.go:770 +0x124
go/types.(*StdSizes).Sizeof(0x0, {0x104aac990, 0x104f85300})
    /opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/sizes.go:228 +0x314
go/types.(*Config).sizeof(...)
    /opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/sizes.go:333
go/types.representableConst.func1({0x104aac990?, 0x104f85300?})
    /opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/const.go:76 +0x9c
go/types.representableConst({0x104ab2c30, 0x104f50240}, 0x140002f8200, 0x104f85300, 0x1400215d468)
    /opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/const.go:92 +0x138
go/types.(*Checker).representation(0x140002f8200, 0x140019815c0, 0x104f85300)
    /opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/const.go:256 +0x68
go/types.(*Checker).implicitTypeAndValue(0x140002f8200, 0x140019815c0, {0x104aac9b8, 0x1400025cb60})
    /opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/expr.go:375 +0x304
go/types.(*Checker).assignment(0x140002f8200, 0x140019815c0, {0x104aac9b8, 0x1400025cb60}, {0x104820081, 0x14})
    /opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/assignments.go:52 +0x23c
go/types.(*Checker).initConst(0x140002f8200, 0x14001890840, 0x140019815c0)
    /opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/assignments.go:126 +0x274
go/types.(*Checker).constDecl(0x140002f8200, 0x14001890840, {0x104aaf538, 0x14001bc5cc0}, {0x104aaf538, 0x14001bc5ce0}, 0x0)
    /opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/decl.go:490 +0x250
go/types.(*Checker).objDecl(0x140002f8200, {0x104ab7d20, 0x14001890840}, 0x0)
    /opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/decl.go:191 +0x84c
go/types.(*Checker).packageObjects(0x140002f8200)
    /opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/resolver.go:693 +0x468
go/types.(*Checker).checkFiles(0x140002f8200, {0x14001bb1b30, 0x5, 0x5})
    /opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/check.go:408 +0x164
go/types.(*Checker).Files(...)
    /opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/check.go:372
sigs.k8s.io/controller-tools/pkg/loader.(*loader).typeCheck(0x140002a75c0, 0x140008051c0)
    /Users/rafaelgarcia/go/pkg/mod/sigs.k8s.io/controller-tools@v0.13.0/pkg/loader/loader.go:286 +0x2d8
sigs.k8s.io/controller-tools/pkg/loader.(*Package).NeedTypesInfo(0x140008051c0)
    /Users/rafaelgarcia/go/pkg/mod/sigs.k8s.io/controller-tools@v0.13.0/pkg/loader/loader.go:99 +0x44
sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check(0x14000ad6f90, 0x140008051c0)
    /Users/rafaelgarcia/go/pkg/mod/sigs.k8s.io/controller-tools@v0.13.0/pkg/loader/refs.go:268 +0x304
sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check.func1(0x95?)
    /Users/rafaelgarcia/go/pkg/mod/sigs.k8s.io/controller-tools@v0.13.0/pkg/loader/refs.go:262 +0x58
created by sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check in goroutine 51
    /Users/rafaelgarcia/go/pkg/mod/sigs.k8s.io/controller-tools@v0.13.0/pkg/loader/refs.go:260 +0x230
make[1]: *** [generate-manifests] Error 2
make create-workload-cluster exited with exit code 2

What did you expect to happen: A Hivelocity k8s cluster to get created.

Anything else you would like to add: No

Environment:

rgarcia commented 5 months ago

hey there--let me know if this isn't the best place to ask this question, or if there's anything I can do to provide more information. Would love to use this provider!

guettli commented 5 months ago

@rgarcia I am looking at your issue now. A panic should not happen, even if the config is invalid.

BTW I see you use vps.md.amd. At the moment our controller only uses the API for bare-metal servers. We use these API endpoints: https://developers.hivelocity.net/reference/bare-metal-devices

Do you want to use caphv for bare-metal servers or VPS servers?

guettli commented 5 months ago

We have not tested it on Mac yet.

Could you try the same commands on a Linux machine or VM?

The error does not happen in our code. We just use the controller-gen tool.

I bump the version from 0.13.0 to 0.14.0. Maybe this solves the issues for you.

Please switch to this branch: tg/upgrade-to-controller-tools-v0.14.0

Then:

rm hack/tools/bin/controller-gen 

make generate-manifests 

You don't need to start Tilt for that.

Please tell us if running on Linux or the version bump helped.

guettli commented 5 months ago

@rgarcia The update of controller-tools was merged into the main branch. If you fetch the latest main branch, the error should be gone. Please tell us if this worked for you. And feel free to create a new issue if something is not clear.