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"):
- the tile keeps running, rsync each volume across, dirty
- stop the tile, rsync each again: only the delta, so seconds
- flip the home node and start on the target
- 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
- type Move
- type Phase
- type Redeployer
- type Service
- func (s *Service) Estimate(ctx context.Context, t *repo.Tile) ([]VolumeSize, int64, error)
- func (s *Service) ForTile(ctx context.Context, tileID string) *Move
- func (s *Service) Start(ctx context.Context, t *repo.Tile, targetNode string) (*Move, error)
- func (s *Service) WithWork(q *workqueue.Queue) *Service
- type VolumeSize
Constants ¶
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.
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 ¶
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 ¶
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.
type VolumeSize ¶
VolumeSize is one volume of a move, named and sized, for the modal.