-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Issue Description:
We are supporting Multi-Version APIs for our controller built with kubebuilder, we have API of two versions: v1beta1
and v1beta2
, the api conversion is done through the webhook. The v1beta2
acts as hub version(storage version), while v1beta1
acts as spoke version,
In v1beta1
and v1beta2
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
and v1beta2
versions, its default value in both v1beta1
and v1beta2
versions is true
.
If we set field EnableMetrics in v1beta1
version to false
explicitly, then the field EnableMetrics in v1beta1
will converted to v1beta2
and that is expected from conversion logs.
However then we see logs of conversion from v1beta2
to v1beta1
, at that time the field EnableMetrics in v1beta2
actually becomes true
, then the field EnableMetrics in v1beta1
also become true
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:
2021-03-25T09:04:34.269Z INFO api_conversion Converting v1beta1 to v1beta2 {"EnableMetrics in v1beta1": false}
2021-03-25T09:04:34.282Z INFO api_conversion Converting v1beta2 to v1beta1 {"EnableMetrics in v1beta2": true}
2021-03-25T09:04:34.286Z INFO api_conversion Converting v1beta2 to v1beta1 {"EnableMetrics in v1beta2": true}
2021-03-25T09:04:34.290Z INFO api_conversion Converting v1beta2 to v1beta1 {"EnableMetrics in v1beta2": true}
2021-03-25T09:04:34.299Z INFO api_conversion Converting v1beta2 to v1beta1 {"EnableMetrics in v1beta2": true}
Expected Behavior:
The field EnableMetrics
should not be override with default value in v1beta2
, since we have explicitly set it to false in v1beta1
.
What versions of software are you using? Specifically, the following are often useful:
- go version 1.15
- kubebuilder version (
kubebuilder version
) and scaffolding version (check yourPROJECT
file)
...
layout: go.kubebuilder.io/v3
version: 3-alpha
...
- controller-runtime version (check your
go.mod
file). v0.8.0 - controller-tools version v0.4.1
- Kubernetes & kubectl versions (just run
kubectl version
against your API server)
# kubectl version
Client Version: version.Info{Major:"1", Minor:"20", GitVersion:"v1.20.0", GitCommit:"af46c47ce925f4c4ad5cc8d1fca46c7b77d13b38", GitTreeState:"clean", BuildDate:"2020-12-08T17:59:43Z", GoVersion:"go1.15.5", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.0+e49167a", GitCommit:"e49167aad6a08046be6ab21ff13029110c76951d", GitTreeState:"clean", BuildDate:"2021-01-28T07:35:27Z", GoVersion:"go1.15.5", Compiler:"gc", Platform:"linux/amd64"}
/kind bug
@camilamacedo86 Would you help on this?