Documentation
¶
Index ¶
- Variables
- func GenerateRandomBytes(n int) ([]byte, error)
- func GenerateRandomStringURLSafe(n int) (string, error)
- func GenerateRandomStringVMNameSafe(size int) (string, error)
- type DebugServer
- type Instance
- type InstanceGroup
- func (g *InstanceGroup) ConnectInfo(ctx context.Context, id string) (provider.ConnectInfo, error)
- func (g *InstanceGroup) Decrease(ctx context.Context, instancesToDelete []string) ([]string, error)
- func (g *InstanceGroup) Heartbeat(ctx context.Context, id string) error
- func (g *InstanceGroup) Increase(ctx context.Context, delta int) (int, error)
- func (g *InstanceGroup) Init(ctx context.Context, logger hclog.Logger, settings provider.Settings) (provider.ProviderInfo, error)
- func (g *InstanceGroup) Shutdown(ctx context.Context) error
- func (g *InstanceGroup) Update(ctx context.Context, update func(instance string, state provider.State)) error
- type Phase
- type PrivPub
- type ReconcilerConfig
- type VCDInstanceGroup
Constants ¶
This section is empty.
Variables ¶
var ( // Instance Lifecycle Metrics InstancesCreatedTotal = promauto.NewCounterVec(prometheus.CounterOpts{ Name: "fleeting_vcd_instances_created_total", Help: "Total number of instances created", }, []string{instanceGroupLabel}) InstancesDeletedTotal = promauto.NewCounterVec(prometheus.CounterOpts{ Name: "fleeting_vcd_instances_deleted_total", Help: "Total number of instances deleted", }, []string{instanceGroupLabel}) InstancesFailedTotal = promauto.NewCounterVec(prometheus.CounterOpts{ Name: "fleeting_vcd_instances_failed_total", Help: "Total number of failed instance operations", }, []string{instanceGroupLabel, "operation"}) InstancesCurrentByState = promauto.NewGaugeVec(prometheus.GaugeOpts{ Name: "fleeting_vcd_instances_current", Help: "Current number of instances by state", }, []string{instanceGroupLabel, "state"}) InstanceCreationDuration = promauto.NewHistogramVec(prometheus.HistogramOpts{ Name: "fleeting_vcd_instance_creation_duration_seconds", Help: "Time taken to create an instance", Buckets: []float64{30, 60, 90, 120, 180, 300, 600, 900, 1200}, }, []string{instanceGroupLabel}) InstanceDeletionDuration = promauto.NewHistogramVec(prometheus.HistogramOpts{ Name: "fleeting_vcd_instance_deletion_duration_seconds", Help: "Time taken to delete an instance", Buckets: []float64{10, 30, 60, 120, 300, 600, 1200, 1800, 3600}, }, []string{instanceGroupLabel}) // Garbage Collection Metrics GCRunsTotal = promauto.NewCounterVec(prometheus.CounterOpts{ Name: "fleeting_vcd_gc_runs_total", Help: "Total number of garbage collection runs", }, []string{instanceGroupLabel}) GCInstancesCollectedTotal = promauto.NewCounterVec(prometheus.CounterOpts{ Name: "fleeting_vcd_gc_instances_collected_total", Help: "Total number of instances cleaned up by garbage collection", }, []string{instanceGroupLabel}) GCDuration = promauto.NewHistogramVec(prometheus.HistogramOpts{ Name: "fleeting_vcd_gc_duration_seconds", Help: "Time taken to run garbage collection", Buckets: []float64{1, 5, 10, 30, 60, 120, 300}, }, []string{instanceGroupLabel}) // VCD API Metrics APICallsTotal = promauto.NewCounterVec(prometheus.CounterOpts{ Name: "fleeting_vcd_api_calls_total", Help: "Total number of VCD API calls", }, []string{instanceGroupLabel, "operation"}) APIErrorsTotal = promauto.NewCounterVec(prometheus.CounterOpts{ Name: "fleeting_vcd_api_errors_total", Help: "Total number of VCD API errors", }, []string{instanceGroupLabel, "operation"}) APIDuration = promauto.NewHistogramVec(prometheus.HistogramOpts{ Name: "fleeting_vcd_api_duration_seconds", Help: "Time taken for VCD API calls", Buckets: []float64{0.1, 0.5, 1, 2, 5, 10, 30, 60}, }, []string{instanceGroupLabel, "operation"}) // Pool Status Metrics PoolSize = promauto.NewGaugeVec(prometheus.GaugeOpts{ Name: "fleeting_vcd_pool_size", Help: "Current pool size", }, []string{instanceGroupLabel}) PoolMaxSize = promauto.NewGaugeVec(prometheus.GaugeOpts{ Name: "fleeting_vcd_pool_max_size", Help: "Configured maximum pool size", }, []string{instanceGroupLabel}) // State Manager Metrics (now backed by desiredStateStore) StateManagerInstancesTotal = promauto.NewGaugeVec(prometheus.GaugeOpts{ Name: "fleeting_vcd_state_manager_instances_total", Help: "Total instances tracked in state store", }, []string{instanceGroupLabel}) StateManagerInstancesByState = promauto.NewGaugeVec(prometheus.GaugeOpts{ Name: "fleeting_vcd_state_manager_instances_by_state", Help: "Instances by fleeting state in state store", }, []string{instanceGroupLabel, "state"}) // Reconciler Metrics ReconcileDuration = promauto.NewHistogramVec(prometheus.HistogramOpts{ Name: "fleeting_vcd_reconcile_duration_seconds", Help: "Time taken for a single reconciliation cycle", Buckets: []float64{0.1, 0.5, 1, 2, 5, 10, 30, 60, 120}, }, []string{instanceGroupLabel}) ReconcileTotal = promauto.NewCounterVec(prometheus.CounterOpts{ Name: "fleeting_vcd_reconcile_total", Help: "Total number of reconciliation cycles", }, []string{instanceGroupLabel}) )
var ( NAME = "fleeting-plugin-vcd" VERSION = "dev" REVISION = "HEAD" REFERENCE = "HEAD" BUILT = "now" Version plugin.VersionInfo )
Functions ¶
func GenerateRandomBytes ¶
GenerateRandomBytes returns securely generated random bytes. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
func GenerateRandomStringURLSafe ¶
GenerateRandomStringURLSafe returns a URL-safe, base64 encoded securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
func GenerateRandomStringVMNameSafe ¶
GenerateRandomStringVMNameSafe returns a string that can be used as a VM name. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
Types ¶
type DebugServer ¶ added in v0.0.3
type DebugServer struct {
// contains filtered or unexported fields
}
func NewDebugServer ¶ added in v0.0.3
func NewDebugServer(log hclog.Logger, store *desiredStateStore, instanceGroupName string) *DebugServer
func (*DebugServer) ServeHTTP ¶ added in v0.0.3
func (ds *DebugServer) ServeHTTP(w http.ResponseWriter, r *http.Request)
type Instance ¶ added in v0.1.0
type Instance struct {
ID string // VApp HREF (empty until VApp created)
IntentID string // UUID, assigned at Increase time
Name string // VApp name
VMName string
Phase Phase
IPAddress string
VAppStatus string
VMStatus string
OSType string // Cached OS type from VM spec (e.g. "windows9Server64Guest")
// Timestamps
CreatedAt *time.Time
CreateStartedAt *time.Time
CreateCompletedAt *time.Time
DeleteRequestedAt *time.Time
DeleteStartedAt *time.Time
DeleteCompletedAt *time.Time
GCMarkedAt *time.Time
LastUpdated *time.Time
// Retry
RetryCount int
LastError string
NextRetryAfter *time.Time
// MissedPolls tracks how many consecutive polls this instance was not found in VCD.
// Used to avoid marking instances as disappeared due to eventual consistency.
MissedPolls int
}
Instance represents a tracked VCD instance with its full lifecycle state.
type InstanceGroup ¶
type InstanceGroup struct {
Name string `json:"name"`
// Cloud Director connection config
StrURL string `json:"url"`
Org string `json:"org"`
Token string `json:"token"`
VirtualDatacenter string `json:"virtual_datacenter"`
Network string `json:"network"`
IPAllocationMode string `json:"ip_allocation_mode"`
InstanceGroupName string `json:"instance_group_name"`
VAppNamePrefix string `json:"vapp_name_prefix"`
Catalog string `json:"catalog"`
Template string `json:"template"`
StorageProfile string `json:"storage_profile"`
CPUCount int `json:"cpu_count"`
CoresPerSocket int `json:"cores_per_socket"`
MemoryMB int64 `json:"memory_mb"`
DiskSizeGB int `json:"disk_size_gb"`
DebugServerAddr string `json:"debug_server_addr"`
MaxConcurrentCreates int `json:"max_concurrent_creates"`
MaxConcurrentDeletes int `json:"max_concurrent_deletes"`
// contains filtered or unexported fields
}
func (*InstanceGroup) ConnectInfo ¶
func (g *InstanceGroup) ConnectInfo(ctx context.Context, id string) (provider.ConnectInfo, error)
ConnectInfo implements provider.InstanceGroup
func (*InstanceGroup) Heartbeat ¶ added in v0.0.2
func (g *InstanceGroup) Heartbeat(ctx context.Context, id string) error
type ReconcilerConfig ¶ added in v0.1.0
type ReconcilerConfig struct {
MaxConcurrentCreates int
MaxConcurrentDeletes int
Interval time.Duration
MaxInstanceAge time.Duration
}
ReconcilerConfig holds configuration for the reconciliation loop.
type VCDInstanceGroup ¶ added in v0.1.0
type VCDInstanceGroup interface {
// Increase requests n new instances. Returns intent IDs.
Increase(n int) []string
// Decrease marks instances for deletion.
Decrease(instanceIDs []string)
// Instances returns all tracked instances from cache.
Instances() []Instance
// Instance returns a specific instance by VApp HREF from cache.
Instance(id string) (Instance, bool)
// Shutdown stops the reconciler, waits for in-flight ops, cleans up all instances.
Shutdown(ctx context.Context) error
}
VCDInstanceGroup manages a group of VCD instances with reconciliation.