instance

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package instance records the host-instance ServerConfiguration values (containerd namespace suffix and cgroup root) that a given runPath was bootstrapped under, so the daemon can refuse to start when reconfigured to a different layout. Migration between layouts is out of scope — the operator destroys the runPath and re-runs `kuke init` against the new config.

Index

Constants

View Source
const MetadataFile = ".kukeon-instance.json"

MetadataFile is the basename of the instance-metadata file written under runPath. The dot prefix keeps it visually distinct from realm directories (which never start with a dot) so a directory listing of /opt/kukeon makes the instance file obvious.

Variables

This section is empty.

Functions

func Path

func Path(runPath string) string

Path returns the absolute path of the instance metadata file under the given runPath.

func VerifyOrWrite

func VerifyOrWrite(runPath, suffix, cgroupRoot string) error

VerifyOrWrite enforces the runPath / configuration consistency contract: if a prior instance metadata exists under runPath and disagrees with the supplied (suffix, cgroupRoot), return an ErrInstanceMismatch-wrapped error so the caller can refuse to start. If absent, write the supplied values so the next start can verify against them. If present and matching, do nothing.

suffix is the operator-facing form without a leading dot. cgroupRoot is the absolute cgroup path. Both inputs are canonicalized here (TrimSpace on both, plus TrimRight slash on cgroupRoot, mirroring consts.ConfigureRuntime) so callers can pass raw viper / flag values without tripping a spurious mismatch when one start uses "/kukeon-dev/" and the next uses "/kukeon-dev". Validation of well-formedness lives in consts.ConfigureRuntime, which call sites invoke before this.

func Write

func Write(runPath string, m Metadata) error

Write atomically writes the instance metadata to runPath. Creates the runPath directory if missing. Idempotent: re-writing the same content is a no-op visible to the operator only as a fresh mtime.

Types

type Metadata

type Metadata struct {
	ContainerdNamespaceSuffix string `json:"containerdNamespaceSuffix"`
	CgroupRoot                string `json:"cgroupRoot"`
}

Metadata is the on-disk shape of the instance file. The suffix is stored in operator-facing form (no leading dot, e.g. "kukeon.io"); the cgroup root is stored as written by the operator with trailing slashes trimmed.

func Load

func Load(runPath string) (Metadata, bool, error)

Load reads and parses the instance metadata at runPath. Returns (zero, false, nil) if the file does not exist; (md, true, nil) when the file is present and parses; any other read or parse failure is wrapped with errdefs.ErrServerConfigurationInvalid.

Jump to

Keyboard shortcuts

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