Skip to content

Commit

Permalink
[release-1.8] Avoid omitempty on WorkloadUpdateMethods (#2180) (#2181)
Browse files Browse the repository at this point in the history
In our API for WorkloadUpdateMethods we read:
...
An empty list defaults to no automated workload updating.

and a default of: ["LiveMigrate"]

but in the past the json representation of
WorkloadUpdateMethods was defined with omitempty
but, as for:
https://go.dev/src/encoding/json/encode.go
// The "omitempty" option specifies that the field should be omitted
// from the encoding if the field has an empty value, defined as
// false, 0, a nil pointer, a nil interface value, and any empty array,
// slice, map, or string.

the golang json encoder is omitting also empty array and slice
and so an empty list on WorkloadUpdateMethods gets omitted at json
level and so the APIServer will then replace it with the
default value (["LiveMigrate"]).

Avoid declaring omitempty on WorkloadUpdateMethods to
make an empty list an acceptable value.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2151693

This is a manual cherry-pick of #2180

Signed-off-by: Simone Tiraboschi <[email protected]>

Signed-off-by: Simone Tiraboschi <[email protected]>
  • Loading branch information
tiraboschi authored Dec 14, 2022
1 parent a7eb458 commit fb0adee
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 3 deletions.
3 changes: 1 addition & 2 deletions api/v1beta1/hyperconverged_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,7 @@ type HyperConvergedWorkloadUpdateStrategy struct {
//
// +listType=atomic
// +kubebuilder:default={"LiveMigrate"}
// +optional
WorkloadUpdateMethods []string `json:"workloadUpdateMethods,omitempty"`
WorkloadUpdateMethods []string `json:"workloadUpdateMethods"`

// BatchEvictionSize Represents the number of VMIs that can be forced updated per
// the BatchShutdownInterval interval
Expand Down
1 change: 1 addition & 0 deletions api/v1beta1/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions config/crd/bases/hco.kubevirt.io_hyperconvergeds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2290,6 +2290,8 @@ spec:
type: string
type: array
x-kubernetes-list-type: atomic
required:
- workloadUpdateMethods
type: object
workloads:
description: workloads HyperConvergedConfig influences the pod configuration
Expand Down
2 changes: 2 additions & 0 deletions deploy/crds/hco00.crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2290,6 +2290,8 @@ spec:
type: string
type: array
x-kubernetes-list-type: atomic
required:
- workloadUpdateMethods
type: object
workloads:
description: workloads HyperConvergedConfig influences the pod configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2290,6 +2290,8 @@ spec:
type: string
type: array
x-kubernetes-list-type: atomic
required:
- workloadUpdateMethods
type: object
workloads:
description: workloads HyperConvergedConfig influences the pod configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2290,6 +2290,8 @@ spec:
type: string
type: array
x-kubernetes-list-type: atomic
required:
- workloadUpdateMethods
type: object
workloads:
description: workloads HyperConvergedConfig influences the pod configuration
Expand Down
2 changes: 1 addition & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ HyperConvergedWorkloadUpdateStrategy defines options related to updating a KubeV

| Field | Description | Scheme | Default | Required |
| ----- | ----------- | ------ | -------- |-------- |
| workloadUpdateMethods | WorkloadUpdateMethods defines the methods that can be used to disrupt workloads during automated workload updates. When multiple methods are present, the least disruptive method takes precedence over more disruptive methods. For example if both LiveMigrate and Evict methods are listed, only VMs which are not live migratable will be restarted/shutdown. An empty list defaults to no automated workload updating. | []string | {"LiveMigrate"} | false |
| workloadUpdateMethods | WorkloadUpdateMethods defines the methods that can be used to disrupt workloads during automated workload updates. When multiple methods are present, the least disruptive method takes precedence over more disruptive methods. For example if both LiveMigrate and Evict methods are listed, only VMs which are not live migratable will be restarted/shutdown. An empty list defaults to no automated workload updating. | []string | {"LiveMigrate"} | true |
| batchEvictionSize | BatchEvictionSize Represents the number of VMIs that can be forced updated per the BatchShutdownInterval interval | *int | 10 | false |
| batchEvictionInterval | BatchEvictionInterval Represents the interval to wait before issuing the next batch of shutdowns | *metav1.Duration | "1m0s" | false |

Expand Down

0 comments on commit fb0adee

Please sign in to comment.