server

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2025 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractPoolNameFromVMID added in v0.4.0

func ExtractPoolNameFromVMID(vmid string) (string, error)

ExtractPoolNameFromVMID parses a VMID to get the associated Pool name. VMIDs (runnerName) are formatted as "pool-suffix", so this avoids scanning all Pools.

Types

type Config

type Config struct {
	BindAddress      string            `yaml:"bind_address" validate:"required,hostname_port"`
	Metrics          *MetricsConfig    `yaml:"metrics"`
	BasicAuthEnabled bool              `yaml:"basic_auth_enabled" validate:""`
	BasicAuthUsers   map[string]string `yaml:"basic_auth_users" validate:"required_if=basic_auth_enabled true"`
	GitHub           *GitHubConfig     `yaml:"github" validate:"required"`
	Pools            []*PoolConfig     `yaml:"pools" validate:"required,min=1"`
	LogLevel         string            `yaml:"log_level" validate:"required,oneof=debug info warn error fatal panic trace"`
	Debug            bool              `yaml:"debug" validate:""`
	// contains filtered or unexported fields
}

Config is the configuration for the Client.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig creates a new Config with default values.

func NewConfig

func NewConfig(path string) (*Config, error)

NewConfigFromFile creates a new Config from a file.

func (*Config) Load

func (c *Config) Load() error

LoadFromFile loads the configuration from a file.

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the configuration.

type FirecrackerConfig

type FirecrackerConfig struct {
	BinaryPath      string                   `yaml:"binary_path" `
	KernelImagePath string                   `yaml:"kernel_image_path"`
	KernelArgs      string                   `yaml:"kernel_args"`
	MachineConfig   FirecrackerMachineConfig `yaml:"machine_config"`
	Metadata        map[string]interface{}   `yaml:"metadata"`
}

type FirecrackerMachineConfig

type FirecrackerMachineConfig struct {
	VcpuCount  int64 `yaml:"vcpu_count"`
	MemSizeMib int64 `yaml:"mem_size_mib"`
}

type GitHubConfig

type GitHubConfig struct {
	AppPrivateKey string `yaml:"app_private_key" validate:"required"`
	AppID         int64  `yaml:"app_id" validate:"required"`
}

type MetricsConfig

type MetricsConfig struct {
	Enabled bool   `yaml:"enabled" validate:""`
	Address string `yaml:"address" validate:"required_if=enabled true,hostname_port"`
}

type MicroVM added in v0.3.0

type MicroVM struct {
	VMID   string
	IPAddr string
}

type MicroVMManager added in v0.3.0

type MicroVMManager interface {
	ListMicroVMs(ctx context.Context, pool string) ([]*MicroVM, error)
	GetMicroVM(ctx context.Context, vmid string) (*MicroVM, error)
}

MicroVMManager is an interface for managing MicroVMs.

type Opt

type Opt func(s *Server)

Opt is a functional option for Server.

func WithLogger

func WithLogger(logger *zerolog.Logger) Opt

WithLogger sets the logger for the Server.

type Pool

type Pool struct {
	// contains filtered or unexported fields
}

Pool represents a pool of Firecracker VMs that are used to run GitHub Actions jobs.

func NewPool

func NewPool(logger *zerolog.Logger, config *PoolConfig, github *github.Client) (*Pool, error)

NewPool creates a new Pool.

func (*Pool) GetCurrentSize

func (p *Pool) GetCurrentSize() int

GetCurrentSize returns the current size of the pool.

func (*Pool) GetDir

func (p *Pool) GetDir() string

GetDir returns the directory where the pool sockets and logs are stored.

func (*Pool) ListMicroVMs added in v0.3.0

func (p *Pool) ListMicroVMs(ctx context.Context, pool string) ([]*MicroVM, error)

ListMicroVMs retrieves the names and IP addresses of all running Firecracker VMs inside the pool.

func (*Pool) Pause

func (p *Pool) Pause()

Pause pauses the pool. Pausing the pool will prevent the pool from scaling.

func (*Pool) Resume

func (p *Pool) Resume()

Resume resumes the pool. Resuming the pool will allow the pool to scale.

func (*Pool) Scale

func (p *Pool) Scale(ctx context.Context, replicas int) error

Scale scales the pool to the desired size.

func (*Pool) Start

func (p *Pool) Start()

Start starts the pool. Starting the pool will start the scaling process.

func (*Pool) Stop

func (p *Pool) Stop()

Stop stops the pool. Stopping the pool will stop all the VMs in the pool.

type PoolConfig

type PoolConfig struct {
	Name        string             `yaml:"name" validate:"required"`
	MaxRunners  int                `yaml:"max_runners" validate:"min=1"`
	MinRunners  int                `yaml:"min_runners" validate:"min=1"`
	Runner      *RunnerConfig      `yaml:"runner" validate:"required"`
	Firecracker *FirecrackerConfig `yaml:"firecracker" validate:"required"`
}

PoolConfig represents the configuration of a Pool.

type PoolManager

type PoolManager interface {
	ListPools(ctx context.Context) ([]*Pool, error)
	GetPool(ctx context.Context, id string) (*Pool, error)
	ScalePool(ctx context.Context, id string, delta int) error
	PausePool(ctx context.Context, id string) error
	ResumePool(ctx context.Context, id string) error
	Reload(ctx context.Context) error
}

PoolManager is an interface for managing pools.

type RunnerConfig

type RunnerConfig struct {
	Name            string   `yaml:"name" validate:"required"`
	ImagePullPolicy string   `yaml:"image_pull_policy" validate:"required,oneof=always never ifnotpresent"`
	Image           string   `yaml:"image" validate:"required"`
	Organization    string   `yaml:"organization" validate:"required"`
	GroupID         int64    `yaml:"group_id" validate:"required"`
	Labels          []string `yaml:"labels" validate:"required"`
}

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server represents the Fireactions server.

func New

func New(config *Config, opts ...Opt) (*Server, error)

New creates a new Server.

func (*Server) GetMicroVM added in v0.4.0

func (s *Server) GetMicroVM(ctx context.Context, vmid string) (*MicroVM, error)

GetMicroVM returns a MicroVM object by the given VM ID.

func (*Server) GetPool

func (s *Server) GetPool(ctx context.Context, id string) (*Pool, error)

GetPool returns the pool with the given ID.

func (*Server) ListMicroVMs added in v0.3.0

func (s *Server) ListMicroVMs(ctx context.Context, poolName string) ([]*MicroVM, error)

ListMicroVMs returns a list of MicroVMs for the given poolName.

func (*Server) ListPools

func (s *Server) ListPools(ctx context.Context) ([]*Pool, error)

ListPools returns a list of all pools.

func (*Server) PausePool

func (s *Server) PausePool(ctx context.Context, id string) error

PausePool pauses the pool with the given ID.

func (*Server) Reload added in v0.2.4

func (s *Server) Reload(ctx context.Context) error

func (*Server) ResumePool

func (s *Server) ResumePool(ctx context.Context, id string) error

ResumePool resumes the pool with the given ID.

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

Run starts the server and blocks until the context is canceled.

func (*Server) ScalePool

func (s *Server) ScalePool(ctx context.Context, id string, replicas int) error

ScalePool scales the pool with the given ID to the desired size.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL