-
Notifications
You must be signed in to change notification settings - Fork 423
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
✨ Set default value for corev1.Protocol type if not already specified #480
✨ Set default value for corev1.Protocol type if not already specified #480
Conversation
@munnerz: GitHub didn't allow me to request PR reviews from the following users: tamalsaha. Note that only kubernetes-sigs members and repo collaborators can review this PR, and authors cannot review their own PRs. In response to this:
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. |
This is great. Is this possible to unit test for? |
Any idea why the tests are failing? |
I've updated the testdata (the CronJob resource used embeds a PodSpec, so this change causes the In terms of testing specifically this change, we don't currently have any unit test for The only behaviour that is not tested is ensuring that if The only way I can think of to work around this is to have the integration test framework inject a 'copy' of this package/entry into KnownTypes during tests only, which could contain a type named |
6fb84ad
to
2f191a5
Compare
Okay, I did some more messing around with this and concluded that adding a test to ensure that the default value, if explicit specified with a marker, overrides this built-in default is actually not particularly useful (and not trivial, as during the evaluation of the functions defined in known_types.go, the markers have not yet been processed so we are unable to determine whether an explicit default has been provided here). Given that this default value is not going to change within @pwittrock this is ready for review now and passing 😄 |
@munnerz Can you look into the failed tests? |
2f191a5
to
0c2ff29
Compare
This PR seems to do the same thing: #440 |
The comments on that PR don't seem like blockers. Do you have a preference for which PR we take? |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: munnerz, pwittrock 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 |
It still does not work for me. if "crdVersions=v1" is specified default value is not generated, see #476 If I use v1beta1, then although default value is generated, but during apply it report error like:
Any ideas? Thanks~ |
Related issue is kubernetes-sigs/controller-tools#444, temporal solution is kubernetes-sigs/controller-tools#480, which is included in v0.4.1
Related issue is kubernetes-sigs/controller-tools#444, temporal solution is kubernetes-sigs/controller-tools#480, which is included in v0.4.1
I'm hoping this can be cherry-picked to fix controller-gen in v0.3 for users still wanting v1beta1 CRDs and webhooks by default (ex. in kubebuilder's go/v2 plugin). /cherry-pick release-0.3 |
This crucially includes [controller-tools#480][0] which allows us to apply these manifests to a Kubernetes 1.18 cluster without issues. A key change here is that we'll now generate CRD manifests using the `apiextensions.k8s.io/v1` API version rather than `v1beta1`. [0]: kubernetes-sigs/controller-tools#480 which
This crucially includes [controller-tools#480][0] which allows us to apply these manifests to a Kubernetes 1.18 cluster without issues. A key change here is that we'll now generate CRD manifests using the `apiextensions.k8s.io/v1` API version rather than `v1beta1`. [0]: kubernetes-sigs/controller-tools#480
compliable issue with kubernetes 1.18, detail: kubernetes-sigs/controller-tools#480 Signed-off-by: STRRL <str_ruiling@outlook.com>
compliable issue with kubernetes 1.18, detail: kubernetes-sigs/controller-tools#480 Signed-off-by: STRRL <str_ruiling@outlook.com>
* feat: conditional branches in workflownode Signed-off-by: STRRL <str_ruiling@outlook.com> * feat: reconciler of task node Signed-off-by: STRRL <str_ruiling@outlook.com> * feat: setup one container for task node Signed-off-by: STRRL <str_ruiling@outlook.com> * fix: address the comments by muse-dev Signed-off-by: STRRL <str_ruiling@outlook.com> * chore: cleanup duplicated codes Signed-off-by: STRRL <str_ruiling@outlook.com> * fix: bump controller-gen version compliable issue with kubernetes 1.18, detail: kubernetes-sigs/controller-tools#480 Signed-off-by: STRRL <str_ruiling@outlook.com> * chore: bump the version of controller-gen to v0.4.1 Signed-off-by: STRRL <str_ruiling@outlook.com> * fix: restrict kubernetes version with replace Signed-off-by: STRRL <str_ruiling@outlook.com> * fix: also restrict version for e2e-test Signed-off-by: STRRL <str_ruiling@outlook.com> * fix: also bump the verison of controller-runtime Signed-off-by: STRRL <str_ruiling@outlook.com> * fix: fallback to v1beta1 Signed-off-by: STRRL <str_ruiling@outlook.com> * Revert "fix: also bump the verison of controller-runtime" This reverts commit 8e05196. Signed-off-by: STRRL <str_ruiling@outlook.com> * fix: fill the conditional branches if nil Signed-off-by: STRRL <str_ruiling@outlook.com> * fix: permission of custom task about creating pod Signed-off-by: STRRL <str_ruiling@outlook.com> * feat: use v1 instead of v1beta1 with CRD Signed-off-by: STRRL <str_ruiling@outlook.com> * fix: NOOP when pods exactly same Signed-off-by: STRRL <str_ruiling@outlook.com> * refactor: refactor the collectors Signed-off-by: STRRL <str_ruiling@outlook.com> * feat: finish the rest of task nodes Signed-off-by: STRRL <str_ruiling@outlook.com> * fix: check before sync nodes in task Signed-off-by: STRRL <str_ruiling@outlook.com> * chore: make linters happier Signed-off-by: STRRL <str_ruiling@outlook.com> * chore: make linters happier Signed-off-by: STRRL <str_ruiling@outlook.com> * Update pkg/workflow/controllers/task_reconciler.go Signed-off-by: STRRL <str_ruiling@outlook.com> Co-authored-by: AsterNighT <klxjt99@outlook.com> * fix: use create instead of apply apply will create a huge annotaion which exceed the limit of size of annotation Signed-off-by: STRRL <str_ruiling@outlook.com> * chore: update the comments for workflow template Signed-off-by: STRRL <str_ruiling@outlook.com> * fix: crd installation in e2e test Signed-off-by: STRRL <str_ruiling@outlook.com> Co-authored-by: AsterNighT <klxjt99@outlook.com> Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io>
* feat: conditional branches in workflownode Signed-off-by: STRRL <str_ruiling@outlook.com> * feat: reconciler of task node Signed-off-by: STRRL <str_ruiling@outlook.com> * feat: setup one container for task node Signed-off-by: STRRL <str_ruiling@outlook.com> * fix: address the comments by muse-dev Signed-off-by: STRRL <str_ruiling@outlook.com> * chore: cleanup duplicated codes Signed-off-by: STRRL <str_ruiling@outlook.com> * fix: bump controller-gen version compliable issue with kubernetes 1.18, detail: kubernetes-sigs/controller-tools#480 Signed-off-by: STRRL <str_ruiling@outlook.com> * chore: bump the version of controller-gen to v0.4.1 Signed-off-by: STRRL <str_ruiling@outlook.com> * fix: restrict kubernetes version with replace Signed-off-by: STRRL <str_ruiling@outlook.com> * fix: also restrict version for e2e-test Signed-off-by: STRRL <str_ruiling@outlook.com> * fix: also bump the verison of controller-runtime Signed-off-by: STRRL <str_ruiling@outlook.com> * fix: fallback to v1beta1 Signed-off-by: STRRL <str_ruiling@outlook.com> * Revert "fix: also bump the verison of controller-runtime" This reverts commit 8e05196. Signed-off-by: STRRL <str_ruiling@outlook.com> * fix: fill the conditional branches if nil Signed-off-by: STRRL <str_ruiling@outlook.com> * fix: permission of custom task about creating pod Signed-off-by: STRRL <str_ruiling@outlook.com> * feat: use v1 instead of v1beta1 with CRD Signed-off-by: STRRL <str_ruiling@outlook.com> * fix: NOOP when pods exactly same Signed-off-by: STRRL <str_ruiling@outlook.com> * refactor: refactor the collectors Signed-off-by: STRRL <str_ruiling@outlook.com> * feat: finish the rest of task nodes Signed-off-by: STRRL <str_ruiling@outlook.com> * fix: check before sync nodes in task Signed-off-by: STRRL <str_ruiling@outlook.com> * chore: make linters happier Signed-off-by: STRRL <str_ruiling@outlook.com> * chore: make linters happier Signed-off-by: STRRL <str_ruiling@outlook.com> * Update pkg/workflow/controllers/task_reconciler.go Signed-off-by: STRRL <str_ruiling@outlook.com> Co-authored-by: AsterNighT <klxjt99@outlook.com> * fix: use create instead of apply apply will create a huge annotaion which exceed the limit of size of annotation Signed-off-by: STRRL <str_ruiling@outlook.com> * chore: update the comments for workflow template Signed-off-by: STRRL <str_ruiling@outlook.com> * fix: crd installation in e2e test Signed-off-by: STRRL <str_ruiling@outlook.com> Co-authored-by: AsterNighT <klxjt99@outlook.com> Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io> Signed-off-by: root <root@vm3.jisiqhvhuzaupp2x5y5vff1eff.fx.internal.cloudapp.net>
* feat: conditional branches in workflownode Signed-off-by: STRRL <str_ruiling@outlook.com> * feat: reconciler of task node Signed-off-by: STRRL <str_ruiling@outlook.com> * feat: setup one container for task node Signed-off-by: STRRL <str_ruiling@outlook.com> * fix: address the comments by muse-dev Signed-off-by: STRRL <str_ruiling@outlook.com> * chore: cleanup duplicated codes Signed-off-by: STRRL <str_ruiling@outlook.com> * fix: bump controller-gen version compliable issue with kubernetes 1.18, detail: kubernetes-sigs/controller-tools#480 Signed-off-by: STRRL <str_ruiling@outlook.com> * chore: bump the version of controller-gen to v0.4.1 Signed-off-by: STRRL <str_ruiling@outlook.com> * fix: restrict kubernetes version with replace Signed-off-by: STRRL <str_ruiling@outlook.com> * fix: also restrict version for e2e-test Signed-off-by: STRRL <str_ruiling@outlook.com> * fix: also bump the verison of controller-runtime Signed-off-by: STRRL <str_ruiling@outlook.com> * fix: fallback to v1beta1 Signed-off-by: STRRL <str_ruiling@outlook.com> * Revert "fix: also bump the verison of controller-runtime" This reverts commit 8e05196. Signed-off-by: STRRL <str_ruiling@outlook.com> * fix: fill the conditional branches if nil Signed-off-by: STRRL <str_ruiling@outlook.com> * fix: permission of custom task about creating pod Signed-off-by: STRRL <str_ruiling@outlook.com> * feat: use v1 instead of v1beta1 with CRD Signed-off-by: STRRL <str_ruiling@outlook.com> * fix: NOOP when pods exactly same Signed-off-by: STRRL <str_ruiling@outlook.com> * refactor: refactor the collectors Signed-off-by: STRRL <str_ruiling@outlook.com> * feat: finish the rest of task nodes Signed-off-by: STRRL <str_ruiling@outlook.com> * fix: check before sync nodes in task Signed-off-by: STRRL <str_ruiling@outlook.com> * chore: make linters happier Signed-off-by: STRRL <str_ruiling@outlook.com> * chore: make linters happier Signed-off-by: STRRL <str_ruiling@outlook.com> * Update pkg/workflow/controllers/task_reconciler.go Signed-off-by: STRRL <str_ruiling@outlook.com> Co-authored-by: AsterNighT <klxjt99@outlook.com> * fix: use create instead of apply apply will create a huge annotaion which exceed the limit of size of annotation Signed-off-by: STRRL <str_ruiling@outlook.com> * chore: update the comments for workflow template Signed-off-by: STRRL <str_ruiling@outlook.com> * fix: crd installation in e2e test Signed-off-by: STRRL <str_ruiling@outlook.com> Co-authored-by: AsterNighT <klxjt99@outlook.com> Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io> Signed-off-by: root <root@vm3.jisiqhvhuzaupp2x5y5vff1eff.fx.internal.cloudapp.net>
Mitigation to help resolve #444 whilst waiting for kubernetes/enhancements#1928 to merge.
This patch will cause resources that embed e.g.
ServiceSpec
orPodSpec
to have thedefault
field set for theprotocol
field:This will workaround the issue described in #444, and can be easily extended to new fields/types as they are discovered.
We should probably also consider fixing #445 as well, as this may cause some users that are not specifying
// +kubebuilder:default
annotations in their resources to begin specifying adefault
field (if they utilise thisProtocol
type), which will causekubectl
client side validation errors (which will require users to add--validate=false
to theirkubectl create
usages)/cc @pwittrock @tamalsaha