Documentation ¶
Overview ¶
Proxmox Virtual Environment Provisioner
Index ¶
- Constants
- Variables
- type Node
- type PveInfraConfig
- type PveProvisioner
- func (p *PveProvisioner) Config() models.InfraConfig
- func (p *PveProvisioner) Create() error
- func (p *PveProvisioner) Delete() error
- func (p *PveProvisioner) Reserve() error
- func (p *PveProvisioner) ScriptExecutor(scriptType models.ScriptType) models.ScriptExecutor
- func (p *PveProvisioner) ScriptSets() []*models.ScriptSet
- func (p *PveProvisioner) Spec() models.Spec
- type PveSpec
- type PveVM
- type ScheduleTx
- type Scheduler
- func (s *Scheduler) Cancel(id NodeID, spec VMSpec)
- func (s *Scheduler) Free(id NodeID, spec VMSpec)
- func (s *Scheduler) Schedule(spec VMSpec) (NodeID, error)
- func (s *Scheduler) Transaction(fn func(tx *ScheduleTx) error) error
- func (s *Scheduler) UpdateNodes(fn func() ([]*Node, error), updateReserved bool) error
- func (s *Scheduler) Use(id NodeID, spec VMSpec)
- type VMConfig
- type VMSpec
Constants ¶
const CloneTimeout = 5 * time.Minute
const DEFAULT_CPU_OVER_COMMITMENT_RATIO = 4
const DEFAULT_SYSTEM_MEM = 4096
4096MiB = 4GiB
const DeleteTimeout = 5 * time.Minute
const PveSpecType models.SpecType = "proxmox-ve"
const ScheduleTimeout = 5 * time.Minute
const StartTimeout = 5 * time.Minute
Variables ¶
var FullError = errors.Errorf("full")
FullError means failed to allocate resources.
var GlobalScheduler = &Scheduler{}
TODO: 複数のクラスタに対応できない
var PveCloneSem = semaphore.NewWeighted(1)
TODO 複数のprovisionerが同時にcloneをすると、IDが衝突してしまう。 これを回避するため、同時にclone操作をするのを制限した。
var PveUpdateSchedulerOnce sync.Once
TODO タスクが動いている最中、特にReserve()とCreate()の間にschedulerStatusが実行されてしまうと、 確保済み扱いのCPUやメモリがカウントされない。このため、リソース開放時にpanicする。 これを回避するために Scheduler.UpdateNodes() の実行は1回限りに制限する。
Functions ¶
This section is empty.
Types ¶
type Node ¶
type Node struct { NodeID NodeID // Number of physical CPUs. PCPU int // Information of virtual CPUs. VCPU struct { // Maximum number of virtual CPUs. // If you need disable the maximum limit of virtual CPUs, set Max=0. Max int // Number of used virtual CPUs by running VMs. Used int // Number of virtual CPUs by VMs in preparing. Reserved int } // Amount of physical memory size (MiB). PMem int // Information of virtual memory. VMem struct { // Amount of memory size (MiB) for system. // This memory is used by Proxmox VE system and margin for prevent out-of-memory. // Default: DEFAULT_SYSTEM_MEM System int // Amount of used memory size (MiB) by already running VMs. // This value is the total of memory size each running VMs. Used int // Amount of reserved memory size (MiB). // This value is the total of memory size each VMs in preparing. Reserved int } }
type PveInfraConfig ¶
type PveInfraConfig struct { PveSpec *PveSpec VMs map[string][]VMConfig // contains filtered or unexported fields }
func NewPveInfraConfig ¶
func NewPveInfraConfig(spec *PveSpec) *PveInfraConfig
func (*PveInfraConfig) AddVM ¶
func (c *PveInfraConfig) AddVM(name string, vm VMConfig)
func (*PveInfraConfig) Spec ¶
func (c *PveInfraConfig) Spec() models.Spec
func (*PveInfraConfig) String ¶
func (c *PveInfraConfig) String() string
type PveProvisioner ¶
type PveProvisioner struct {
// contains filtered or unexported fields
}
func (*PveProvisioner) Config ¶
func (p *PveProvisioner) Config() models.InfraConfig
func (*PveProvisioner) Create ¶
func (p *PveProvisioner) Create() error
Create starts all VMs of defined by PveSpec.
func (*PveProvisioner) Delete ¶
func (p *PveProvisioner) Delete() error
Delete deletes all resources of defined by PveSpec.
func (*PveProvisioner) Reserve ¶ added in v0.2.0
func (p *PveProvisioner) Reserve() error
Reserve() reserves all resources (CPU, memory, storage, etc) of defined by PveSpec.
func (*PveProvisioner) ScriptExecutor ¶
func (p *PveProvisioner) ScriptExecutor(scriptType models.ScriptType) models.ScriptExecutor
func (*PveProvisioner) ScriptSets ¶
func (p *PveProvisioner) ScriptSets() []*models.ScriptSet
func (*PveProvisioner) Spec ¶
func (p *PveProvisioner) Spec() models.Spec
type PveSpec ¶
type PveSpec struct { // Identifier of the spec. Name string // Proxmox VE account settings.. Proxmox struct { // URL of the Proxmox VE API server. // Example: https://pve.local:8006 Address string // Login information. Account struct { User string Password string } // Fingerprint of the Proxmox VE API server. // If you need the server certificate pinning to make it more secure. Fingerprint string } // Addresses to assign to VMs. AddressPools []*struct { StartAddress string `yaml:"start_address"` EndAddress string `yaml:"end_address"` CIDR int Gateway string } `yaml:"address_pools"` // User information. // This user will create by cloud-init at VM start-up. User struct { User string // todo: password is not used. Password string SSHPublicKey string `yaml:"ssh_public_key"` } VMs map[string]*PveVM }
func (*PveSpec) LoadDefault ¶ added in v0.3.0
func (*PveSpec) ValidateDefault ¶ added in v0.3.0
type PveVM ¶
type PveVM struct { // Template name. Template string // Pool name to which the VM belongs. Pool string // Number of VMs. Nodes int // Number of processors. Processors int // RAM size (MiB). MemorySize int `yaml:"memory_size"` // Minimal storage size (GiB). // The storage may be large than specified size. StorageSize int `yaml:"storage_size"` // Define tasks to execute on VMs. Scripts *config.ScriptConfigSet }
type ScheduleTx ¶
type ScheduleTx struct { S *Scheduler // contains filtered or unexported fields }
func (*ScheduleTx) Commit ¶
func (tx *ScheduleTx) Commit()
Commit allocates all reserved resources while this transaction.
func (*ScheduleTx) IsFinished ¶
func (tx *ScheduleTx) IsFinished() bool
IsFinished returns true if already committed or reverted. Otherwise, it returns false.
func (*ScheduleTx) Revert ¶
func (tx *ScheduleTx) Revert()
Revert releases all reserved resources while this transaction.
func (*ScheduleTx) Schedule ¶
func (tx *ScheduleTx) Schedule(spec VMSpec) (NodeID, error)
Schedule decides best VM location and reserves it. The reserved resources are allocated or released when calling the Commit() or Revert().
func (*ScheduleTx) ScheduleWait ¶ added in v0.2.0
func (tx *ScheduleTx) ScheduleWait(ctx context.Context, spec VMSpec) (NodeID, error)
ScheduleWait waits for allocate resources and reserves it.
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
func (*Scheduler) Cancel ¶
Cancel releases reserved resources. You should call it when you need drops the reserved resources by Schedule().
func (*Scheduler) Schedule ¶
Schedule decides best VM location and reserves it. You should call the Use() or Cancel() after call it.
func (*Scheduler) Transaction ¶
func (s *Scheduler) Transaction(fn func(tx *ScheduleTx) error) error
Transaction starts an transaction to allocate resources atomically.
func (*Scheduler) UpdateNodes ¶
UpdateNodes updates all nodes status. If updateReserved is true, Scheduler.nodes.VCPU.Reserved and Scheduler.nodes.VMem.Reserved parameters are updated.