Documentation
¶
Overview ¶
Package kernel manages guest kernels: their definitions, and their binaries on the host. A kernel is the default one this binary carries or one a client imports, checked against its SHA-256.
Index ¶
- Constants
- func Extract(dstPath string, version Version) (string, error)
- func MetricDescriptions() []metric.Description
- type Config
- type Kernel
- type Manager
- func (m *Manager) Collect(ch chan<- prometheus.Metric)
- func (m *Manager) Delete(nameOrID string) error
- func (m *Manager) Describe(ch chan<- *prometheus.Desc)
- func (m *Manager) DiskBytes(k Kernel) int64
- func (m *Manager) EnsureDefault() error
- func (m *Manager) Import(name, architecture, sha256 string, r io.Reader) (Kernel, error)
- func (m *Manager) Kernel(nameOrID string) (Kernel, error)
- func (m *Manager) Kernels() []Kernel
- func (m *Manager) Path(k Kernel) (string, error)
- type Recorder
- type Store
- type Version
Constants ¶
const ( ArchitectureX86_64 = "x86_64" ArchitectureAArch64 = "aarch64" )
The CPU architectures a kernel may be built for, as uname -m names them.
const DefaultName = "default"
DefaultName is the name of the default kernel, which the daemon defines itself and an instance boots when it names no kernel.
const MaxImportBytes = 512 << 20
MaxImportBytes is the largest kernel a client can import.
Variables ¶
This section is empty.
Functions ¶
func Extract ¶ added in v0.4.0
Extract writes the default kernel of version, decompressed, to dstPath, unless a file is already there, and returns dstPath. The kernel is written beside dstPath and renamed into place, so dstPath is never a partial kernel.
func MetricDescriptions ¶ added in v0.4.0
func MetricDescriptions() []metric.Description
MetricDescriptions returns the descriptions of every metric the kernel manager serves, for the reference.
Types ¶
type Config ¶
type Config struct {
// DataDir holds the kernels, under kernels/<id>; it is required.
DataDir string
// Store keeps the kernel definitions. It is required.
Store Store
// Events records what happens to kernels. Nil records nothing.
Events Recorder
// Logger defaults to slog.Default.
Logger *slog.Logger
}
Config configures a Manager.
type Kernel ¶ added in v0.4.0
type Kernel struct {
ID string `yaml:"id"`
Name string `yaml:"name"`
Architecture string `yaml:"arch"`
SHA256 string `yaml:"sha256"`
CreatedAt time.Time `yaml:"created_at"`
UpdatedAt time.Time `yaml:"updated_at"`
}
Kernel is a guest kernel image an instance can boot from, kept on the host.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager imports and deletes kernels: their definitions, kept in a Store, and their binaries on the host. It is safe for concurrent use.
func NewManager ¶
NewManager returns a Manager for the kernels under cfg.DataDir.
func (*Manager) Collect ¶ added in v0.4.0
func (m *Manager) Collect(ch chan<- prometheus.Metric)
Collect implements prometheus.Collector: the kernels defined, and what they take on disk, as they are now.
func (*Manager) Delete ¶
Delete removes a kernel's definition and its binary, refusing the default kernel and one an instance or snapshot boots.
func (*Manager) Describe ¶ added in v0.4.0
func (m *Manager) Describe(ch chan<- *prometheus.Desc)
Describe implements prometheus.Collector.
func (*Manager) DiskBytes ¶ added in v0.4.0
DiskBytes returns the size of a kernel's binary on local disk, or 0 if it is not there.
func (*Manager) EnsureDefault ¶ added in v0.4.0
EnsureDefault puts the default kernel this binary carries on the host, and defines it once it is there. It extracts it again if its copy on the host is missing or damaged, and in place of the one an older version of Dicer carried.
func (*Manager) Import ¶ added in v0.4.0
Import keeps the kernel a client sends, read from r, and defines it. It refuses an invalid kernel, the default kernel's name and a name already taken, and checks the kernel against sha256 if that is set. The SHA-256 is kept whether or not it is set, so that the kernel is checked each time an instance boots it. Nothing is kept if it fails.
type Recorder ¶ added in v0.4.0
Recorder records what happens to kernels. It is declared here, and satisfied by internal/event, so that this package reports what it does without knowing who listens.
type Store ¶ added in v0.4.0
type Store interface {
CreateKernel(k Kernel) error
Kernel(nameOrID string) (Kernel, error)
Kernels() []Kernel
UpdateKernel(k Kernel) error
// DeleteKernel refuses a kernel an instance or snapshot boots.
DeleteKernel(nameOrID string) error
}
Store keeps the kernel definitions.
type Version ¶ added in v0.4.0
type Version string
Version identifies a release of Dicer's kernel, https://github.com/konradasb/dicer-kernel.
const DefaultVersion Version = "v6.18.53-1"
DefaultVersion is the release of Dicer's kernel this version of Dicer carries as the default kernel. A new release of Dicer may carry a newer one.