Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apis/placement/v1/clusterresourceplacement_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ type RollingUpdateConfig struct {
// Absolute number is calculated from percentage by rounding up.
// We consider a resource unavailable when we either remove it from a cluster or in-place
// upgrade the resources content on the same cluster.
// This can not be 0 if MaxSurge is 0.
// The minimum of MaxUnavailable is 1 to avoid rolling out stuck during in-place resource update.
Comment thread
circy9 marked this conversation as resolved.
// Defaults to 25%.
// +kubebuilder:default="25%"
// +kubebuilder:validation:XIntOrString
Comment thread
circy9 marked this conversation as resolved.
Expand All @@ -513,7 +513,7 @@ type RollingUpdateConfig struct {
// The desired number equals to the number of clusters scheduler selected when the placement type is `PickAll`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// The desired number equals to the NumberOfClusters field when the placement type is PickN.

What is the desired number?

// Value can be an absolute number (ex: 5) or a percentage of desire (ex: 10%).
// Absolute number is calculated from percentage by rounding up.
// This does not apply to the case that we do in-place upgrade of resources on the same cluster.
// This does not apply to the case that we do in-place update of resources on the same cluster.
// This can not be 0 if MaxUnavailable is 0.
// Defaults to 25%.
// +kubebuilder:default="25%"
Expand Down
4 changes: 2 additions & 2 deletions apis/placement/v1beta1/clusterresourceplacement_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ type RollingUpdateConfig struct {
// Absolute number is calculated from percentage by rounding up.
// We consider a resource unavailable when we either remove it from a cluster or in-place
// upgrade the resources content on the same cluster.
// This can not be 0 if MaxSurge is 0.
// The minimum of MaxUnavailable is 1 to avoid rolling out stuck during in-place resource update.
// Defaults to 25%.
// +kubebuilder:default="25%"
// +kubebuilder:validation:XIntOrString
Expand All @@ -513,7 +513,7 @@ type RollingUpdateConfig struct {
// The desired number equals to the number of clusters scheduler selected when the placement type is `PickAll`.
// Value can be an absolute number (ex: 5) or a percentage of desire (ex: 10%).
// Absolute number is calculated from percentage by rounding up.
// This does not apply to the case that we do in-place upgrade of resources on the same cluster.
// This does not apply to the case that we do in-place update of resources on the same cluster.
// This can not be 0 if MaxUnavailable is 0.
// Defaults to 25%.
// +kubebuilder:default="25%"
Expand Down
4 changes: 2 additions & 2 deletions pkg/utils/validator/clusterresourceplacement.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,8 @@ func validateRolloutStrategy(rolloutStrategy placementv1beta1.RolloutStrategy) e
if err != nil {
allErr = append(allErr, fmt.Errorf("maxUnavailable `%+v` is invalid: %w", rolloutStrategy.RollingUpdate.MaxUnavailable, err))
}
if value < 0 {
allErr = append(allErr, fmt.Errorf("maxUnavailable must be greater than or equal to 0, got `%+v`", rolloutStrategy.RollingUpdate.MaxUnavailable))
if value < 1 {
allErr = append(allErr, fmt.Errorf("maxUnavailable must be greater than or equal to 1, got `%+v`", rolloutStrategy.RollingUpdate.MaxUnavailable))
}
}
if rolloutStrategy.RollingUpdate.MaxSurge != nil {
Expand Down
15 changes: 14 additions & 1 deletion pkg/utils/validator/clusterresourceplacement_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,20 @@ func TestValidateClusterResourcePlacement_RolloutStrategy(t *testing.T) {
},
},
wantErr: true,
wantErrMsg: "maxUnavailable must be greater than or equal to 0, got `-10`",
wantErrMsg: "maxUnavailable must be greater than or equal to 1, got `-10`",
},
"invalid rollout strategy - zero MaxUnavailable": {
strategy: placementv1beta1.RolloutStrategy{
Type: placementv1beta1.RollingUpdateRolloutStrategyType,
RollingUpdate: &placementv1beta1.RollingUpdateConfig{
MaxUnavailable: &intstr.IntOrString{
Type: 0,
IntVal: 0,
},
},
},
wantErr: true,
wantErrMsg: "maxUnavailable must be greater than or equal to 1, got `0`",
},
"invalid rollout strategy - % error MaxSurge": {
strategy: placementv1beta1.RolloutStrategy{
Expand Down