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

codegen: fix code-generation #1083

Merged
merged 3 commits into from
Mar 15, 2023
Merged

Conversation

fmuyassarov
Copy link
Member

Our make-generate is currently broken as shown below and this PR fixes it by bumping mockery version and disabling buildvcs to avoid go VCS status error. More info on commit messages. Last commit is about re-running make generate (auto-generated code).

NOTE: mockery latest version is 2.22.1 but that requires mockery.yaml file to be available. I'm not sure if we really need it. But if yes, we can do it separately because this PR is about fixing the code generation.

$ make generate 
docker build \
    --build-arg BUILDER_IMAGE=golang:1.20-bullseye \
    -t nfd-generator \
    -f Dockerfile_generator .
[+] Building 1.0s (10/10) FINISHED                                                                                                                                                                 
 => [internal] load .dockerignore                                                                                                                                                             0.0s
 => => transferring context: 156B                                                                                                                                                             0.0s
 => [internal] load build definition from Dockerfile_generator                                                                                                                                0.0s
 => => transferring dockerfile: 990B                                                                                                                                                          0.0s
 => [internal] load metadata for docker.io/library/golang:1.20-bullseye                                                                                                                       1.0s
 => [auth] library/golang:pull token for registry-1.docker.io                                                                                                                                 0.0s
 => [1/5] FROM docker.io/library/golang:1.20-bullseye@sha256:51ff22f03320894402290ba7dfd83ee05b61e58b5381d76b40f2e3a370d81da3                                                                 0.0s
 => CACHED [2/5] RUN go install github.com/vektra/mockery/[email protected] &&     go install sigs.k8s.io/controller-tools/cmd/[email protected] &&     git clone https://github.com/kubernetes  0.0s
 => CACHED [3/5] RUN apt-get update && apt-get install unzip                                                                                                                                  0.0s
 => CACHED [4/5] RUN curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v3.17.3/protoc-3.17.3-linux-x86_64.zip &&     unzip protoc-3.17.3-linux-x86_64.zip -d /usr/local  0.0s
 => CACHED [5/5] WORKDIR /go/node-feature-discovery                                                                                                                                           0.0s
 => exporting to image                                                                                                                                                                        0.0s
 => => exporting layers                                                                                                                                                                       0.0s
 => => writing image sha256:9ea9bf4bad6e19752c6d8987549a9fe797138918661312bb1b5aa49df2a9ee39                                                                                                  0.0s
 => => naming to docker.io/library/nfd-generator                                                                                                                                              0.0s
docker run --rm \
    -v "`pwd`:/go/node-feature-discovery" \
    -v "`go env GOCACHE`:/.cache" \
    -v "`go env GOMODCACHE`:/go/pkg/mod" \
    --user=`id -u`:`id -g`\
    nfd-generator \
    ./hack/generate.sh
10 Mar 23 22:05 UTC INF Starting mockery dry-run=false version=v2.13.0
10 Mar 23 22:05 UTC INF Walking dry-run=false version=v2.13.0
2023/03/10 22:05:40 internal error: package "github.com/k8stopologyawareschedwg/noderesourcetopology-api/pkg/generated/clientset/versioned" without types was imported from "sigs.k8s.io/node-feature-discovery/pkg/apihelper"
pkg/apihelper/apihelpers.go:19: running "mockery": exit status 1
+ go-to-protobuf --output-base=. --go-header-file ../../../../hack/boilerplate.go.txt --proto-import ../../../../vendor/ --packages +sigs.k8s.io/node-feature-discovery/pkg/apis/nfd/v1alpha1=v1alpha1 --keep-gogoproto=false --apimachinery-packages -k8s.io/apimachinery/pkg/util/intstr
topological order bytes
topological order encoding/json
topological order errors
topological order fmt
topological order github.com/gogo/protobuf/proto
topological order github.com/gogo/protobuf/sortkeys
topological order github.com/google/gofuzz
topological order io
topological order k8s.io/api/core/v1
topological order k8s.io/apimachinery/pkg/apis/meta/v1
topological order k8s.io/apimachinery/pkg/runtime
topological order k8s.io/apimachinery/pkg/runtime/schema
topological order k8s.io/klog/v2
topological order math
topological order math/bits
topological order reflect
topological order regexp
topological order runtime/debug
topological order sigs.k8s.io/node-feature-discovery/pkg/utils
topological order sort
topological order strconv
topological order strings
topological order text/template
topological order k8s.io/apimachinery/pkg/util/intstr
topological order sigs.k8s.io/node-feature-discovery/pkg/apis/nfd/v1alpha1
+ mv sigs.k8s.io/node-feature-discovery/pkg/apis/nfd/v1alpha1/generated.pb.go sigs.k8s.io/node-feature-discovery/pkg/apis/nfd/v1alpha1/generated.proto .
+ rm -rf sigs.k8s.io
10 Mar 23 22:05 UTC INF Starting mockery dry-run=false version=v2.13.0
10 Mar 23 22:05 UTC INF Walking dry-run=false version=v2.13.0
2023/03/10 22:05:42 internal error: package "context" without types was imported from "sigs.k8s.io/node-feature-discovery/pkg/labeler"
pkg/labeler/doc.go:20: running "mockery": exit status 1
10 Mar 23 22:05 UTC INF Starting mockery dry-run=false version=v2.13.0
10 Mar 23 22:05 UTC INF Walking dry-run=false version=v2.13.0
2023/03/10 22:05:42 internal error: package "github.com/stretchr/testify/mock" without types was imported from "sigs.k8s.io/node-feature-discovery/source"
source/source.go:19: running "mockery": exit status 1
make: *** [Makefile:145: generate] Error 1

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Mar 10, 2023
@netlify
Copy link

netlify bot commented Mar 10, 2023

Deploy Preview for kubernetes-sigs-nfd ready!

Name Link
🔨 Latest commit e3a856b
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-nfd/deploys/640ce15b133f970008c2e472
😎 Deploy Preview https://deploy-preview-1083--kubernetes-sigs-nfd.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 10, 2023
@fmuyassarov fmuyassarov changed the title fix code-generation codegen: fix code-generation Mar 10, 2023
@fmuyassarov
Copy link
Member Author

/cc @marquiz @ArangoGutierrez

Copy link
Contributor

@marquiz marquiz left a comment

Choose a reason for hiding this comment

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

Thanks @fmuyassarov for the fix!

One question: which part of the auto-generation fails with the error obtaining VCS status?

Also, maybe you could put all autogenerated changes in the last commit (removing auto-generated parts from the first commit)?

Omit go version control information (buildvcs), otherwise
go command fails to obtain vcs status as shown below:

error obtaining VCS status: exit status 128
	Use -buildvcs=false to disable VCS stamping.

Signed-off-by: Muyassarov, Feruzjon <[email protected]>
Update generated code based on the updated from re-running make
generate.

Signed-off-by: Muyassarov, Feruzjon <[email protected]>
@fmuyassarov
Copy link
Member Author

One question: which part of the auto-generation fails with the error obtaining VCS status?

when running generate-groups.sh.

${K8S_CODE_GENERATOR}/generate-groups.sh client,informer,lister \

Also, maybe you could put all autogenerated changes in the last commit (removing auto-generated parts from the first commit)?

Yep, I myself didn't notice actually those committed (used git add .) changes. But it if fixed now, thanks for the suggestion.

Copy link
Contributor

@marquiz marquiz left a comment

Choose a reason for hiding this comment

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

Thanks for the update

I haven't seen the VCS status problem but it possibly occurred if you run the generation under a git worktree(?) But better to fix that problem in any case.

/assign @ArangoGutierrez

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 12, 2023
@fmuyassarov
Copy link
Member Author

I haven't seen the VCS status problem but it possibly occurred if you run the generation under a git worktree(?) But better to fix that problem in any case.

If you checkout to a58cc0a, which doesn't include -buildvcs=false, and run make generate you will most probably see the same. But I guess it is as you said that it happens when running under a git worktree.

Copy link
Contributor

@ArangoGutierrez ArangoGutierrez left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 15, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ArangoGutierrez, fmuyassarov, marquiz

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

@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: b6671654b9291733ea60cc7d4ddeebe8dcb32d39

@k8s-ci-robot k8s-ci-robot merged commit a06e44e into kubernetes-sigs:master Mar 15, 2023
@fmuyassarov fmuyassarov deleted the mockery branch March 15, 2023 13:57
@marquiz marquiz mentioned this pull request Apr 12, 2023
24 tasks
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants