Documentation ¶
Overview ¶
Package vms defines logic for managing a pool of virtual machines.
Index ¶
- type Config
- type Pool
- func (p *Pool) DeleteVM(vm *compute.Instance) error
- func (p *Pool) Fill(ctx context.Context) ([]*compute.Instance, error)
- func (p *Pool) FreeVMs() ([]*compute.Instance, error)
- func (p *Pool) KillOldVMs(idleBackends []string) error
- func (p *Pool) TooOldVMs(vms []*compute.Instance, idleBackends []string) ([]*compute.Instance, error)
- func (pool *Pool) WaitForVM(ctx context.Context, userEmail string) (*compute.Instance, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { InstanceName string ServiceAccountName string ProxyURL string ApplicationImage string BackendID string ProxiedHostname string }
A Config holds the creation-time parameters for a per-user VM.
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
A Pool is a collection of unallocated virtual machines.
func NewPool ¶
func NewPool(ctx context.Context, computeService *compute.Service, iamService *iam.Service, proxyAdmin *proxy.Admin, proxyURL, proxiedHostname, project, zone, network, machineType, applicationImage string) (*Pool, error)
NewPool creates a new VM pool in the given project/zone combination.
The `applicationImage` value specifies the full path of a Docker image that will run on the VM once the user's disk has been attached to it.
The user's disk will be volume mounted into the Docker container at `/content`.
func (*Pool) KillOldVMs ¶
func (*Pool) TooOldVMs ¶
func (p *Pool) TooOldVMs(vms []*compute.Instance, idleBackends []string) ([]*compute.Instance, error)
TooOldVMs computes the list of all VMs that are too old under three criteria:
- Having sat idle for too long (i.e. wasting money).
- Having been assigned to a user for too long (as a form of abuse prevention).
- Being unassigned and created too long ago (i.e. potentially running an out-of-date image).
Click to show internal directories.
Click to hide internal directories.