kubernetes-sigs / custom-metrics-apiserver

Framework for implementing custom metrics support for Kubernetes
Apache License 2.0
504 stars 176 forks source link

fix: openapi-gen should produce gen files with autogenerated tag #118

Closed zroubalik closed 1 year ago

zroubalik commented 1 year ago

Signed-off-by: Zbynek Roubalik zroubalik@gmail.com

These files should be marked as autogenerated. The original version caused problems when we were trying to generate stuff on top of this.

ie:

        /Users/zroubali/go/src/github.com/kedacore/keda/adapter/generated/openapi
-: build constraints exclude all Go files in /Users/zroubali/go/src/github.com/kedacore/keda/vendor/sigs.k8s.io/custom-metrics-apiserver/pkg/generated/openapi/core
-: build constraints exclude all Go files in /Users/zroubali/go/src/github.com/kedacore/keda/vendor/sigs.k8s.io/custom-metrics-apiserver/pkg/generated/openapi/custommetrics
-: build constraints exclude all Go files in /Users/zroubali/go/src/github.com/kedacore/keda/vendor/sigs.k8s.io/custom-metrics-apiserver/pkg/generated/openapi/externalmetrics

It would be awesome if we can have another version with this fix 🙏

CC @dgrisonnet @olivierlemasle

k8s-ci-robot commented 1 year ago

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: zroubalik Once this PR has been reviewed and has the lgtm label, please assign dgrisonnet for approval by writing /assign @dgrisonnet in a comment. 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: - **[OWNERS](https://github.com/kubernetes-sigs/custom-metrics-apiserver/blob/master/OWNERS)** 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 commented 1 year ago

Hi @zroubalik. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
zroubalik commented 1 year ago

Thanks for the PR; however I don't understand the issue.

Keda itself already vendors generated files with the !ignore_autogenerated constraint:

https://github.com/kedacore/keda/blob/cbdb405dc3f9936d100f39ee0a1c6c1f98c1c2dd/vendor/knative.dev/pkg/apis/zz_generated.deepcopy.go#L1-L2

Is the issue specific to vendoring?

Would adding a doc.go file with package documentation (and no build constraint) also solve your issue ("build constraints exclude all Go files in ...")?

Strange, I haven't noticed the occurence of the marker in Knative deps, but these deps don't cause problems.

I just tried to add a blank doc.go file in these packages and it seems like it is working. I am not expert on vendoring & generations so really don't understand what is happening here 😄

Seems like we can close this PR and open a tackle this with the doc.go approach, I can send a new PR with these, if that's okay?

olivierlemasle commented 1 year ago

I just tried to add a blank doc.go file in these packages and it seems like it is working. I am not expert on vendoring & generations so really don't understand what is happening here smile

That must be magic...

Seems like we can close this PR and open a tackle this with the doc.go approach, I can send a new PR with these, if that's okay?

Yes, please. Like what metrics-server does: https://github.com/kubernetes-sigs/metrics-server/blob/99800088326ec9c3448895f24f60e36e68ce4398/pkg/api/generated/openapi/doc.go

zroubalik commented 1 year ago

closing in favor of https://github.com/kubernetes-sigs/custom-metrics-apiserver/pull/119