Most of them are outdated, but provide historical design context.
They are not user documentation and should not be treated as such.
Documentation is available here.
Prestarted Vm
Summary
The Prestarted Vm feature allows holding a predefined number of unassigned ready to use Vms running in a pool.
Owner
-
Feature owner: Muli Salem (msalem)
-
Backend Component owner: Muli Salem (msalem)
-
GUI Component owner: ?
-
REST Component owner: Michael Pasternak (mpasternak)
-
QA Owner: Tomas Dosek (Tdosek)
-
Current status
- Status: Engine-done, API-done, GUI-design, QA-test plans ready and reviewed
- Last updated date: Tue Dec 27 2011:
Detailed Description
- Today there are 2 types of Vm pools:
- Manual - the Vm is supposed to be manually returned to the pool. In practice, this is not really entirely supported.
- Automatic - once the user shuts down the Vm - it returns to the pool (stateless).
The prestarted Vm feature will deal with Automatic Vm pools.
In ovirt, a VmPool is created based on a specific template. A Vm in the pool can either be assigned to a specific user or be in shutdown state. Therefore, when an admin assigns a Vm to a user, the Vm needs to boot before the user can begin using it.
The prestarted Vm will maintain a number of Vms that are running and not assigned to a specific user (unassigned). This will be at a “best effort” basis, meaning there may be cases in which the number of prestarted Vms will be smaller than the amount defined by the admin.
Benefit to ovirt
The prestarted Vms will allow instant assignment of a Vm from the pool to a user without the user needing to wait for the Vm to start.
PRD
The requirements are the following:
- Enable a Vm in a pool to be both running and unassigned to a specific user.
- Maintain a minimal amount of prestarted Vms, that are running and waiting to be assigned.
- The number of prestarted Vms is a new VMpool property. This number can be changed after Vm pool was already created. In case it is changed, the system is not required to shutdown prestarted Vms, but rather this will be done manually by the admin if necessary.
- The maximum number of prestarted Vms is the size of the VmPool.
- When a Vm is shut down its base snapshot is restored and it is returned to the pool (no change in behaviour here).
- The prestarted Vms creation does not have to begin immediately upon pool creation, but rather can be happen periodically.
Design
Current flow:
- When running Vm from administrator - the RunVm command is called. The changes he makes actually stay on the Vm even after shutdown.
- When running Vm from user portal - AttachUserToVmFromPoolAndRunCommand executes, which runs the addPermission + CreateAllSnapshotsFromVm. On endSuccessfully the RunVm command runs. When Vm is shut down - VmPoolHandler.ProcessVmPoolOnStopVm(vmId) -> removePermission + RestoreAllSnapshots.
New Design:
- Adding a prestarted_vms field to each VmPool.
- This field is configurable upon Vmpool creation by the admin, and has a default value of 0;
- It can be edited after the pool has been created. In case an admin lowers the minimum number, the “extra” Vms will not be shutdown. He will be supplied with the following message:
The prestarted Vms will not be shut down automatically.
prestarted_vms: {|class=”wikitable sortable” !border=”1”| Column Name ||Column Type ||Null? / Default ||Description |- |prestarted_vms || smallint ||not null / default 0 ||The minimum number of prestarted vms |- |}
- We also need to add this column to vm_pools_view and vm_pools_full_view.
VmPoolMonitor Maintaining the number of prestarted will be done periodically. The periodic approach was chosen since it avoids relying on the different stages in the VmPool’s life cycle. There will be a job that runs every x minutes. x is defined in vdc_options in a new row called VmPoolRefreshRate. A new property needs to be added to the engine-config.properties file. The default will be 2 minutes. The job will go over each pool, check whether there are enough prestarted Vms running. If not, it will start the needed amount.
We will the following config values for this job: prestarted_vms: {|class=”wikitable sortable” !border=”1”| config key || config type ||Null? / Default ||Description |- |VmPoolMonitorBatchSize || smallint ||5||The maximum amount of vms that will be prestarted in a single run of the VmPoolMonitor |- |VmPoolMonitorIntervalInMinutes || smallint ||5||The size of interval between VmPoolMonitor runs |- |VmPoolMonitorMaxAttempts || smallint ||3||The number of attempts that are made to prestart a Vm |}
- This option can be optimized by triggering the job upon certain events. Events that should trigger: addVmPool, AttachUserToVmFromPoolCommand…?
Algorithm for selecting a Vm for user
- A vm will be assigned to a user in the following priority:
-
- The Vm is up
- is not running by the admin (Can be deduced from the images status?)
- is not given to another user
- Current assignment:
- The Vm is down
- is not given to a user
-
Algorithm for maintaining number of prestarted Vms
- The Prestarted Vm Job counts the number of Vms that:
-
- Are running (*) not by the admin
- are not assigned to a user
- If there are not enough of them, he looks for Vms that are:
- down
- not assigned to a user
-
The implementation will be as follows:
- The AttachUserToVmFromPoolAndRunCommand and AttachUserToVmFromPoolCommand will be combined to one command named AllocateVmFromPoolCommand.
- A new command called PrepareVmForUse will be added. The command will run the CreateAllSnapshotsFromVmCommand, and upon ending successfully will run RunVm. The command will be used both by the command in the previous clause, and by the scheduler that prepares prestarted vms.
- We will add a flow that checks if there are available prestarted Vms. If so, do only “AddPermission”. If no prestarted Vms were found, run AddPermission + PrepareVmForUse.
REST API
A new integer property, “prestarted_vms”, was added to the VmPool resource
Affected Commands
- AttachUserToVmFromPoolCommandAndRun + AttachUserToVmFromPoolCommandAndRun - As explained above.
- AddVmPoolCommand - no change since the parameter held is of type vm_pools.
- UpdateVmPoolCommand - no change since the parameter held is of type vm_pools.
- RemoveVmPoolCommand - no change since the parameter held is of type vm_pools.
Open Issues
-
- We need to define what the scheduler counts to be as a prestarted vm (only up, maybe VM.isStatusQualifyToMigrate() which includes Up, PoweringUp, Paused, RebootInProgress)
- We need to decide whether we take the periodic approach (with or without optimization), or the event driven one.
Dependencies / Related Features
Affected rhevm projects:
- API
- CLI
- backend
- Webadmin
- User Portal