Skip to content

Conversation

@pedjak
Copy link
Contributor

@pedjak pedjak commented Nov 22, 2024

The default value for the field is true, and it is omitted from the serialized output if the field is set to false. Hence, it is possible to flip value from true to false in the following scenario:

  • client submits to k8s API server with ServicePerNode=false
  • client fetches the persisted instance from k8s API server, given that false for a boolean is considered empty, ServicePerNode field does not appear in the received payload.
  • client updates the payload and sends it back the k8s API server. Given that ServicePerNode is not present in the payload, k8s API server is going to flip it to the default value, which is true

To correct this, omitempty tag is removed for ServicePerNode field, so that the field is always present in the serialized output.

The default value for the field is `true`, and it is omitted from the serialized
output if the field is set to false. Hence, it is possible to flip value from `true` to
`false` in the following scenario:

* client submits to k8s API server with `ServicePerNode=false`
* client fetch the persisted instance from k8s API server, given that
`false` for a boolean is considered empty, `ServicePerNode` field does
not appear in the received payload.
* client updates the payload and sends it back the k8s API server. Given
that `ServicePerNode` is not present in the payload, k8s API server is going
to flip it to the default value, which is `true`

To correct this, `omitempty` tag is removed for `ServicePerNode` field,
so that the field is always present in the serialized output.
@pedjak pedjak requested a review from a team as a code owner November 22, 2024 12:16
@pedjak pedjak self-assigned this Nov 22, 2024
@pedjak pedjak added the bug Something isn't working label Nov 22, 2024
@github-actions github-actions bot added the fix label Nov 22, 2024
@pedjak pedjak merged commit 616d0bd into main Nov 22, 2024
4 checks passed
@pedjak pedjak deleted the fix/predrag/serialize-servicepernode-always branch November 22, 2024 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants