drift

package
v1.10.21 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package drift is the shared vocabulary for divergence between what Miabi recorded and what Docker runs. Node housekeeping reports it for one node; the control manager watches it across the platform.

Index

Constants

View Source
const (
	ClassOrphan    = "orphan"    // managed label present, DB record gone — still running on the node
	ClassMissing   = "missing"   // DB record expects it live, nothing running for it
	ClassUntracked = "untracked" // no miabi.* label — a hand-run resource
	// ClassReplaced is a resource whose record is intact but whose contents are not: a volume deleted and
	// recreated by hand keeps its name and its row, and holds none of the data they describe.
	ClassReplaced = "replaced"
)

Classes.

View Source
const (
	ActionRemove   = "remove"   // orphan → delete the lingering resource
	ActionRedeploy = "redeploy" // missing → redeploy from the owning resource
	ActionImport   = "import"   // untracked → adopt via the existing import flow
	// ActionRestore is for lost data: recreating the volume would give an empty one, so the way back is a
	// backup, not a redeploy.
	ActionRestore = "restore"
	// ActionNone is for drift Miabi must report but may not touch, because something else owns the resource —
	// the platform's own gateway, installed and owned by the Miabi stack.
	ActionNone = "none"
)

Recommended actions per item.

View Source
const (
	OwnerApp      = "app"
	OwnerDatabase = "database"
	OwnerVolume   = "volume"
	OwnerStack    = "stack"
	OwnerConfig   = "config"
	// OwnerNode is for what a node itself owns rather than a workspace: its gateway.
	OwnerNode = "node"
)

Owner kinds: the DB record class a managed resource belongs to.

Variables

This section is empty.

Functions

func OwnerOf

func OwnerOf(labels map[string]string) (kind string, id uint, ok bool)

OwnerOf returns the owning DB record (kind and numeric id) encoded in a managed resource's labels, so drift can check whether that record still exists. ok is false when the resource is not orphan-eligible. Precedence matters: an app's container carries both app and stack labels, and the app is the owning record.

func Replaced

func Replaced(recorded, engineCreatedAt string) bool

Replaced reports whether a volume that exists under its own name is no longer the one Miabi recorded: its engine creation timestamp moved, so it was deleted and created again, and it holds none of the data the record describes. A volume Miabi never recorded a timestamp for is not replaced — most predate the column, and calling them all replaced would cry wolf about every one of them.

func VolumeOwner

func VolumeOwner(labels map[string]string) (kind string, id uint, ok bool)

VolumeOwner returns the record a managed Docker volume backs: a volume row, or the database instance whose data it holds. App and stack labels are not owners here: neither record owns a volume's data.

func VolumeState

func VolumeState(ctx context.Context, dc docker.Client, name, recordedCreatedAt string) (string, error)

VolumeState reports whether a volume still holds the data its record describes: "" when it does, ClassMissing when it is gone, ClassReplaced when it was deleted and recreated. An engine that cannot answer returns an error and no class — not knowing is never evidence of loss.

Types

type Item

type Item struct {
	Class     string `json:"class"`
	Kind      string `json:"kind"` // container | volume | config | service
	Ref       string `json:"ref"`  // container ID or volume name (the apply handle)
	Name      string `json:"name"`
	Image     string `json:"image,omitempty"`
	State     string `json:"state,omitempty"`
	OwnerKind string `json:"owner_kind,omitempty"` // app | database | volume | stack
	OwnerID   uint   `json:"owner_id,omitempty"`
	Action    string `json:"action"`
}

Item is one resource that diverges from intent.

Jump to

Keyboard shortcuts

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