Skip to content

Commit 25185ae

Browse files
Support fractional overcommit values
1 parent 6652086 commit 25185ae

5 files changed

Lines changed: 38 additions & 22 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ check: FORCE static-check build/cover.html build-all
117117

118118
generate: install-controller-gen
119119
@printf "\e[1;36m>> controller-gen\e[0m\n"
120-
@controller-gen crd rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
120+
@controller-gen crd:allowDangerousTypes=true rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
121121
@controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
122122
@controller-gen applyconfiguration paths="./..."
123123

api/v1/hypervisor_types.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,15 @@ type HypervisorSpec struct {
162162
// Overcommit specifies the desired overcommit ratio by resource type.
163163
//
164164
// If no overcommit is specified for a resource type, the default overcommit
165-
// ratio of 1 should be applied.
165+
// ratio of 1.0 should be applied, i.e. the effective capacity is the same
166+
// as the actual capacity.
167+
//
168+
// If the overcommit ratio results in a fractional effective capacity,
169+
// the effective capacity is expected to be rounded down. This allows
170+
// gradually adjusting the hypervisor capacity.
166171
//
167172
// +kubebuilder:validation:Optional
168-
Overcommit map[corev1.ResourceName]uint `json:"overcommit,omitempty"`
173+
Overcommit map[corev1.ResourceName]float64 `json:"overcommit,omitempty"`
169174
}
170175

171176
const (
@@ -389,6 +394,9 @@ type HypervisorStatus struct {
389394
// overcommit ratio of 1 should be applied, meaning the effective capacity
390395
// is the same as the actual capacity.
391396
//
397+
// If the overcommit ratio results in a fractional effective capacity, the
398+
// effective capacity is expected to be rounded down.
399+
//
392400
// +kubebuilder:validation:Optional
393401
EffectiveCapacity map[ResourceName]resource.Quantity `json:"effectiveCapacity,omitempty"`
394402

api/v1/zz_generated.deepcopy.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

applyconfigurations/api/v1/hypervisorspec.go

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/kvm.cloud.sap_hypervisors.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,17 @@ spec:
167167
type: string
168168
overcommit:
169169
additionalProperties:
170-
type: integer
170+
type: number
171171
description: |-
172172
Overcommit specifies the desired overcommit ratio by resource type.
173173
174174
If no overcommit is specified for a resource type, the default overcommit
175-
ratio of 1 should be applied.
175+
ratio of 1.0 should be applied, i.e. the effective capacity is the same
176+
as the actual capacity.
177+
178+
If the overcommit ratio results in a fractional effective capacity,
179+
the effective capacity is expected to be rounded down. This allows
180+
gradually adjusting the hypervisor capacity.
176181
type: object
177182
reboot:
178183
default: false
@@ -445,6 +450,9 @@ spec:
445450
In case no overcommit ratio is specified for a resource type, the default
446451
overcommit ratio of 1 should be applied, meaning the effective capacity
447452
is the same as the actual capacity.
453+
454+
If the overcommit ratio results in a fractional effective capacity, the
455+
effective capacity is expected to be rounded down.
448456
type: object
449457
evicted:
450458
description: Evicted indicates whether the hypervisor is evicted.

0 commit comments

Comments
 (0)