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-codegen.sh does not work on M1 mac out of the box #732

Open
1 of 4 tasks
aariv1 opened this issue May 7, 2024 · 7 comments · May be fixed by #733
Open
1 of 4 tasks

update-codegen.sh does not work on M1 mac out of the box #732

aariv1 opened this issue May 7, 2024 · 7 comments · May be fixed by #733
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@aariv1
Copy link

aariv1 commented May 7, 2024

Area

  • Scheduler
  • Controller
  • Helm Chart
  • Documents

Other components

codegen

What happened?

This is more of an annoyance but when you execute ./hack/update-codegen.sh on m1 mac it by default fails because realpath fails if the path you are requesting does not exist. The error in this case is simply:
realpath: ./hack/tools: No such file or directory

What did you expect to happen?

Expectation is that you could run the update-codegen.sh without needing to create the tools directory beforehand

For example something like this:

TOOLS_DIR=$(realpath ./hack) TOOLS_DIR+="/tools"

How can we reproduce it (as minimally and precisely as possible)?

On at least m1 mach clone the repo and execute hack/update-codegen.sh

Anything else we need to know?

No response

Kubernetes version

$ kubectl version
# paste output here

Scheduler Plugins version

release-1.28
@aariv1 aariv1 added the kind/bug Categorizes issue or PR as related to a bug. label May 7, 2024
@Huang-Wei
Copy link
Contributor

@aariv1 does adding the following line work for you locally? (if so, feel free to raise a PR)

diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh
index 6303a29c..0f626256 100755
--- a/hack/update-codegen.sh
+++ b/hack/update-codegen.sh
@@ -19,6 +19,7 @@ set -o nounset
 set -o pipefail
 
 SCRIPT_ROOT=$(dirname "${BASH_SOURCE[@]}")/..
+mkdir -p "{SCRIPT_ROOT}/hack/tools/bin"
 
 TOOLS_DIR=$(realpath ./hack/tools)
 TOOLS_BIN_DIR="${TOOLS_DIR}/bin"

@googs1025
Copy link
Member

@aariv1 I encountered the same issue on my Mac, but when I used Ubuntu, everything worked fine. Maybe you could try using Linux to see if it helps.

@aariv1
Copy link
Author

aariv1 commented May 8, 2024

Adding mkdir -p "${SCRIPT_ROOT}/hack/tools/bin" does work (although the codegen is still broken #729). I'll raise a pr anyway. Thank you

@aariv1
Copy link
Author

aariv1 commented May 8, 2024

/assign

@aariv1 aariv1 linked a pull request May 8, 2024 that will close this issue
@clubanderson
Copy link

applied this fix and then received when the script ran

${CONTROLLER_GEN} object:headerFile="hack/boilerplate/boilerplate.generatego.txt" \
  paths="./apis/scheduling/..."
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=0x105464b24]

goroutine 194 [running]:
go/types.(*Checker).handleBailout(0x140017db600, 0x14000529d18)
        /Users/andan02/.gvm/gos/go1.22.2/src/go/types/check.go:367 +0x9c
panic({0x10573d360?, 0x105cd7e90?})
        /Users/andan02/.gvm/gos/go1.22.2/src/runtime/panic.go:770 +0x124
go/types.(*StdSizes).Sizeof(0x0, {0x105807b70, 0x105ce0640})
        /Users/andan02/.gvm/gos/go1.22.2/src/go/types/sizes.go:228 +0x314
go/types.(*Config).sizeof(...)
        /Users/andan02/.gvm/gos/go1.22.2/src/go/types/sizes.go:333
go/types.representableConst.func1({0x105807b70?, 0x105ce0640?})
        /Users/andan02/.gvm/gos/go1.22.2/src/go/types/const.go:76 +0x9c
go/types.representableConst({0x10580ddb0, 0x105cac7c0}, 0x140017db600, 0x105ce0640, 0x0)
        /Users/andan02/.gvm/gos/go1.22.2/src/go/types/const.go:92 +0x138
go/types.(*Checker).arrayLength(0x140017db600, {0x10580c180, 0x14000547460?})
        /Users/andan02/.gvm/gos/go1.22.2/src/go/types/typexpr.go:510 +0x238
go/types.(*Checker).typInternal(0x140017db600, {0x10580a7a0, 0x140005522a0}, 0x0)
        /Users/andan02/.gvm/gos/go1.22.2/src/go/types/typexpr.go:299 +0x3bc
go/types.(*Checker).definedType(0x140017db600, {0x10580a7a0, 0x140005522a0}, 0x104ee0a5c?)
        /Users/andan02/.gvm/gos/go1.22.2/src/go/types/typexpr.go:180 +0x2c
go/types.(*Checker).varType(0x140017db600, {0x10580a7a0, 0x140005522a0})
        /Users/andan02/.gvm/gos/go1.22.2/src/go/types/typexpr.go:145 +0x2c
go/types.(*Checker).structType(0x140017db600, 0x1400055b920, 0x1400055b920?)
        /Users/andan02/.gvm/gos/go1.22.2/src/go/types/struct.go:113 +0x128
go/types.(*Checker).typInternal(0x140017db600, {0x10580a710, 0x14001071590}, 0x1400055dbd0)
        /Users/andan02/.gvm/gos/go1.22.2/src/go/types/typexpr.go:316 +0xed0
go/types.(*Checker).definedType(0x140017db600, {0x10580a710, 0x14001071590}, 0x105579956?)
        /Users/andan02/.gvm/gos/go1.22.2/src/go/types/typexpr.go:180 +0x2c
go/types.(*Checker).typeDecl(0x140017db600, 0x1400055dbd0, 0x14000545680, 0x0)
        /Users/andan02/.gvm/gos/go1.22.2/src/go/types/decl.go:615 +0x39c
go/types.(*Checker).objDecl(0x140017db600, {0x105812d20, 0x1400055dbd0}, 0x0)
        /Users/andan02/.gvm/gos/go1.22.2/src/go/types/decl.go:197 +0x880
go/types.(*Checker).packageObjects(0x140017db600)
        /Users/andan02/.gvm/gos/go1.22.2/src/go/types/resolver.go:681 +0x3c0
go/types.(*Checker).checkFiles(0x140017db600, {0x14000d49aa0, 0x3, 0x3})
        /Users/andan02/.gvm/gos/go1.22.2/src/go/types/check.go:408 +0x164
go/types.(*Checker).Files(...)
        /Users/andan02/.gvm/gos/go1.22.2/src/go/types/check.go:372
sigs.k8s.io/controller-tools/pkg/loader.(*loader).typeCheck(0x140003b8ea0, 0x1400042e900)
        /Users/andan02/.gvm/pkgsets/go1.22.2/global/pkg/mod/sigs.k8s.io/controller-tools@v0.11.1/pkg/loader/loader.go:286 +0x2d8
sigs.k8s.io/controller-tools/pkg/loader.(*Package).NeedTypesInfo(0x1400042e900)
        /Users/andan02/.gvm/pkgsets/go1.22.2/global/pkg/mod/sigs.k8s.io/controller-tools@v0.11.1/pkg/loader/loader.go:99 +0x44
sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check(0x1400069ce40, 0x1400042e900)
        /Users/andan02/.gvm/pkgsets/go1.22.2/global/pkg/mod/sigs.k8s.io/controller-tools@v0.11.1/pkg/loader/refs.go:268 +0x304
sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check.func1(0x5a?)
        /Users/andan02/.gvm/pkgsets/go1.22.2/global/pkg/mod/sigs.k8s.io/controller-tools@v0.11.1/pkg/loader/refs.go:262 +0x58
created by sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check in goroutine 178
        /Users/andan02/.gvm/pkgsets/go1.22.2/global/pkg/mod/sigs.k8s.io/controller-tools@v0.11.1/pkg/loader/refs.go:260 +0x230

not sure if this is related to the underlying issue here.

@Huang-Wei
Copy link
Contributor

@clubanderson your issue seems to be caused by Go 1.22 - which is incompatible w/ the controller-gen version. Go 1.21 works:

go 1.21

Meanwhile I will bump the version of controller-gen so Go 1.22 can also work.

@clubanderson
Copy link

yep - that worked -

gvm install go1.21.0
gvm use go1.21.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants