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

Move from go 1.17 to go1.18 #295

Merged
merged 6 commits into from
May 19, 2022

Conversation

swatisehgal
Copy link
Collaborator

  1. Ran go mod tidy
  2. Dockerfile updates
  3. Github CI workflows to go 1.18.1 update

@openshift-ci openshift-ci bot requested review from marioferh and MarSik May 19, 2022 10:11
@openshift-ci
Copy link
Contributor

openshift-ci bot commented May 19, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: swatisehgal

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 19, 2022
@swatisehgal
Copy link
Collaborator Author

CI fails when it runs make verify-generate, which seems to be running fine in my local environment 🤔:

$ make verify-generated
Using operator-sdk cached at bin/operator-sdk_linux_amd64
/home/swsehgal/go/src/github.com/openshift-kni/numaresources-operator/bin/controller-gen "crd:trivialVersions=true,preserveUnknownFields=false" rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
""bin"/"operator-sdk_linux_amd64"" generate kustomize manifests -q
cd config/manager && /home/swsehgal/go/src/github.com/openshift-kni/numaresources-operator/bin/kustomize edit set image controller=quay.io/openshift-kni/numaresources-operator:4.11.999-snapshot
/home/swsehgal/go/src/github.com/openshift-kni/numaresources-operator/bin/kustomize build config/manifests | ""bin"/"operator-sdk_linux_amd64"" generate bundle -q --overwrite --version 4.11.999-snapshot --channels=alpha --default-channel=alpha
INFO[0000] Creating bundle.Dockerfile                   
INFO[0000] Creating bundle/metadata/annotations.yaml    
INFO[0000] Bundle metadata generated suceessfully       
""bin"/"operator-sdk_linux_amd64"" bundle validate ./bundle
INFO[0000] All validation tests have completed successfully 
/home/swsehgal/go/src/github.com/openshift-kni/numaresources-operator/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
Verifying that all code is committed after updating deps and formatting and generating code
hack/verify-generated.sh

@swatisehgal
Copy link
Collaborator Author

/retest

@ffromani
Copy link
Member

/cc

@openshift-ci openshift-ci bot requested a review from ffromani May 19, 2022 11:06
@@ -1,6 +1,6 @@
module github.com/openshift-kni/numaresources-operator

go 1.17
go 1.18
Copy link
Member

Choose a reason for hiding this comment

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

you may want to pull RTE 0.6.0

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah, thanks for cutting a release on the RTE side!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will update this PR now.

Move from go 1.17 to go1.18
Ran `go mod tidy`

Signed-off-by: Swati Sehgal <swsehgal@redhat.com>
Signed-off-by: Swati Sehgal <swsehgal@redhat.com>
Signed-off-by: Swati Sehgal <swsehgal@redhat.com>
@ffromani
Copy link
Member

CI fails when it runs make verify-generate, which seems to be running fine in my local environment thinking:

$ make verify-generated
Using operator-sdk cached at bin/operator-sdk_linux_amd64
/home/swsehgal/go/src/github.com/openshift-kni/numaresources-operator/bin/controller-gen "crd:trivialVersions=true,preserveUnknownFields=false" rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
""bin"/"operator-sdk_linux_amd64"" generate kustomize manifests -q
cd config/manager && /home/swsehgal/go/src/github.com/openshift-kni/numaresources-operator/bin/kustomize edit set image controller=quay.io/openshift-kni/numaresources-operator:4.11.999-snapshot
/home/swsehgal/go/src/github.com/openshift-kni/numaresources-operator/bin/kustomize build config/manifests | ""bin"/"operator-sdk_linux_amd64"" generate bundle -q --overwrite --version 4.11.999-snapshot --channels=alpha --default-channel=alpha
INFO[0000] Creating bundle.Dockerfile                   
INFO[0000] Creating bundle/metadata/annotations.yaml    
INFO[0000] Bundle metadata generated suceessfully       
""bin"/"operator-sdk_linux_amd64"" bundle validate ./bundle
INFO[0000] All validation tests have completed successfully 
/home/swsehgal/go/src/github.com/openshift-kni/numaresources-operator/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
Verifying that all code is committed after updating deps and formatting and generating code
hack/verify-generated.sh

make sure to clean up your local bin/ to see if it reproduces locally

Signed-off-by: Swati Sehgal <swsehgal@redhat.com>
@swatisehgal
Copy link
Collaborator Author

make sure to clean up your local bin/ to see if it reproduces locally

Thanks for that, yeah the issue is reproducing locally.

@swatisehgal
Copy link
Collaborator Author

Looks like this is a known issue :kubernetes-sigs/kubebuilder#2530. The reason of the failure is because kubebuilder does not support go 1.18 yet: kubernetes-sigs/kubebuilder#2561.

@ffromani
Copy link
Member

Looks like this is a known issue :kubernetes-sigs/kubebuilder#2530. The reason of the failure is because kubebuilder does not support go 1.18 yet: kubernetes-sigs/kubebuilder#2561.

to move forward, I'd be in favour of applying a local fix like

$ git diff
diff --git a/Makefile b/Makefile
index 7c44e5b7..e9c85402 100644
--- a/Makefile
+++ b/Makefile
@@ -236,26 +236,26 @@ undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/confi
 
 CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
 controller-gen: ## Download controller-gen locally if necessary.
-       $(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.6.1)
+       $(call go-install-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.6.1)
 
 KUSTOMIZE = $(shell pwd)/bin/kustomize
 kustomize: ## Download kustomize locally if necessary.
-       $(call go-get-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/v3@v3.8.7)
+       $(call go-install-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/v3@v3.8.7)
 
 ENVTEST = $(shell pwd)/bin/setup-envtest
 envtest: ## Download envtest-setup locally if necessary.
-       $(call go-get-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest@latest)
+       $(call go-install-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest@latest)
 
-# go-get-tool will 'go get' any package $2 and install it to $1.
+# go-install-tool will 'go get' any package $2 and install it to $1.
 PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
-define go-get-tool
+define go-install-tool
 @[ -f $(1) ] || { \
 set -e ;\
 TMP_DIR=$$(mktemp -d) ;\
 cd $$TMP_DIR ;\
 go mod init tmp ;\
 echo "Downloading $(2)" ;\
-GOBIN=$(PROJECT_DIR)/bin go get $(2) ;\
+GOBIN=$(PROJECT_DIR)/bin go install $(2) ;\
 rm -rf $$TMP_DIR ;\
 }
 endef

I think this is actually something we can carry for the time being.
xref: https://go.dev/doc/go-get-install-deprecation

As of today, Kube-builder does not support go 1.18:
kubernetes-sigs/kubebuilder#2561.

Also, note that installing executables with go get is deprecated
in go1.18 (xref:https://go.dev/doc/go-get-install-deprecation).

Co-authored-by: Francesco Romani <fromani@redhat.com>
Signed-off-by: Swati Sehgal <swsehgal@redhat.com>
@ffromani
Copy link
Member

I'm in favour of moving to the latest kustomize v4. I'm not aware of any regression this would cause, and a quick glance at the changes between v3.8 and v4.5 revealed blockers.
xref: kubernetes-sigs/kustomize#3618

@swatisehgal
Copy link
Collaborator Author

I'm in favour of moving to the latest kustomize v4. I'm not aware of any regression this would cause, and a quick glance at the changes between v3.8 and v4.5 revealed blockers. xref: kubernetes-sigs/kustomize#3618

Good catch actually, I over-enthisiastically pushed the changes without testing locally, staying with Kustomize version 3.8.7 is giving me the error as linked in the issue and the one we are getting in the CI as well:


$ make verify-generated
Using operator-sdk cached at bin/operator-sdk_linux_amd64
/home/swsehgal/go/src/github.com/openshift-kni/numaresources-operator/bin/controller-gen "crd:trivialVersions=true,preserveUnknownFields=false" rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
go: creating new go.mod: module tmp
Downloading sigs.k8s.io/kustomize/kustomize/v3@v3.8.7
go: sigs.k8s.io/kustomize/kustomize/v3@v3.8.7 (in sigs.k8s.io/kustomize/kustomize/v3@v3.8.7):
        The go.mod file for the module providing named packages contains one or
        more exclude directives. It must not contain directives that would cause
        it to be interpreted differently than if it were the main module.
make: *** [Makefile:243: kustomize] Error 1

I think the issue you linked has been resolved after removing excluded dependencies from kustomize go mod:
kubernetes-sigs/kustomize#4387 so after bumping kustomize to 4.5 we overcome the current issue.

@swatisehgal
Copy link
Collaborator Author

Posting the fix shortly.

Signed-off-by: Swati Sehgal <swsehgal@redhat.com>
@ffromani
Copy link
Member

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label May 19, 2022
@openshift-merge-robot openshift-merge-robot merged commit e0e3fc7 into openshift-kni:main May 19, 2022
@swatisehgal swatisehgal deleted the go1.18 branch May 19, 2022 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants