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

πŸ› (go/v4): Start to check ENABLE_WEBHOOKS envvar into main.go to fix issue when webhooks are used #3578

Merged

Conversation

lowang-bh
Copy link
Member

@lowang-bh lowang-bh commented Sep 2, 2023

Fixes #3559

describe: fix issue that webhook generated code in cmd/main.go ignored checking the env ENABLE_WEBHOOKS

Test result :

➜  guestbook git:(dev) βœ— export ENABLE_WEBHOOKS=false; make run
test -s /Users/wlh/go/src/github.com/lowang-bh/demo/guestbook/bin/controller-gen && /Users/wlh/go/src/github.com/lowang-bh/demo/guestbook/bin/controller-gen --version | grep -q v0.13.0 || \
	GOBIN=/Users/wlh/go/src/github.com/lowang-bh/demo/guestbook/bin go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.13.0
/Users/wlh/go/src/github.com/lowang-bh/demo/guestbook/bin/controller-gen rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
/Users/wlh/go/src/github.com/lowang-bh/demo/guestbook/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
go fmt ./...
go vet ./...
go run ./cmd/main.go
2023-09-02T18:47:24+08:00	INFO	setup	starting manager
2023-09-02T18:47:24+08:00	INFO	starting server	{"kind": "health probe", "addr": "[::]:8081"}
2023-09-02T18:47:24+08:00	INFO	controller-runtime.metrics	Starting metrics server
2023-09-02T18:47:24+08:00	INFO	controller-runtime.metrics	Serving metrics server	{"bindAddress": ":8080", "secure": false}
2023-09-02T18:47:24+08:00	INFO	Starting EventSource	{"controller": "guestbook", "controllerGroup": "webapp.my.domain", "controllerKind": "Guestbook", "source": "kind source: *v1.Guestbook"}
2023-09-02T18:47:24+08:00	INFO	Starting Controller	{"controller": "guestbook", "controllerGroup": "webapp.my.domain", "controllerKind": "Guestbook"}
2023-09-02T18:47:24+08:00	INFO	Starting workers	{"controller": "guestbook", "controllerGroup": "webapp.my.domain", "controllerKind": "Guestbook", "worker count": 1}

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 2, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @lowang-bh. 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. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Sep 2, 2023
@lowang-bh
Copy link
Member Author

Test finished successfully
image

Copy link
Member

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution πŸ₯‡

Following some nits

  • The plugins go/v2 and go/v3 are deprecated so changes should not be performed on them.
  • After change the scaffold you need to run make generate so that all samples under testdata and docs will be properly updated. Could you please to do it?

@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Sep 3, 2023
@lowang-bh
Copy link
Member Author

  • After change the scaffold you need to run make generate

Done.

image

@camilamacedo86
Copy link
Member

camilamacedo86 commented Sep 3, 2023

@lowang-bh,

Thank you.
Could you please squash the commits?
We need to have always just one commit to get merged per PR

PS.: I also updated title for we have a better info when we generate the release notes. I hope that you do not mind.

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 3, 2023
@camilamacedo86 camilamacedo86 changed the title πŸ› fix issue that webook generated code ignored checking env ENABLE_WEBHOOKS πŸ› (go/v4): Start to check ENABLE_WEBHOOKS envvar into main.go to fix issue when webhooks are used Sep 3, 2023
@lowang-bh
Copy link
Member Author

Could you please squash the commits?

Done.

I also updated title for we have a better info when we generate the release notes. I hope that you do not mind

Thanks.

Copy link
Member

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

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

/lgtm
/approved

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: camilamacedo86, lowang-bh

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 k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 3, 2023
@camilamacedo86
Copy link
Member

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 3, 2023
@camilamacedo86
Copy link
Member

/hold cancel
/approved cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 3, 2023
@lowang-bh
Copy link
Member Author

lowang-bh commented Sep 3, 2023

Yes, I am looking into this issue. It always insert two pices of same code.

fix make generate errors

Signed-off-by: lowang-bh <lhui_wang@163.com>

remove duplicated code in cmd/main.go when gen docs

Signed-off-by: lowang-bh <lhui_wang@163.com>
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 3, 2023
@lowang-bh
Copy link
Member Author

/test pull-kubebuilder-e2e-k8s-1-27-1
/test pull-kubebuilder-e2e-k8s-1-25-3
/test pull-kubebuilder-e2e-k8s-1-26-0

@camilamacedo86
Copy link
Member

/test pull-kubebuilder-e2e-k8s-1-25-3

Copy link
Member

@camilamacedo86 camilamacedo86 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 Sep 3, 2023
@camilamacedo86
Copy link
Member

The API fails because the change in the doc see:

sigs.k8s.io/kubebuilder/v3/hack/docs/internal/cronjob-tutorial
Incompatible changes:

  • MainEnableWebhook: value changed from "\n\n\t/\n\t\tWe'''ll also set up webhooks for our type, which we'''ll t... to "\n\n\t/\n\t\tWe'''ll also set up webhooks for our type, which we'''ll t...'
  • GOAPIDIFF_RC=1

Therefore, it is not a genuine breakchange.
So, we can move forward with this one.

@camilamacedo86 camilamacedo86 merged commit a8ad43f into kubernetes-sigs:master Sep 4, 2023
14 of 16 checks passed
@lowang-bh lowang-bh deleted the fixwebhookgen branch September 4, 2023 12:52
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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
3 participants