-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
unexpected behavior for bool type with api conversion #2109
Comments
Hi @morvencao, It does not show a bug with Kubebuilder CLI tool. I understand that you are looking for help/support over how to use the webhooks conversion and implement it. I think @varshaprasad96 has been doing contributions on that and might help you here. @varshaprasad96 could you please give a hand on this one? |
You have not provided Also, are you using
From kubebuilder we don't implement any conversion webhook logic yet, you need to implement |
SDK does not that. @varshaprasad96 has been working on in the PR to scaffold a code to help users with. See: #2084 All points raised by @Adirio are valid. Would also recommend to you use the latest beta version and do the migration. See: https://master.book.kubebuilder.io/migration/v2vsv3.html And then, was decided to just bump the controller-runtime to 0.8.0 for the 3.1.0 release which will be done sequentially after the 3.0.0 stable one which is very closer to happens. See the pr: #1961 However, has no breaking changes from the controller-runtime version used on master now and 0.8.0 so it would also be fine. |
thanks @camilamacedo86 @Adirio We have implemented logic of ConvertTo and ConvertFrom functions for our type, the conversion for the other fields are working as expected, except the fields of I believe this should be relevant to the defaulting feature introduced by the the CustomResourceDefinition of I'm not sure if the kubebuilder Multi-Version API/API conversion supports the defaulting feature of CRD. |
Without the code of those conversions, or at least a simplified version, there is little we can do to check that. Providing a minimal reproducible example would be the best approach. |
@Adirio Before I logged the issue, I did some experiment. |
I think it may be related to some |
Maybe, I'll try to verify if it's the The conversion logic is quite simple:
|
That's strange, both methods are setting that variable directly. Any mutating webhook? |
@Adirio No, I don't enable mutating and validate webhook. |
@Adirio Looks like removing the |
Removing the omitempty tag really mitigate the issue, but I have to mention that for the |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-contributor-experience at kubernetes/community. |
Stale issues rot after 30d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-contributor-experience at kubernetes/community. |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /close |
@k8s-triage-robot: Closing this issue. 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. |
Issue Description:
We are supporting Multi-Version APIs for our controller built with kubebuilder, we have API of two versions:
v1beta1
andv1beta2
, the api conversion is done through the webhook. Thev1beta2
acts as hub version(storage version), whilev1beta1
acts as spoke version,In
v1beta1
andv1beta2
versions, we have some fields of bool type, we found unexpected behavior with these fields.Case 1: for a field EnableMetrics exists in both
v1beta1
andv1beta2
versions, its default value in bothv1beta1
andv1beta2
versions istrue
.If we set field EnableMetrics in
v1beta1
version tofalse
explicitly, then the field EnableMetrics inv1beta1
will converted tov1beta2
and that is expected from conversion logs.However then we see logs of conversion from
v1beta2
tov1beta1
, at that time the field EnableMetrics inv1beta2
actually becomestrue
, then the field EnableMetrics inv1beta1
also becometrue
after conversion.We suspect that the default value of field EnableMetrics in
v1beta2
overrided the user specified value(false
), and we're sure we don't set the value in our controller.See the conversion logs for more details:
Expected Behavior:
The field
EnableMetrics
should not be override with default value inv1beta2
, since we have explicitly set it to false inv1beta1
.What versions of software are you using? Specifically, the following are often useful:
kubebuilder version
) and scaffolding version (check yourPROJECT
file)go.mod
file). v0.8.0kubectl version
against your API server)/kind bug
@camilamacedo86 Would you help on this?
The text was updated successfully, but these errors were encountered: