Skip to content

Commit

Permalink
Merge pull request #543 from ksimon1/guest-memory
Browse files Browse the repository at this point in the history
feat: replace vm.spec.template.spec.domain.resources.requests.memory …
  • Loading branch information
ksimon1 authored Aug 30, 2023
2 parents 7a2e34e + 885e2bc commit 7c16e78
Show file tree
Hide file tree
Showing 19 changed files with 69 additions and 85 deletions.
2 changes: 1 addition & 1 deletion automation/validate-min-memory-consistency.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def newestOsLabel(template):

def minMemoryReqInTemplate(template):
object = template["objects"][0]
min_str = object["spec"]["template"]["spec"]["domain"]["resources"]["requests"]["memory"]
min_str = object["spec"]["template"]["spec"]["domain"]["memory"]["guest"]
if min_str.startswith("${"):
for param in template["parameters"]:
if param["name"] == min_str[2:-1]:
Expand Down
4 changes: 2 additions & 2 deletions templates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ metadata:
# The jsonpath root is the objects: element of the template
template.kubevirt.io/editable: |
/objects[0].spec.template.spec.domain.cpu.cores
/objects[0].spec.template.spec.domain.resources.requests.memory
/objects[0].spec.template.spec.domain.memory.guest
/objects[0].spec.template.spec.domain.devices.disks
/objects[0].spec.template.spec.volumes
/objects[0].spec.template.spec.networks
Expand Down Expand Up @@ -211,7 +211,7 @@ metadata:
# The jsonpath root is the spec: element of the VM object
template.kubevirt.io/keep: |
/template.spec.domain.cpu.cores
/template.spec.domain.resources.requests.memory
/template.spec.domain.memory.guest
/template.spec.domain.devices.disks
/template.spec.volumes
/template.spec.networks
Expand Down
4 changes: 2 additions & 2 deletions templates/VALIDATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ the `jsonpath::` prefix.

good:
```
jsonpath::.spec.domain.resources.requests.memory
jsonpath::.spec.domain.memory.guest
```

bad:
```
.spec.domain.resources.requests.memory
.spec.domain.memory.guest
```

### Validation rules
Expand Down
9 changes: 4 additions & 5 deletions templates/centos-stream8.tpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ metadata:
/objects[0].spec.template.spec.domain.cpu.sockets
/objects[0].spec.template.spec.domain.cpu.cores
/objects[0].spec.template.spec.domain.cpu.threads
/objects[0].spec.template.spec.domain.resources.requests.memory
/objects[0].spec.template.spec.domain.memory.guest
/objects[0].spec.template.spec.domain.devices.disks
/objects[0].spec.template.spec.volumes
/objects[0].spec.template.spec.networks
Expand Down Expand Up @@ -64,7 +64,7 @@ objects:
[
{
"name": "minimal-required-memory",
"path": "jsonpath::.spec.domain.resources.requests.memory",
"path": "jsonpath::.spec.domain.memory.guest",
"rule": "integer",
"message": "This VM requires more memory.",
"min": {{ lookup('osinfo', osinfoname)["minimum_resources.architecture=x86_64|all.ram"] }}
Expand Down Expand Up @@ -107,9 +107,8 @@ objects:
{% if cpumodel |default("") %}
model: {{ cpumodel }}
{% endif %}
resources:
requests:
memory: {{ item.memsize }}
memory:
guest: {{ item.memsize }}
devices:
rng: {}
networkInterfaceMultiqueue: true
Expand Down
9 changes: 4 additions & 5 deletions templates/centos-stream9.tpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ metadata:
/objects[0].spec.template.spec.domain.cpu.sockets
/objects[0].spec.template.spec.domain.cpu.cores
/objects[0].spec.template.spec.domain.cpu.threads
/objects[0].spec.template.spec.domain.resources.requests.memory
/objects[0].spec.template.spec.domain.memory.guest
/objects[0].spec.template.spec.domain.devices.disks
/objects[0].spec.template.spec.volumes
/objects[0].spec.template.spec.networks
Expand Down Expand Up @@ -64,7 +64,7 @@ objects:
[
{
"name": "minimal-required-memory",
"path": "jsonpath::.spec.domain.resources.requests.memory",
"path": "jsonpath::.spec.domain.memory.guest",
"rule": "integer",
"message": "This VM requires more memory.",
"min": {{ lookup('osinfo', osinfoname)["minimum_resources.architecture=x86_64|all.ram"] }}
Expand Down Expand Up @@ -107,9 +107,8 @@ objects:
{% if cpumodel |default("") %}
model: {{ cpumodel }}
{% endif %}
resources:
requests:
memory: {{ item.memsize }}
memory:
guest: {{ item.memsize }}
devices:
rng: {}
networkInterfaceMultiqueue: true
Expand Down
9 changes: 4 additions & 5 deletions templates/centos6.tpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ metadata:
/objects[0].spec.template.spec.domain.cpu.sockets
/objects[0].spec.template.spec.domain.cpu.cores
/objects[0].spec.template.spec.domain.cpu.threads
/objects[0].spec.template.spec.domain.resources.requests.memory
/objects[0].spec.template.spec.domain.memory.guest
/objects[0].spec.template.spec.domain.devices.disks
/objects[0].spec.template.spec.volumes
/objects[0].spec.template.spec.networks
Expand Down Expand Up @@ -54,7 +54,7 @@ objects:
[
{
"name": "minimal-required-memory",
"path": "jsonpath::.spec.domain.resources.requests.memory",
"path": "jsonpath::.spec.domain.memory.guest",
"rule": "integer",
"message": "This VM requires more memory.",
"min": {{ lookup('osinfo', osinfoname)["minimum_resources.architecture=x86_64|all.ram"] }}
Expand Down Expand Up @@ -97,9 +97,8 @@ objects:
{% if cpumodel |default("") %}
model: {{ cpumodel }}
{% endif %}
resources:
requests:
memory: {{ item.memsize }}
memory:
guest: {{ item.memsize }}
devices:
networkInterfaceMultiqueue: true
useVirtioTransitional: true
Expand Down
9 changes: 4 additions & 5 deletions templates/centos7.tpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ metadata:
/objects[0].spec.template.spec.domain.cpu.sockets
/objects[0].spec.template.spec.domain.cpu.cores
/objects[0].spec.template.spec.domain.cpu.threads
/objects[0].spec.template.spec.domain.resources.requests.memory
/objects[0].spec.template.spec.domain.memory.guest
/objects[0].spec.template.spec.domain.devices.disks
/objects[0].spec.template.spec.volumes
/objects[0].spec.template.spec.networks
Expand Down Expand Up @@ -64,7 +64,7 @@ objects:
[
{
"name": "minimal-required-memory",
"path": "jsonpath::.spec.domain.resources.requests.memory",
"path": "jsonpath::.spec.domain.memory.guest",
"rule": "integer",
"message": "This VM requires more memory.",
"min": {{ lookup('osinfo', osinfoname)["minimum_resources.architecture=x86_64|all.ram"] }}
Expand Down Expand Up @@ -107,9 +107,8 @@ objects:
{% if cpumodel |default("") %}
model: {{ cpumodel }}
{% endif %}
resources:
requests:
memory: {{ item.memsize }}
memory:
guest: {{ item.memsize }}
devices:
rng: {}
networkInterfaceMultiqueue: true
Expand Down
9 changes: 4 additions & 5 deletions templates/fedora.tpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ metadata:
/objects[0].spec.template.spec.domain.cpu.sockets
/objects[0].spec.template.spec.domain.cpu.cores
/objects[0].spec.template.spec.domain.cpu.threads
/objects[0].spec.template.spec.domain.resources.requests.memory
/objects[0].spec.template.spec.domain.memory.guest
/objects[0].spec.template.spec.domain.devices.disks
/objects[0].spec.template.spec.volumes
/objects[0].spec.template.spec.networks
Expand Down Expand Up @@ -63,7 +63,7 @@ objects:
[
{
"name": "minimal-required-memory",
"path": "jsonpath::.spec.domain.resources.requests.memory",
"path": "jsonpath::.spec.domain.memory.guest",
"rule": "integer",
"message": "This VM requires more memory.",
"min": {{ lookup('osinfo', osinfoname)["minimum_resources.architecture=x86_64|all.ram"] }}
Expand Down Expand Up @@ -118,9 +118,8 @@ objects:
{% if item.emulatorthread %}
isolateEmulatorThread: True
{% endif %}
resources:
requests:
memory: {{ item.memsize }}
memory:
guest: {{ item.memsize }}
devices:
rng: {}
networkInterfaceMultiqueue: true
Expand Down
9 changes: 4 additions & 5 deletions templates/opensuse.tpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ metadata:
/objects[0].spec.template.spec.domain.cpu.sockets
/objects[0].spec.template.spec.domain.cpu.cores
/objects[0].spec.template.spec.domain.cpu.threads
/objects[0].spec.template.spec.domain.resources.requests.memory
/objects[0].spec.template.spec.domain.memory.guest
/objects[0].spec.template.spec.domain.devices.disks
/objects[0].spec.template.spec.volumes
/objects[0].spec.template.spec.networks
Expand Down Expand Up @@ -58,7 +58,7 @@ objects:
[
{
"name": "minimal-required-memory",
"path": "jsonpath::.spec.domain.resources.requests.memory",
"path": "jsonpath::.spec.domain.memory.guest",
"rule": "integer",
"message": "This VM requires more memory.",
"min": {{ lookup('osinfo', osinfoname)["minimum_resources.architecture=x86_64|all.ram"] }}
Expand Down Expand Up @@ -101,9 +101,8 @@ objects:
{% if cpumodel |default("") %}
model: {{ cpumodel }}
{% endif %}
resources:
requests:
memory: {{ item.memsize }}
memory:
guest: {{ item.memsize }}
devices:
rng: {}
networkInterfaceMultiqueue: true
Expand Down
9 changes: 4 additions & 5 deletions templates/rhel7.tpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ metadata:
/objects[0].spec.template.spec.domain.cpu.sockets
/objects[0].spec.template.spec.domain.cpu.cores
/objects[0].spec.template.spec.domain.cpu.threads
/objects[0].spec.template.spec.domain.resources.requests.memory
/objects[0].spec.template.spec.domain.memory.guest
/objects[0].spec.template.spec.domain.devices.disks
/objects[0].spec.template.spec.volumes
/objects[0].spec.template.spec.networks
Expand Down Expand Up @@ -58,7 +58,7 @@ objects:
[
{
"name": "minimal-required-memory",
"path": "jsonpath::.spec.domain.resources.requests.memory",
"path": "jsonpath::.spec.domain.memory.guest",
"rule": "integer",
"message": "This VM requires more memory.",
"min": {{ lookup('osinfo', osinfoname)["minimum_resources.architecture=x86_64|all.ram"] }}
Expand Down Expand Up @@ -107,9 +107,8 @@ objects:
{% if item.emulatorthread %}
isolateEmulatorThread: True
{% endif %}
resources:
requests:
memory: {{ item.memsize }}
memory:
guest: {{ item.memsize }}
devices:
rng: {}
networkInterfaceMultiqueue: true
Expand Down
9 changes: 4 additions & 5 deletions templates/rhel8.tpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ metadata:
/objects[0].spec.template.spec.domain.cpu.sockets
/objects[0].spec.template.spec.domain.cpu.cores
/objects[0].spec.template.spec.domain.cpu.threads
/objects[0].spec.template.spec.domain.resources.requests.memory
/objects[0].spec.template.spec.domain.memory.guest
/objects[0].spec.template.spec.domain.devices.disks
/objects[0].spec.template.spec.volumes
/objects[0].spec.template.spec.networks
Expand Down Expand Up @@ -60,7 +60,7 @@ objects:
[
{
"name": "minimal-required-memory",
"path": "jsonpath::.spec.domain.resources.requests.memory",
"path": "jsonpath::.spec.domain.memory.guest",
"rule": "integer",
"message": "This VM requires more memory.",
"min": {{ lookup('osinfo', osinfoname)["minimum_resources.architecture=x86_64|all.ram"] }}
Expand Down Expand Up @@ -109,9 +109,8 @@ objects:
{% if item.emulatorthread %}
isolateEmulatorThread: True
{% endif %}
resources:
requests:
memory: {{ item.memsize }}
memory:
guest: {{ item.memsize }}
devices:
rng: {}
networkInterfaceMultiqueue: true
Expand Down
9 changes: 4 additions & 5 deletions templates/rhel9.tpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ metadata:
/objects[0].spec.template.spec.domain.cpu.sockets
/objects[0].spec.template.spec.domain.cpu.cores
/objects[0].spec.template.spec.domain.cpu.threads
/objects[0].spec.template.spec.domain.resources.requests.memory
/objects[0].spec.template.spec.domain.memory.guest
/objects[0].spec.template.spec.domain.devices.disks
/objects[0].spec.template.spec.volumes
/objects[0].spec.template.spec.networks
Expand Down Expand Up @@ -60,7 +60,7 @@ objects:
[
{
"name": "minimal-required-memory",
"path": "jsonpath::.spec.domain.resources.requests.memory",
"path": "jsonpath::.spec.domain.memory.guest",
"rule": "integer",
"message": "This VM requires more memory.",
"min": {{ lookup('osinfo', osinfoname)["minimum_resources.architecture=x86_64|all.ram"] }}
Expand Down Expand Up @@ -109,9 +109,8 @@ objects:
{% if item.emulatorthread %}
isolateEmulatorThread: True
{% endif %}
resources:
requests:
memory: {{ item.memsize }}
memory:
guest: {{ item.memsize }}
devices:
rng: {}
networkInterfaceMultiqueue: true
Expand Down
9 changes: 4 additions & 5 deletions templates/ubuntu.tpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ metadata:
/objects[0].spec.template.spec.domain.cpu.sockets
/objects[0].spec.template.spec.domain.cpu.cores
/objects[0].spec.template.spec.domain.cpu.threads
/objects[0].spec.template.spec.domain.resources.requests.memory
/objects[0].spec.template.spec.domain.memory.guest
/objects[0].spec.template.spec.domain.devices.disks
/objects[0].spec.template.spec.volumes
/objects[0].spec.template.spec.networks
Expand Down Expand Up @@ -64,7 +64,7 @@ objects:
[
{
"name": "minimal-required-memory",
"path": "jsonpath::.spec.domain.resources.requests.memory",
"path": "jsonpath::.spec.domain.memory.guest",
"rule": "integer",
"message": "This VM requires more memory.",
"min": {{ lookup('osinfo', osinfoname)["minimum_resources.architecture=x86_64|all.ram"] }}
Expand Down Expand Up @@ -107,9 +107,8 @@ objects:
{% if cpumodel |default("") %}
model: {{ cpumodel }}
{% endif %}
resources:
requests:
memory: {{ item.memsize }}
memory:
guest: {{ item.memsize }}
devices:
rng: {}
networkInterfaceMultiqueue: true
Expand Down
9 changes: 4 additions & 5 deletions templates/windows10.tpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ metadata:
defaults.template.kubevirt.io/network: default
template.kubevirt.io/editable: |
/objects[0].spec.template.spec.domain.cpu.cores
/objects[0].spec.template.spec.domain.resources.requests.memory
/objects[0].spec.template.spec.domain.memory.guest
/objects[0].spec.template.spec.domain.devices.disks
/objects[0].spec.template.spec.volumes
/objects[0].spec.template.spec.networks
Expand Down Expand Up @@ -47,7 +47,7 @@ objects:
[
{
"name": "minimal-required-memory",
"path": "jsonpath::.spec.domain.resources.requests.memory",
"path": "jsonpath::.spec.domain.memory.guest",
"rule": "integer",
"message": "This VM requires more memory.",
"min": {{ lookup('osinfo', osinfoname)["minimum_resources.architecture=x86_64.ram"] }}
Expand Down Expand Up @@ -122,9 +122,8 @@ objects:
{% if item.emulatorthread %}
isolateEmulatorThread: True
{% endif %}
resources:
requests:
memory: {{ item.memsize }}
memory:
guest: {{ item.memsize }}
features:
acpi: {}
apic: {}
Expand Down
Loading

0 comments on commit 7c16e78

Please sign in to comment.