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

Migrate code-gen to kube_codegen.sh #412

Merged
merged 2 commits into from
Nov 22, 2024

Conversation

fmuyassarov
Copy link
Collaborator

Migrate to kube_codegen.sh and bump k8s libraries along the way to the same version as k8s.io/code-generator.

I decided to wait for #406 to land but it should not block you from giving review on this.

@fmuyassarov fmuyassarov requested review from klihub, marquiz and askervin and removed request for klihub and marquiz November 14, 2024 20:30
@fmuyassarov fmuyassarov changed the title Migrate to code gen to kube_codegen.sh Migrate code-gen to kube_codegen.sh Nov 14, 2024
Copy link
Collaborator

@klihub klihub left a comment

Choose a reason for hiding this comment

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

Could you alter the split into two commits like this:

  1. import new deps + update Makefile+any other tooling necessary
  2. regenerate everything (make generate) and commit the resulting changes

It is much easier for us to review (review first commit, skim through resulting changes in the second), much easier for you to rebase (just drop the tip-most commit, rerun make generate the commit the changes) and much easier for me to test it on top of my tree (just cherry-pick for first commit with the tooling changes and run make generate). With the current version, the last two of these will cause unavoidable conflicts because the relevant changes are not split from the side-effects.

@fmuyassarov
Copy link
Collaborator Author

Could you alter the split into two commits like this:

1. import new deps + update Makefile+any other tooling necessary

2. regenerate everything (`make generate`) and commit the resulting changes

It is much easier for us to review (review first commit, skim through resulting changes in the second), much easier for you to rebase (just drop the tip-most commit, rerun make generate the commit the changes) and much easier for me to test it on top of my tree (just cherry-pick for first commit with the tooling changes and run make generate). With the current version, the last two of these will cause unavoidable conflicts because the relevant changes are not split from the side-effects.

Sure, I will do as you suggested here because I currently it is messed up :)

@fmuyassarov
Copy link
Collaborator Author

@klihub PTAL. Updated the commits.

@klihub
Copy link
Collaborator

klihub commented Nov 15, 2024

@fmuyassarov When I try a make generate with this, I get this failure:

klitkey1-mobl1 generators-v2 $ make generate
/home/kli/src/work/devel/nri-plugins/metrics/generators-v2/build-aux/bin/controller-gen \
        crd:generateEmbeddedObjectMeta=true output:crd:artifacts:config=config/crd/bases\
        paths="./pkg/apis/..."
/home/kli/src/work/devel/nri-plugins/metrics/generators-v2/build-aux/bin/controller-gen \
        rbac:roleName=manager-role crd paths="./pkg/apis/..." output:crd:artifacts:config=config/crd/bases
/home/kli/src/work/devel/nri-plugins/metrics/generators-v2/build-aux/bin/controller-gen object:headerFile="scripts/hack/boilerplate.go.txt" paths="./pkg/apis/..."
./scripts/hack/update_codegen.sh go
Generating client code for 1 targets
F1115 11:08:28.607834 2185078 main.go:65] Error: failed making a parser: error(s) in "/u/src/kli/work/devel/nri-plugins/metrics/generators-v2/pkg/apis/config/v1alpha1":
-: directory /u/src/kli/work/devel/nri-plugins/metrics/generators-v2/pkg/apis/config/v1alpha1 outside main module or its selected dependencies
Cleaning up temporary vendor directory...
make: *** [Makefile:505: generate-clients] Error 255

@klihub
Copy link
Collaborator

klihub commented Nov 15, 2024

@fmuyassarov I still get the same failure with this latest version.

klihub
klihub previously requested changes Nov 17, 2024
Copy link
Collaborator

@klihub klihub left a comment

Choose a reason for hiding this comment

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

Can you test on your side with my proposed one-liner change ?

With that in place now make generate works for me. I wonder if this then breaks for you, since the original version worked with $REPO_ROOT as the current working directory...

scripts/hack/update_codegen.sh Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Copy link
Collaborator

@klihub klihub left a comment

Choose a reason for hiding this comment

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

This really LGTM now. I have a few small nits. Some of the shell-quoting ones should be taken with a grain of salt though, especially if shellcheck disagrees with me.

@klihub klihub dismissed their stale review November 18, 2024 12:04

Now works also for me.

@marquiz
Copy link
Collaborator

marquiz commented Nov 18, 2024

I think this could be merged. Preferably with klihubs comments addressed.

Now that I looked at this: just a general note that my personal feeling is that the Makefile is getting somewhat hairy'ish with all the phony rules and army of variables (like CLIENT_GEN_VERSION has no effect if CLIENT_GEN is modified and such). I'd find it easier to follow a script (á la scripts/hack/update_codegen.sh) that just does everything (installs tools, runs them, cleanup if needed) in sequential order. But not much to do with this PR...

@fmuyassarov
Copy link
Collaborator Author

I think this could be merged. Preferably with klihubs comments addressed.

Now that I looked at this: just a general note that my personal feeling is that the Makefile is getting somewhat hairy'ish with all the phony rules and army of variables (like CLIENT_GEN_VERSION has no effect if CLIENT_GEN is modified and such). I'd find it easier to follow a script (á la scripts/hack/update_codegen.sh) that just does everything (installs tools, runs them, cleanup if needed) in sequential order. But not much to do with this PR...

This a valid point but I would prefer to do that clean up as a follow up.

@marquiz
Copy link
Collaborator

marquiz commented Nov 19, 2024

This a valid point but I would prefer to do that clean up as a follow up.

Yeah, was just a note, food for thought... And I'm not sure that everybody agrees...

@fmuyassarov
Copy link
Collaborator Author

rebased....

- import new deps
- update Makefile targets
- introduce update_codegen.sh for code generation in a new format

Signed-off-by: Feruzjon Muyassarov <[email protected]>
@fmuyassarov fmuyassarov marked this pull request as ready for review November 20, 2024 09:06
@fmuyassarov
Copy link
Collaborator Author

@klihub This is now rebased on top of your merged patches.

@klihub
Copy link
Collaborator

klihub commented Nov 20, 2024

This a valid point but I would prefer to do that clean up as a follow up.

Yeah, was just a note, food for thought... And I'm not sure that everybody agrees...

Yes, as long as we think it through beforehand and make such changes so that 1) we can still pass the tooling version(s) to be used from the Makefile rule to the script, and 2) the script is smart enough to not re-clone and re-compile the tooling binaries if I run twice make generate without overriding the tooling versions.

But maybe I'd prefer to let things settle now for a while and go with these changes before we start again touching this stuff...

@klihub klihub merged commit ed3e6fa into containers:main Nov 22, 2024
3 checks passed
@fmuyassarov fmuyassarov deleted the generators-v2 branch November 22, 2024 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants