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

Ensure code generation dependencies are downloaded #2339

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

astefanutti
Copy link
Contributor

What this PR does / why we need it:

This PR runs go mod download prior to running code generation to ensure the required dependencies are present.

Before:

$ sudo rm -rf `go list -m -mod=readonly -f "{{.Dir}}" k8s.io/code-generator`
$ make generate
GOBIN=/workdir/bin go install sigs.k8s.io/controller-tools/cmd/[email protected]
/workdir/bin/controller-gen "crd:generateEmbeddedObjectMeta=true,maxDescLen=400" rbac:roleName=training-operator webhook paths="./pkg/apis/kubeflow.org/v1/..." \
	output:crd:artifacts:config=manifests/base/crds \
	output:rbac:artifacts:config=manifests/base/rbac \
	output:webhook:artifacts:config=manifests/base/webhook
/workdir/bin/controller-gen "crd:generateEmbeddedObjectMeta=true" rbac:roleName=training-operator-v2 webhook \
	paths="./pkg/apis/kubeflow.org/v2alpha1/...;./pkg/controller.v2/...;./pkg/runtime.v2/...;./pkg/webhook.v2/...;./pkg/cert/..." \
	output:crd:artifacts:config=manifests/v2/base/crds \
	output:rbac:artifacts:config=manifests/v2/base/rbac \
	output:webhook:artifacts:config=manifests/v2/base/webhook
/workdir/bin/controller-gen object:headerFile="hack/boilerplate/boilerplate.go.txt" paths="./pkg/apis/..."
hack/update-codegen.sh
hack/update-codegen.sh: line 19: /kube_codegen.sh: No such file or directory
make: *** [Makefile:52: generate] Error 1

After:

$ sudo rm -rf `go list -m -mod=readonly -f "{{.Dir}}" k8s.io/code-generator`
$ make generate
# OK

Checklist:

  • Docs included if any changes are user facing

Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign jeffwan for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

Copy link
Member

@andreyvelich andreyvelich 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 updating this @astefanutti!

Makefile Outdated
@@ -47,7 +47,7 @@ manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and Cust
output:rbac:artifacts:config=manifests/v2/base/rbac \
output:webhook:artifacts:config=manifests/v2/base/webhook

generate: controller-gen manifests ## Generate apidoc, sdk and code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
generate: go-mod-download controller-gen manifests ## Generate apidoc, sdk and code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
Copy link
Member

Choose a reason for hiding this comment

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

Btw, I think you can remove controller-gen task from the generate, since manifests runs controller-gen:

manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, updated.

Makefile Outdated
@@ -47,7 +47,7 @@ manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and Cust
output:rbac:artifacts:config=manifests/v2/base/rbac \
output:webhook:artifacts:config=manifests/v2/base/webhook

generate: controller-gen manifests ## Generate apidoc, sdk and code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
generate: go-mod-download controller-gen manifests ## Generate apidoc, sdk and code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
Copy link
Member

Choose a reason for hiding this comment

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

@astefanutti @kubeflow/wg-training-leads Do we need a separate task for go mod download or we can just include this command as part of generate task, for instance:

generate: manifests ## Generate apidoc, sdk and code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
        go mod download
	$(CONTROLLER_GEN) object:headerFile="hack/boilerplate/boilerplate.go.txt" paths="./pkg/apis/..."
	hack/update-codegen.sh
	hack/python-sdk/gen-sdk.sh
	hack/python-sdk-v2/gen-sdk.sh
	$(MAKE) apidoc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I find a separate target slightly more consistent with those for controller-get and Kustomize, but I don't have a strong opinion :)

@coveralls
Copy link

Pull Request Test Coverage Report for Build 12089250799

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 12088918617: 0.0%
Covered Lines: 77
Relevant Lines: 77

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants