config

package
v0.9.237-pre.2 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2025 License: AGPL-3.0 Imports: 7 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DIR_NAME   = ".cedana"
	FILE_NAME  = "config"
	FILE_TYPE  = "json"
	DIR_PERM   = 0o755
	FILE_PERM  = 0o644
	ENV_PREFIX = "CEDANA"

	// NOTE: `localhost` server inside kubernetes may or may not work
	// based on firewall and network configuration, it would only work
	// on local system, hence for serving on TCP default is 0.0.0.0
	DEFAULT_TCP_ADDR   = "0.0.0.0:8080"
	DEFAULT_SOCK_ADDR  = "/run/cedana.sock"
	DEFAULT_SOCK_PERMS = 0o666

	DEFAULT_PROTOCOL  = "unix"
	DEFAULT_LOG_LEVEL = "info"

	DEFAULT_COMPRESSION = "tar"
	DEFAULT_DUMP_DIR    = "/tmp"

	DEFAULT_PLUGINS_LIB_DIR = "/usr/local/lib"
	DEFAULT_PLUGINS_BIN_DIR = "/usr/local/bin"
)

Variables

This section is empty.

Functions

func Init

func Init(args InitArgs) error

Types

type CLI

type CLI struct {
	// Wait for ready sets CLI commands to block if the daemon is not up yet
	WaitForReady bool `json:"wait_for_ready" mapstructure:"wait_for_ready" yaml:"wait_for_ready"`
}

type CRIU

type CRIU struct {
	// BinaryPath is a custom path to the CRIU binary
	BinaryPath string `json:"binary_path"   mapstructure:"binary_path" yaml:"binary_path"`
	// LeaveRunning sets whether to leave the process running after checkpoint
	LeaveRunning bool `json:"leave_running" mapstructure:"leave_running" yaml:"leave_running"`
}

type Checkpoint

type Checkpoint struct {
	// Dir is the default directory to store checkpoints
	Dir string `json:"dir"         mapstructure:"dir" yaml:"dir"`
	// Compression is the default compression algorithm to use for checkpoints
	Compression string `json:"compression" mapstructure:"compression" yaml:"compression"`
}

type Config

type Config struct {
	// Address to use for incoming/outgoing connections
	Address string `json:"address" mapstructure:"address" yaml:"address"`
	// Protocol to use for incoming/outgoing connections (TCP, UNIX, VSOCK)
	Protocol string `json:"protocol" mapstructure:"protocol" yaml:"protocol"`
	// LogLevel is the default log level used by the server
	LogLevel string `json:"log_level" mapstructure:"log_level" yaml:"log_level"`

	// Connection settings
	Connection Connection `json:"connection" mapstructure:"connection" yaml:"connection"`
	// Checkpoint and storage settings
	Checkpoint Checkpoint `json:"checkpoint" mapstructure:"checkpoint" yaml:"checkpoint"`
	// Database details
	DB DB `json:"db"         mapstructure:"db" yaml:"db"`
	// Profiling settings
	Profiling Profiling `json:"profiling" mapstructure:"profiling" yaml:"profiling"`
	// Metrics settings
	Metrics Metrics `json:"metrics" mapstructure:"metrics" yaml:"metrics"`
	// CRIU settings and defaults
	CRIU CRIU `json:"criu" mapstructure:"criu" yaml:"criu"`
	// CLI settings
	CLI CLI `json:"cli" mapstructure:"cli" yaml:"cli"`
	// Plugin settings
	Plugins Plugins `json:"plugins" mapstructure:"plugins" yaml:"plugins"`
}

Cedana configuration. Each of the below fields can also be set through an environment variable with the same name, prefixed, and in uppercase. E.g. `Metrics.ASR` can be set with `CEDANA_METRICS_ASR`. The `env_aliases` tag below specifies alternative (alias) environment variable names (comma-separated).

var Global Config = Config{

	Protocol: DEFAULT_PROTOCOL,
	LogLevel: DEFAULT_LOG_LEVEL,
	Checkpoint: Checkpoint{
		Dir:         DEFAULT_DUMP_DIR,
		Compression: DEFAULT_COMPRESSION,
	},
	DB: DB{
		Remote: false,
		Path:   filepath.Join(os.TempDir(), "cedana.db"),
	},
	Profiling: Profiling{
		Enabled:   true,
		Precision: "auto",
	},
	Metrics: Metrics{
		ASR:  false,
		Otel: false,
	},
	CLI: CLI{
		WaitForReady: false,
	},
	CRIU: CRIU{
		LeaveRunning: false,
	},
	Plugins: Plugins{
		LibDir: DEFAULT_PLUGINS_LIB_DIR,
		BinDir: DEFAULT_PLUGINS_BIN_DIR,
		GPU: GPU{
			PoolSize: 0,
		},
	},
}

The default global config. This will get overwritten by the config file or env vars during startup, if they exist.

type Connection

type Connection struct {
	// URL is your unique Cedana endpoint URL
	URL string `json:"url"    mapstructure:"url" yaml:"url" env_aliases:"CEDANA_URL"`
	// AuthToken is your authentication token for the Cedana endpoint
	AuthToken string `json:"auth_token" mapstructure:"auth_token" yaml:"auth_token" env_aliases:"CEDANA_AUTH_TOKEN"`
}

type DB

type DB struct {
	// Remote sets whether to use a remote database
	Remote bool `json:"remote"      mapstructure:"remote"  yaml:"remote" env_aliases:"CEDANA_REMOTE"`
	// Path is the local path to the database file. E.g. /tmp/cedana.db
	Path string `json:"path" mapstructure:"path" yaml:"path"`
}

type GPU

type GPU struct {
	// Number of warm GPU controllers to keep in pool
	PoolSize int `json:"pool_size" mapstructure:"pool_size" yaml:"pool_size"`
	// LogDir is the directory to write GPU logs to. By default, logs are written to daemon's stdout
	LogDir string `json:"log_dir" mapstructure:"log_dir" yaml:"log_dir"`
}

type InitArgs

type InitArgs struct {
	Config    string
	ConfigDir string
}

type Metrics

type Metrics struct {
	// ASR sets whether to enable ASR metrics
	ASR bool `json:"asr"  mapstructure:"asr" yaml:"asr"`
	// Otel sets whether to enable OpenTelemetry metrics
	Otel bool `json:"otel" mapstructure:"otel" yaml:"otel" env_aliases:"CEDANA_OTEL_ENABLED"`
}

type Plugins

type Plugins struct {
	// BinDir is the directory where plugin binaries are stored
	BinDir string `json:"bin_dir" mapstructure:"bin_dir" yaml:"bin_dir"`
	// LibDir is the directory where plugin libraries are stored
	LibDir string `json:"lib_dir" mapstructure:"lib_dir" yaml:"lib_dir" env_aliases:"CEDANA_PLUGINS_LIB_DIR"`
	// GPU is settings for the GPU plugin
	GPU GPU `json:"gpu"        mapstructure:"gpu" yaml:"gpu"`
}

type Profiling

type Profiling struct {
	// Enabled sets whether to enable and show profiling information
	Enabled bool `json:"enabled" mapstructure:"enabled" yaml:"enabled"`
	// Precision sets the time precision when printing profiling information (auto, ns, us, ms, s)
	Precision string `json:"precision" mapstructure:"precision" yaml:"precision"`
}

Jump to

Keyboard shortcuts

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