containerapply

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: EPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LabelFingerprint is stored on the container so spec drift recreates it.
	LabelFingerprint = "iofog-container-apply"

	// CPUCFSPeriod is the CFS period (100ms) used with CPU quota.
	CPUCFSPeriod int64 = 100000
)

Variables

This section is empty.

Functions

func ApplyLabel

func ApplyLabel(ms *models.Microservice, env []string) (string, error)

ApplyLabel is the create-time apply label, including the environment digest.

func CPUQuota

func CPUQuota(cpus float64) int64

CPUQuota converts a CPU count to CFS quota with period CPUCFSPeriod.

func CatalogBind

func CatalogBind(ms *models.Microservice, diskDir string) (host, container string, readOnly bool, ok bool)

CatalogBind is the single parent catalog mount (host projection → bindPath).

func CommandArgs

func CommandArgs(ms *models.Microservice) []string

CommandArgs is the engine command list, or nil to leave the image default.

func DockerTmpfsOptions

func DockerTmpfsOptions(t models.TmpfsMount) string

DockerTmpfsOptions formats tmpfs size (MiB) and mode for HostConfig.Tmpfs.

func DockerUser

func DockerUser(runAsUser, runAsGroup *string) string

DockerUser is Config.User. Group is appended as uid:gid only when both are set and runAsUser does not already contain ':'.

func EnvHashFromLabel

func EnvHashFromLabel(label string) (string, bool)

EnvHashFromLabel returns the stored environment digest when the label has one.

func HasEnvHash

func HasEnvHash(label string) bool

HasEnvHash reports whether the apply label includes an environment digest.

func HashEnv

func HashEnv(env []string) string

HashEnv returns a stable digest of KEY=VALUE pairs. Order does not matter.

func KnowledgeCatalogBind

func KnowledgeCatalogBind(ms *models.Microservice, diskDir string) (host, container string, readOnly bool, ok bool)

KnowledgeCatalogBind is the single parent knowledge catalog mount (host projection → bindPath).

func Marshal

func Marshal(fp Fingerprint) (string, error)

Marshal encodes the fingerprint as a compact JSON label value.

func MatchesLabel

func MatchesLabel(label string, ms *models.Microservice) bool

MatchesLabel reports whether the stored fingerprint matches the microservice. A missing label matches only when the spec has no apply fields (legacy containers). An environment digest on the label is ignored here; callers compare that separately.

func NanoCPUs

func NanoCPUs(cpus float64) int64

NanoCPUs converts a CPU count to Docker NanoCPUs (1e9 per CPU).

func POSIXRlimits

func POSIXRlimits(ulimits map[string]models.Ulimit) []specs.POSIXRlimit

POSIXRlimits maps ulimit names to OCI rlimits. -1 becomes unlimited (max uint64).

func ShmHostDir

func ShmHostDir(diskDir, msUUID string) string

ShmHostDir is the host directory used for a sized CRI /dev/shm bind.

func TmpfsHostDir

func TmpfsHostDir(diskDir, msUUID, containerPath string) string

TmpfsHostDir is the host directory used for a CRI tmpfs bind.

Types

type Fingerprint

type Fingerprint struct {
	BindPath             string                   `json:"bindPath,omitempty"`
	Permissions          string                   `json:"permissions,omitempty"`
	KnowledgeBindPath    string                   `json:"knowledgeBindPath,omitempty"`
	KnowledgePermissions string                   `json:"knowledgePermissions,omitempty"`
	Entrypoint           []string                 `json:"entrypoint,omitempty"`
	Commands             []string                 `json:"commands,omitempty"`
	WorkingDir           string                   `json:"workingDir,omitempty"`
	RunAsGroup           string                   `json:"runAsGroup,omitempty"`
	ReadOnlyRoot         bool                     `json:"readOnlyRoot,omitempty"`
	Tmpfs                []models.TmpfsMount      `json:"tmpfs,omitempty"`
	ShmSize              *int64                   `json:"shmSize,omitempty"`
	Cpus                 *float64                 `json:"cpus,omitempty"`
	MemoryReservation    *int64                   `json:"memoryReservation,omitempty"`
	MemorySwap           *int64                   `json:"memorySwap,omitempty"`
	Sysctls              map[string]string        `json:"sysctls,omitempty"`
	Ulimits              map[string]models.Ulimit `json:"ulimits,omitempty"`
	Devices              []models.DeviceMapping   `json:"devices,omitempty"`
	// EnvHash is the applied environment snapshot. It is written on create so a
	// later compare can use labels instead of the OCI spec. A missing hash is
	// not a recreate reason.
	EnvHash string `json:"envHash,omitempty"`
}

Fingerprint is the recreate-relevant apply snapshot. Catalog item membership is omitted so add/remove of models or knowledge stays in-place when bindPath and permissions are unchanged.

func FromMicroservice

func FromMicroservice(ms *models.Microservice) Fingerprint

FromMicroservice builds the apply fingerprint for a microservice.

func (Fingerprint) Empty

func (f Fingerprint) Empty() bool

Empty reports whether no recreate-relevant apply fields are set.

Jump to

Keyboard shortcuts

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