placement

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package placement decides which node a tile's task may run on.

Two rules, and the first one is the dangerous one:

  • A pinned tile (it has a volume) runs on its home node and nowhere else. A local volume is a directory on one host's disk, so a pinned task that lands on a different node comes up against an empty volume and the data is simply not there. Swarm reports that as a healthy task. The home node is written on first deploy and changed only by a completed move (docs/plans/30-docker-swarm.md, addendum).
  • A tile with a node group runs only on nodes carrying that label. Groups cascade org to stack to environment to tile like every other setting (docs/plans/31-node-agent-open-questions.md, node groups).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InGroup

func InGroup(ctx context.Context, store repo.Store, rt *runtime.Runtime, t *repo.Tile, group string) bool

InGroup reports whether a pinned tile's data already sits on a node in the given group, so a config change asking for that group needs no volume move.

One predicate, two callers: the plan view uses it to stop showing a move block the operator has already done, and the apply uses it to stop refusing on one. They have to agree, or the page offers a button the apply rejects.

func IsPinned

func IsPinned(ctx context.Context, store repo.Store, t *repo.Tile) bool

func NodeOf

func NodeOf(ctx context.Context, store repo.Store, t *repo.Tile) string

IsPinned reports whether a tile holds a volume, and so may never run more than one replica or move nodes on its own. The classifier is the existing one; no new field (docs/plans/30-docker-swarm.md, addendum). NodeOf is the node a tile's data is on: its home node, or for a volume tile the home node of the service that mounts it.

A volume tile has no service and no placement of its own, the volume is a mount on the tile it is attached to, so that tile's node is where the directory actually is. Reading the volume tile's own column instead is how the file browser came to show the manager's copy of a volume that had been moved to a worker: no error, just the wrong files. Empty means "here".

func ParseAttachment

func ParseAttachment(line string) (storageSlug, pathName, mount string, ro bool, err error)

ParseAttachment decodes one tiles.storage line: "storage-slug/path-name:/mount[:ro]". Only an org share line ("${{ org.storage.NAME }}:/mount") may leave the path name out: it mounts the share's root that way, while a server pool always names a path.

func StorageNodes

func StorageNodes(ctx context.Context, store repo.Store, t *repo.Tile) (nodes []string, anyLocal bool)

StorageNodes reports the swarm nodes the local-backed pools a tile attaches live on, deduped, and whether it attaches any local pool at all.

A local pool is a directory on one host. Docker silently creates an empty local volume for a name it does not know, so a task scheduled anywhere else mounts nothing and reports healthy. That makes a storage attachment a pin just as much as a volume is, which IsPinned used to miss.

A pool whose server has not joined the swarm yet contributes no node id: the tile is still pinned by the attachment, there is just no home to name yet.

Types

type Plan

type Plan struct {
	// HomeNode is set for pinned tiles only.
	HomeNode string
	// Group is the resolved node group, "" = anywhere.
	Group string
	// Replicas is 1 for pinned tiles, the tile's own count otherwise.
	Replicas int
	Pinned   bool
}

Plan is where one tile's task is allowed to run.

func For

func For(ctx context.Context, store repo.Store, rt *runtime.Runtime, t *repo.Tile) (Plan, error)

For resolves a tile's placement, assigning and persisting a home node the first time a pinned tile deploys.

A pinned tile whose home node has left the swarm is refused rather than rescheduled: rescheduling it is exactly the silent data loss above. The operator's way out is Remove on the dead node, which says which volumes go with it.

Jump to

Keyboard shortcuts

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