Skip to content

Commit

Permalink
Bug fix: Allow setting vmiCPUAllocationRatio to 1 (#3211)
Browse files Browse the repository at this point in the history
The value of vmiCPUAllocationRatio should be greater than 0

Signed-off-by: bmordeha <[email protected]>
  • Loading branch information
Barakmor1 authored Dec 18, 2024
1 parent b3b8839 commit 52ddda6
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion api/v1beta1/hyperconverged_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ type HyperConvergedSpec struct {

// ResourceRequirements describes the resource requirements for the operand workloads.
// +kubebuilder:default={"vmiCPUAllocationRatio": 10}
// +kubebuilder:validation:XValidation:rule="!has(self.vmiCPUAllocationRatio) || self.vmiCPUAllocationRatio != 1",message="Automatic CPU limits are incompatible with a VMI CPU allocation ratio of 1"
// +kubebuilder:validation:XValidation:rule="!has(self.vmiCPUAllocationRatio) || self.vmiCPUAllocationRatio > 0",message="vmiCPUAllocationRatio must be greater than 0"
// +optional
ResourceRequirements *OperandResourceRequirements `json:"resourceRequirements,omitempty"`

Expand Down
5 changes: 2 additions & 3 deletions config/crd/bases/hco.kubevirt.io_hyperconvergeds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2730,10 +2730,9 @@ spec:
type: integer
type: object
x-kubernetes-validations:
- message: Automatic CPU limits are incompatible with a VMI CPU allocation
ratio of 1
- message: vmiCPUAllocationRatio must be greater than 0
rule: '!has(self.vmiCPUAllocationRatio) || self.vmiCPUAllocationRatio
!= 1'
> 0'
scratchSpaceStorageClass:
description: |-
Override the storage class used for scratch space during transfer operations. The scratch space storage class
Expand Down
5 changes: 2 additions & 3 deletions deploy/crds/hco00.crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2730,10 +2730,9 @@ spec:
type: integer
type: object
x-kubernetes-validations:
- message: Automatic CPU limits are incompatible with a VMI CPU allocation
ratio of 1
- message: vmiCPUAllocationRatio must be greater than 0
rule: '!has(self.vmiCPUAllocationRatio) || self.vmiCPUAllocationRatio
!= 1'
> 0'
scratchSpaceStorageClass:
description: |-
Override the storage class used for scratch space during transfer operations. The scratch space storage class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2730,10 +2730,9 @@ spec:
type: integer
type: object
x-kubernetes-validations:
- message: Automatic CPU limits are incompatible with a VMI CPU allocation
ratio of 1
- message: vmiCPUAllocationRatio must be greater than 0
rule: '!has(self.vmiCPUAllocationRatio) || self.vmiCPUAllocationRatio
!= 1'
> 0'
scratchSpaceStorageClass:
description: |-
Override the storage class used for scratch space during transfer operations. The scratch space storage class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2730,10 +2730,9 @@ spec:
type: integer
type: object
x-kubernetes-validations:
- message: Automatic CPU limits are incompatible with a VMI CPU allocation
ratio of 1
- message: vmiCPUAllocationRatio must be greater than 0
rule: '!has(self.vmiCPUAllocationRatio) || self.vmiCPUAllocationRatio
!= 1'
> 0'
scratchSpaceStorageClass:
description: |-
Override the storage class used for scratch space during transfer operations. The scratch space storage class
Expand Down
2 changes: 1 addition & 1 deletion tests/func-tests/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var _ = Describe("Check CR validation", Label("validation"), Serial, func() {
}).WithTimeout(10 * time.Second).WithPolling(500 * time.Millisecond).WithContext(ctx).Should(outcome)
},
Entry("succeed when VMI CPU allocation is nil", nil, Succeed()),
Entry("fail when VMI CPU allocation is 1", ptr.To(1), MatchError(ContainSubstring("Automatic CPU limits are incompatible with a VMI CPU allocation ratio of 1"))),
Entry("fail when VMI CPU allocation is 0", ptr.To(0), MatchError(ContainSubstring("vmiCPUAllocationRatio must be greater than 0"))),
Entry("succeed when VMI CPU allocation is 2", ptr.To(2), Succeed()),
)
})
Expand Down

0 comments on commit 52ddda6

Please sign in to comment.