Allow creating VMs with implicit CPU and memory (#243)

* Allow creating VMs with implicit CPU and memory

* Clarify why cpu/memory can be 0 a bit better

* Controller(API): don't forget to update DefaultCPU and DefaultMemory

* Add an integration test for implicit CPU and memory
This commit is contained in:
Nikolay Edigaryev
2025-02-06 00:50:01 +04:00
committed by GitHub
parent 6b3d64be96
commit 581de320b9
10 changed files with 150 additions and 12 deletions
+13
View File
@@ -34,6 +34,19 @@ type VM struct {
// Worker field is set by the Controller to assign this VM to a specific Worker.
Worker string `json:"worker,omitempty"`
// AssignedCPU is set by the Controller when the VM is scheduled.
//
// It's set to CPU when CPU non-zero, otherwise the value is taken from
// Worker's DefaultCPU field. If Worker's DefaultCPU field is zero, it defaults
// to 4.
AssignedCPU uint64 `json:"assignedCPU,omitempty"`
// AssignedMemory is set by the Controller
//
// It's set to Memory when Memory non-zero, otherwise the value is taken from
// Worker's DefaultCPU field. If Worker's DefaultCPU field is zero, it defaults
// to 8192.
AssignedMemory uint64 `json:"assignedMemory,omitempty"`
Username string `json:"username,omitempty"`
Password string `json:"password,omitempty"`
StartupScript *VMScript `json:"startup_script,omitempty"`
+7
View File
@@ -14,6 +14,13 @@ type Worker struct {
// Resources available on this Worker.
Resources Resources `json:"resources,omitempty"`
// DefaultCPU is the amount of CPUs to assign to a VM
// when it doesn't explicitly request a specific amount.
DefaultCPU uint64 `json:"defaultCPU,omitempty"`
// DefaultMemory is the amount of memory to assign to a VM
// when it doesn't explicitly request a specific amount.
DefaultMemory uint64 `json:"defaultMemory,omitempty"`
Meta
}