volmove

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: 15 Imported by: 0

Documentation

Overview

Package volmove moves every volume a tile mounts from one node to another.

Docker has no move-volume API and never will: a local volume is a directory on one host's disk. This is the two-pass copy VM live migration uses, run between the two nodes' agents over the stkr overlay with rsync (docs/plans/30-docker-swarm.md, "Moving a volume after the fact"):

  1. the tile keeps running, rsync each volume across, dirty
  2. stop the tile, rsync each again: only the delta, so seconds
  3. flip the home node and start on the target
  4. leave the source volumes alone, and only now

Step 4's ordering is not optional. Deleting the source before the target is verified and running is how the volume is lost. If anything fails before then, the move aborts with the source volumes untouched and the tile back where it was, which is why every failure path below leaves them alone.

Every volume, not the first one found. A tile can mount several volume subtiles, and a move that carried one of them set the home node anyway; the task came up on the target against an empty directory and swarm called it healthy.

Index

Constants

View Source
const Kind = "volume.move"

Kind is the work-queue kind a move runs under.

Variables

This section is empty.

Functions

This section is empty.

Types

type Move

type Move struct {
	ID     string
	TileID string
	From   string // source node ID
	To     string // target node ID
	// Volumes is every volume the tile mounts, not the first one found. A
	// tile with two volume subtiles that moved only one of them came up
	// healthy on the target reading an empty directory, which is the silent
	// loss placement.go opens by warning about.
	Volumes []string
	Phase   Phase
	Bytes   int64
	Total   int64
	Error   string
	Started time.Time
}

Move is one volume move in flight.

func (Move) ETA

func (m Move) ETA() (time.Duration, bool)

ETA is the remaining time at the rate achieved so far, and whether there is enough information to say. Shown next to the bar; a move with no total yet shows bytes only.

type Phase

type Phase string

Phase is where a move has got to. The modal renders one line per phase.

const (
	PhaseQueued Phase = "queued" // waiting for a free slot
	PhaseCopy   Phase = "copy"   // first pass, tile still running
	PhaseStop   Phase = "stop"   // stopping for the delta pass
	PhaseDelta  Phase = "delta"  // second pass, tile down
	PhaseStart  Phase = "start"  // starting on the target
	PhaseDone   Phase = "done"
	PhaseFailed Phase = "failed"
)

type Redeployer

type Redeployer interface {
	EnqueueCurrent(ctx context.Context, t *repo.Tile, trigger string) (string, error)
}

Redeployer restarts one tile so it comes up under its new placement. The deploy engine behind an interface, because infra/deploy would otherwise import this package back.

type Service

type Service struct {
	Store  repo.Store
	C      *cluster.Cluster // every docker call, and the two agents an rsync runs between
	Deploy Redeployer
	// Instances starts a managed instance again. It needs its own path: an
	// instance is provisioned, never built, so it has no deployment row and
	// the deploy engine's EnqueueCurrent answers "" and no error for it. That
	// read as success and left a moved postgres scaled to zero, still
	// constrained to the node it had just left, while the modal said "Moved".
	Instances *managedtiles.Service
	// contains filtered or unexported fields
}

Service runs moves on the work queue. The phase is the item's step and the byte counters its progress, so the modal reads the same thing after a restart. A restart mid-move fails it and puts the tile back where it started (cleanup): resuming a half-move blind is how a volume is lost.

func New

func New(store repo.Store, c *cluster.Cluster, d Redeployer, inst *managedtiles.Service) *Service

func (*Service) Estimate

func (s *Service) Estimate(ctx context.Context, t *repo.Tile) ([]VolumeSize, int64, error)

Estimate is what the Move modal shows before the operator commits: every volume that is about to move, named and sized from the node holding them, and the total.

Named rather than only totalled, because the operator has to be able to see that a move covers all of them. A single "Volume size" line is what let a half-completed move look correct.

func (*Service) ForTile

func (s *Service) ForTile(ctx context.Context, tileID string) *Move

ForTile returns the move in flight for a tile, or one that finished in the last few seconds, or nil. The canvas card and the drawer both read this to show the old to new arrow and the bar.

func (*Service) Start

func (s *Service) Start(ctx context.Context, t *repo.Tile, targetNode string) (*Move, error)

Start queues a move of the tile's volume to target. It returns as soon as the move is queued; progress is read back through ForTile.

func (*Service) WithWork added in v0.4.0

func (s *Service) WithWork(q *workqueue.Queue) *Service

WithWork registers the move kind. Call before the queue starts.

type VolumeSize

type VolumeSize struct {
	Name  string
	Bytes int64
}

VolumeSize is one volume of a move, named and sized, for the modal.

Jump to

Keyboard shortcuts

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