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

chore: unite the bin cache dir for all projects in go.work #609

Merged
merged 9 commits into from
Jul 2, 2024

Conversation

Chever-John
Copy link
Contributor

@Chever-John Chever-John commented Jun 25, 2024

Fix #426

I am working on issue #426.
I hope that my work is on the right track. I have thoroughly run every makefile command related to the project to ensure everything is functioning correctly.

Looking forward to your feedback and hoping my contribution is valuable.

Thank you!

Copy link

codecov bot commented Jun 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.41%. Comparing base (e95743b) to head (76d4771).
Report is 13 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #609      +/-   ##
==========================================
- Coverage   89.81%   88.41%   -1.41%     
==========================================
  Files         109      111       +2     
  Lines        5164     5308     +144     
==========================================
+ Hits         4638     4693      +55     
- Misses        355      435      +80     
- Partials      171      180       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@spacewander spacewander left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to update
e2e/Makefile
binary cache in .github/workflows/test.yml & .github/workflows/lint.yml

@@ -89,7 +89,7 @@ KIND ?= kind
##@ Build Dependencies

## Location to install dependencies to
LOCALBIN ?= $(shell pwd)/bin
LOCALBIN ?= $(shell cd .. && pwd)/bin
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about using

LOCALBIN ?= $(dir $(lastword $(MAKEFILE_LIST)))bin

in the common.mk?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Chever-John
Would you give this a try? Thanks!

Copy link
Contributor Author

@Chever-John Chever-John Jun 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sry for late~

Yes, I have tried it.

I added the following code (A) into the common.mk file and commented out the corresponding code in the controller/Makefile as shown below (B):

A. code

LOCALBIN ?= $(dir $(lastword $(MAKEFILE_LIST)))
$(LOCALBIN):
	@mkdir -p $(LOCALBIN)

B. code

comment out the LOCALBIN ?= $(shell cd .. && pwd)/bin

## Location to install dependencies to
#LOCALBIN ?= $(shell cd .. && pwd)/bin
# Remember to remove tools downloaded into bin directory manually before updating them.
# If they need to be updated frequently, we can consider to store them in the `Dockerfile.dev`.
$(LOCALBIN):
	mkdir -p $(LOCALBIN)

And I tried to run the command make sth in the htnn/controller dir as follows:

╭─cheverjohn at Jonathan’s MacBook Pro in ~/Workspace/OpenSource/github.com/Chever-John/htnngit:(chore/unite-the-bin-cache-dir*)
╰─± cd controller 
╭─cheverjohn at Jonathan’s MacBook Pro in ~/Workspace/OpenSource/github.com/Chever-John/htnn/controllergit:(chore/unite-the-bin-cache-dir*)
╰─± make controller-gen
test -s ..//controller-gen && ..//controller-gen --version | grep -q v0.13.0 || \
        GOBIN=../ go install sigs.k8s.io/controller-tools/cmd/[email protected]
cannot install, GOBIN must be an absolute path
make: *** [..//controller-gen] Error 1

Then errors came out:)

Copy link
Contributor Author

@Chever-John Chever-John Jun 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about use the following code:

# common.mk
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
LOCALBIN := $(ROOT_DIR)/bin
$(LOCALBIN):
	@mkdir -p $(LOCALBIN)

@spacewander

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update!!!

from ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) to ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))

e2e/istio.sh Outdated
@@ -17,7 +17,9 @@
set -eo pipefail
set -x

HELM="$(pwd)/bin/helm"
PARENT_DIR="$(cd .. && pwd)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can pass LOCALBIN to the script, like

htnn/Makefile

Line 44 in e95743b

LOCALBIN=$(LOCALBIN) tools/gen-crd-code.sh

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sry, I missed it here.

Please wait for me for a few minutes.

replace `LOCALBIN ?=$(cd .. && pwd)/bin` to the 

```makefile

ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
LOCALBIN := $(ROOT_DIR)/bin
```
Copy link
Contributor Author

@Chever-John Chever-John left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@spacewander

Here is my solution.

common.mk Outdated
@@ -16,6 +16,11 @@ SHELL = /bin/bash
OS = $(shell uname)
IN_CI ?=

ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

linke to #609 (comment)

Here is my solution:)

@spacewander

# Remember to remove tools downloaded into bin directory manually before updating them.
# If they need to be updated frequently, we can consider to store them in the `Dockerfile.dev`.
$(LOCALBIN):
mkdir -p $(LOCALBIN)
#$(LOCALBIN):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just comment out the above code temporarily.

Copy link
Contributor Author

@Chever-John Chever-John left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to update e2e/Makefile binary cache in .github/workflows/test.yml & .github/workflows/lint.yml

I found some code related to binary cache in the test.yml file. Is there any related code in the lint.yml file (perhaps not)?

@spacewander
Copy link
Member

Don't forget to update e2e/Makefile binary cache in .github/workflows/test.yml & .github/workflows/lint.yml

I found some code related to binary cache in the test.yml file. Is there any related code in the lint.yml file (perhaps not)?

You are right, there is no need to update lint.yml because it's already using ./bin.

@github-actions github-actions bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jul 1, 2024
@Chever-John
Copy link
Contributor Author

Everything is set up:)
I hope this will run smoothly.

@Chever-John
Copy link
Contributor Author

Chever-John commented Jul 1, 2024

During local testing, I encountered an issue where the local Go version is 1.22.x and the controller-gen version is 0.13.0 (default in the controller project). When I execute the command make manifests, the following error occurs:

~/Workspace/OpenSource/github.com/Chever-John/htnn/controller
☹  ../bin/controller-gen --version                                                                                     chore/unite-the-bin-cache-dir 53e855c
Version: v0.13.0

~/Workspace/OpenSource/github.com/Chever-John/htnn/controller
☹  go version                                                                                                          chore/unite-the-bin-cache-dir 53e855c
go version go1.22.1 darwin/arm64

~/Workspace/OpenSource/github.com/Chever-John/htnn/controller
☺  make manifests                                                                                                      chore/unite-the-bin-cache-dir 53e855c
/Users/cheverjohn/Workspace/OpenSource/github.com/Chever-John/htnn/bin/controller-gen rbac:roleName=htnn-role crd:ignoreUnexportedFields=true \
                output:crd:artifacts:config=../manifests/charts/htnn-controller/templates/crds/ \
                output:rbac:artifacts:config=../manifests/charts/htnn-controller/templates/rbac/ \
                paths="../types/..." paths="./internal/controller/..."
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=0x102a1c604]

goroutine 182 [running]:
go/types.(*Checker).handleBailout(0x14000c27800, 0x14001811d18)
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/check.go:367 +0x9c
panic({0x102cf5a60?, 0x103294af0?})
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/runtime/panic.go:770 +0x124
go/types.(*StdSizes).Sizeof(0x0, {0x102dc0990, 0x10329d300})
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/sizes.go:228 +0x314
go/types.(*Config).sizeof(...)
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/sizes.go:333
go/types.representableConst.func1({0x102dc0990?, 0x10329d300?})
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/const.go:76 +0x9c
go/types.representableConst({0x102dc6c30, 0x103268240}, 0x14000c27800, 0x10329d300, 0x14001811468)
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/const.go:92 +0x138
go/types.(*Checker).representation(0x14000c27800, 0x14001814d00, 0x10329d300)
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/const.go:256 +0x68
go/types.(*Checker).implicitTypeAndValue(0x14000c27800, 0x14001814d00, {0x102dc09b8, 0x140002342a0})
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/expr.go:375 +0x304
go/types.(*Checker).assignment(0x14000c27800, 0x14001814d00, {0x102dc09b8, 0x140002342a0}, {0x102b34081, 0x14})
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/assignments.go:52 +0x23c
go/types.(*Checker).initConst(0x14000c27800, 0x14001dbf500, 0x14001814d00)
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/assignments.go:126 +0x274
go/types.(*Checker).constDecl(0x14000c27800, 0x14001dbf500, {0x102dc3538, 0x1400132a1a0}, {0x102dc3538, 0x1400132a1c0}, 0x0)
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/decl.go:490 +0x250
go/types.(*Checker).objDecl(0x14000c27800, {0x102dcbd20, 0x14001dbf500}, 0x0)
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/decl.go:191 +0x84c
go/types.(*Checker).packageObjects(0x14000c27800)
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/resolver.go:693 +0x468
go/types.(*Checker).checkFiles(0x14000c27800, {0x14001180000, 0x5, 0x5})
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/check.go:408 +0x164
go/types.(*Checker).Files(...)
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/check.go:372
sigs.k8s.io/controller-tools/pkg/loader.(*loader).typeCheck(0x1400025f4d0, 0x14001090fc0)
        /Users/cheverjohn/Workspace/golang/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/loader.go:286 +0x2d8
sigs.k8s.io/controller-tools/pkg/loader.(*Package).NeedTypesInfo(0x14001090fc0)
        /Users/cheverjohn/Workspace/golang/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/loader.go:99 +0x44
sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check(0x140017a7290, 0x14001090fc0)
        /Users/cheverjohn/Workspace/golang/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/refs.go:268 +0x304
sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check.func1(0x5b?)
        /Users/cheverjohn/Workspace/golang/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/refs.go:262 +0x58
created by sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check in goroutine 201
        /Users/cheverjohn/Workspace/golang/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/refs.go:260 +0x230
make: *** [manifests] Error 2

This problem can be stably reproduced.

Related discussion as following issues: kubernetes-sigs/controller-tools#888

Solution: change controller-gen version from v0.13.0 to v0.14.0.

I don't know how to fix this problem in which way. Should I create a new issue to fix it or just solve it in this PR?

@spacewander
Copy link
Member

During local testing, I encountered an issue where the local Go version is 1.22.x and the controller-gen version is 0.13.0 (default in the controller project). When I execute the command make manifests, the following error occurs:

~/Workspace/OpenSource/github.com/Chever-John/htnn/controller
☹  ../bin/controller-gen --version                                                                                     chore/unite-the-bin-cache-dir 53e855c
Version: v0.13.0

~/Workspace/OpenSource/github.com/Chever-John/htnn/controller
☹  go version                                                                                                          chore/unite-the-bin-cache-dir 53e855c
go version go1.22.1 darwin/arm64

~/Workspace/OpenSource/github.com/Chever-John/htnn/controller
☺  make manifests                                                                                                      chore/unite-the-bin-cache-dir 53e855c
/Users/cheverjohn/Workspace/OpenSource/github.com/Chever-John/htnn/bin/controller-gen rbac:roleName=htnn-role crd:ignoreUnexportedFields=true \
                output:crd:artifacts:config=../manifests/charts/htnn-controller/templates/crds/ \
                output:rbac:artifacts:config=../manifests/charts/htnn-controller/templates/rbac/ \
                paths="../types/..." paths="./internal/controller/..."
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=0x102a1c604]

goroutine 182 [running]:
go/types.(*Checker).handleBailout(0x14000c27800, 0x14001811d18)
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/check.go:367 +0x9c
panic({0x102cf5a60?, 0x103294af0?})
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/runtime/panic.go:770 +0x124
go/types.(*StdSizes).Sizeof(0x0, {0x102dc0990, 0x10329d300})
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/sizes.go:228 +0x314
go/types.(*Config).sizeof(...)
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/sizes.go:333
go/types.representableConst.func1({0x102dc0990?, 0x10329d300?})
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/const.go:76 +0x9c
go/types.representableConst({0x102dc6c30, 0x103268240}, 0x14000c27800, 0x10329d300, 0x14001811468)
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/const.go:92 +0x138
go/types.(*Checker).representation(0x14000c27800, 0x14001814d00, 0x10329d300)
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/const.go:256 +0x68
go/types.(*Checker).implicitTypeAndValue(0x14000c27800, 0x14001814d00, {0x102dc09b8, 0x140002342a0})
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/expr.go:375 +0x304
go/types.(*Checker).assignment(0x14000c27800, 0x14001814d00, {0x102dc09b8, 0x140002342a0}, {0x102b34081, 0x14})
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/assignments.go:52 +0x23c
go/types.(*Checker).initConst(0x14000c27800, 0x14001dbf500, 0x14001814d00)
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/assignments.go:126 +0x274
go/types.(*Checker).constDecl(0x14000c27800, 0x14001dbf500, {0x102dc3538, 0x1400132a1a0}, {0x102dc3538, 0x1400132a1c0}, 0x0)
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/decl.go:490 +0x250
go/types.(*Checker).objDecl(0x14000c27800, {0x102dcbd20, 0x14001dbf500}, 0x0)
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/decl.go:191 +0x84c
go/types.(*Checker).packageObjects(0x14000c27800)
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/resolver.go:693 +0x468
go/types.(*Checker).checkFiles(0x14000c27800, {0x14001180000, 0x5, 0x5})
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/check.go:408 +0x164
go/types.(*Checker).Files(...)
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/check.go:372
sigs.k8s.io/controller-tools/pkg/loader.(*loader).typeCheck(0x1400025f4d0, 0x14001090fc0)
        /Users/cheverjohn/Workspace/golang/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/loader.go:286 +0x2d8
sigs.k8s.io/controller-tools/pkg/loader.(*Package).NeedTypesInfo(0x14001090fc0)
        /Users/cheverjohn/Workspace/golang/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/loader.go:99 +0x44
sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check(0x140017a7290, 0x14001090fc0)
        /Users/cheverjohn/Workspace/golang/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/refs.go:268 +0x304
sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check.func1(0x5b?)
        /Users/cheverjohn/Workspace/golang/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/refs.go:262 +0x58
created by sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check in goroutine 201
        /Users/cheverjohn/Workspace/golang/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/refs.go:260 +0x230
make: *** [manifests] Error 2

This problem can be stably reproduced.

Related discussion as following issues: kubernetes-sigs/controller-tools#888

Solution: change controller-gen version from v0.13.0 to v0.14.0.

I don't know how to fix this problem in which way. Should I create a new issue to fix it or just solve it in this PR?

Let's fix it in the new PR, Thanks!

@Chever-John
Copy link
Contributor Author

During local testing, I encountered an issue where the local Go version is 1.22.x and the controller-gen version is 0.13.0 (default in the controller project). When I execute the command make manifests, the following error occurs:

~/Workspace/OpenSource/github.com/Chever-John/htnn/controller
☹  ../bin/controller-gen --version                                                                                     chore/unite-the-bin-cache-dir 53e855c
Version: v0.13.0

~/Workspace/OpenSource/github.com/Chever-John/htnn/controller
☹  go version                                                                                                          chore/unite-the-bin-cache-dir 53e855c
go version go1.22.1 darwin/arm64

~/Workspace/OpenSource/github.com/Chever-John/htnn/controller
☺  make manifests                                                                                                      chore/unite-the-bin-cache-dir 53e855c
/Users/cheverjohn/Workspace/OpenSource/github.com/Chever-John/htnn/bin/controller-gen rbac:roleName=htnn-role crd:ignoreUnexportedFields=true \
                output:crd:artifacts:config=../manifests/charts/htnn-controller/templates/crds/ \
                output:rbac:artifacts:config=../manifests/charts/htnn-controller/templates/rbac/ \
                paths="../types/..." paths="./internal/controller/..."
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=0x102a1c604]

goroutine 182 [running]:
go/types.(*Checker).handleBailout(0x14000c27800, 0x14001811d18)
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/check.go:367 +0x9c
panic({0x102cf5a60?, 0x103294af0?})
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/runtime/panic.go:770 +0x124
go/types.(*StdSizes).Sizeof(0x0, {0x102dc0990, 0x10329d300})
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/sizes.go:228 +0x314
go/types.(*Config).sizeof(...)
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/sizes.go:333
go/types.representableConst.func1({0x102dc0990?, 0x10329d300?})
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/const.go:76 +0x9c
go/types.representableConst({0x102dc6c30, 0x103268240}, 0x14000c27800, 0x10329d300, 0x14001811468)
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/const.go:92 +0x138
go/types.(*Checker).representation(0x14000c27800, 0x14001814d00, 0x10329d300)
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/const.go:256 +0x68
go/types.(*Checker).implicitTypeAndValue(0x14000c27800, 0x14001814d00, {0x102dc09b8, 0x140002342a0})
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/expr.go:375 +0x304
go/types.(*Checker).assignment(0x14000c27800, 0x14001814d00, {0x102dc09b8, 0x140002342a0}, {0x102b34081, 0x14})
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/assignments.go:52 +0x23c
go/types.(*Checker).initConst(0x14000c27800, 0x14001dbf500, 0x14001814d00)
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/assignments.go:126 +0x274
go/types.(*Checker).constDecl(0x14000c27800, 0x14001dbf500, {0x102dc3538, 0x1400132a1a0}, {0x102dc3538, 0x1400132a1c0}, 0x0)
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/decl.go:490 +0x250
go/types.(*Checker).objDecl(0x14000c27800, {0x102dcbd20, 0x14001dbf500}, 0x0)
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/decl.go:191 +0x84c
go/types.(*Checker).packageObjects(0x14000c27800)
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/resolver.go:693 +0x468
go/types.(*Checker).checkFiles(0x14000c27800, {0x14001180000, 0x5, 0x5})
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/check.go:408 +0x164
go/types.(*Checker).Files(...)
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/check.go:372
sigs.k8s.io/controller-tools/pkg/loader.(*loader).typeCheck(0x1400025f4d0, 0x14001090fc0)
        /Users/cheverjohn/Workspace/golang/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/loader.go:286 +0x2d8
sigs.k8s.io/controller-tools/pkg/loader.(*Package).NeedTypesInfo(0x14001090fc0)
        /Users/cheverjohn/Workspace/golang/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/loader.go:99 +0x44
sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check(0x140017a7290, 0x14001090fc0)
        /Users/cheverjohn/Workspace/golang/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/refs.go:268 +0x304
sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check.func1(0x5b?)
        /Users/cheverjohn/Workspace/golang/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/refs.go:262 +0x58
created by sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check in goroutine 201
        /Users/cheverjohn/Workspace/golang/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/refs.go:260 +0x230
make: *** [manifests] Error 2

This problem can be stably reproduced.
Related discussion as following issues: kubernetes-sigs/controller-tools#888
Solution: change controller-gen version from v0.13.0 to v0.14.0.
I don't know how to fix this problem in which way. Should I create a new issue to fix it or just solve it in this PR?

Let's fix it in the new PR, Thanks!

So I'm curious, what kind of solution should I choose?

Do you choose to upgrade the version of controller-gen based on my suggestion?

Copy link
Member

@spacewander spacewander left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to deal with

htnn/Makefile

Line 20 in efa91d0

LOCALBIN ?= $(shell pwd)/bin

$(LOCALBIN):

@spacewander
Copy link
Member

During local testing, I encountered an issue where the local Go version is 1.22.x and the controller-gen version is 0.13.0 (default in the controller project). When I execute the command make manifests, the following error occurs:

~/Workspace/OpenSource/github.com/Chever-John/htnn/controller
☹  ../bin/controller-gen --version                                                                                     chore/unite-the-bin-cache-dir 53e855c
Version: v0.13.0

~/Workspace/OpenSource/github.com/Chever-John/htnn/controller
☹  go version                                                                                                          chore/unite-the-bin-cache-dir 53e855c
go version go1.22.1 darwin/arm64

~/Workspace/OpenSource/github.com/Chever-John/htnn/controller
☺  make manifests                                                                                                      chore/unite-the-bin-cache-dir 53e855c
/Users/cheverjohn/Workspace/OpenSource/github.com/Chever-John/htnn/bin/controller-gen rbac:roleName=htnn-role crd:ignoreUnexportedFields=true \
                output:crd:artifacts:config=../manifests/charts/htnn-controller/templates/crds/ \
                output:rbac:artifacts:config=../manifests/charts/htnn-controller/templates/rbac/ \
                paths="../types/..." paths="./internal/controller/..."
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=0x102a1c604]

goroutine 182 [running]:
go/types.(*Checker).handleBailout(0x14000c27800, 0x14001811d18)
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/check.go:367 +0x9c
panic({0x102cf5a60?, 0x103294af0?})
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/runtime/panic.go:770 +0x124
go/types.(*StdSizes).Sizeof(0x0, {0x102dc0990, 0x10329d300})
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/sizes.go:228 +0x314
go/types.(*Config).sizeof(...)
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/sizes.go:333
go/types.representableConst.func1({0x102dc0990?, 0x10329d300?})
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/const.go:76 +0x9c
go/types.representableConst({0x102dc6c30, 0x103268240}, 0x14000c27800, 0x10329d300, 0x14001811468)
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/const.go:92 +0x138
go/types.(*Checker).representation(0x14000c27800, 0x14001814d00, 0x10329d300)
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/const.go:256 +0x68
go/types.(*Checker).implicitTypeAndValue(0x14000c27800, 0x14001814d00, {0x102dc09b8, 0x140002342a0})
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/expr.go:375 +0x304
go/types.(*Checker).assignment(0x14000c27800, 0x14001814d00, {0x102dc09b8, 0x140002342a0}, {0x102b34081, 0x14})
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/assignments.go:52 +0x23c
go/types.(*Checker).initConst(0x14000c27800, 0x14001dbf500, 0x14001814d00)
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/assignments.go:126 +0x274
go/types.(*Checker).constDecl(0x14000c27800, 0x14001dbf500, {0x102dc3538, 0x1400132a1a0}, {0x102dc3538, 0x1400132a1c0}, 0x0)
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/decl.go:490 +0x250
go/types.(*Checker).objDecl(0x14000c27800, {0x102dcbd20, 0x14001dbf500}, 0x0)
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/decl.go:191 +0x84c
go/types.(*Checker).packageObjects(0x14000c27800)
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/resolver.go:693 +0x468
go/types.(*Checker).checkFiles(0x14000c27800, {0x14001180000, 0x5, 0x5})
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/check.go:408 +0x164
go/types.(*Checker).Files(...)
        /Users/cheverjohn/Infra/dev-env/langs/go/go1.22.1/src/go/types/check.go:372
sigs.k8s.io/controller-tools/pkg/loader.(*loader).typeCheck(0x1400025f4d0, 0x14001090fc0)
        /Users/cheverjohn/Workspace/golang/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/loader.go:286 +0x2d8
sigs.k8s.io/controller-tools/pkg/loader.(*Package).NeedTypesInfo(0x14001090fc0)
        /Users/cheverjohn/Workspace/golang/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/loader.go:99 +0x44
sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check(0x140017a7290, 0x14001090fc0)
        /Users/cheverjohn/Workspace/golang/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/refs.go:268 +0x304
sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check.func1(0x5b?)
        /Users/cheverjohn/Workspace/golang/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/refs.go:262 +0x58
created by sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check in goroutine 201
        /Users/cheverjohn/Workspace/golang/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/refs.go:260 +0x230
make: *** [manifests] Error 2

This problem can be stably reproduced.
Related discussion as following issues: kubernetes-sigs/controller-tools#888
Solution: change controller-gen version from v0.13.0 to v0.14.0.
I don't know how to fix this problem in which way. Should I create a new issue to fix it or just solve it in this PR?

Let's fix it in the new PR, Thanks!

So I'm curious, what kind of solution should I choose?

Do you choose to upgrade the version of controller-gen based on my suggestion?

Yes, let's update the version

@Chever-John
Copy link
Contributor Author

Need to deal with

htnn/Makefile

Line 20 in efa91d0

LOCALBIN ?= $(shell pwd)/bin

$(LOCALBIN):

Got.

Let me finish it right now:)

@github-actions github-actions bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jul 2, 2024
@Chever-John Chever-John force-pushed the chore/unite-the-bin-cache-dir branch from 6a571fd to 6d5c547 Compare July 2, 2024 06:39
site/Makefile Outdated
# If they need to be updated frequently, we can consider to store them in the `Dockerfile.dev`.
$(LOCALBIN):
@mkdir -p $(LOCALBIN)
SHELL = /bin/bash
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The common.mk already provides SHELL?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes!

Have removed it!

@spacewander spacewander merged commit 02945c9 into mosn:main Jul 2, 2024
13 checks passed
@spacewander
Copy link
Member

Merged. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Should unite the binary cache directory
2 participants