Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion pkg/compose/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,23 @@ const (

// Provider operations
OpRunProvider OperationType = 30

// Start-phase operations
OpWaitCondition OperationType = 40
OpRunPreStart OperationType = 41
OpRunPostStart OperationType = 42
)

// PlanPhase situates a node in the plan lifecycle. The Create phase converges
// resources and containers to their desired shape; the Start phase brings
// containers to running — dependency waits, pre_start hooks, starts,
// post_start hooks. The zero value is Create, so plans built before the start
// phase existed render unchanged.
type PlanPhase int

const (
PhaseCreate PlanPhase = iota
PhaseStart
)

// String returns the human-readable name of an OperationType.
Expand Down Expand Up @@ -82,6 +99,12 @@ func (o OperationType) String() string {
return "RenameContainer"
case OpRunProvider:
return "RunProvider"
case OpWaitCondition:
return "WaitCondition"
case OpRunPreStart:
return "RunPreStart"
case OpRunPostStart:
return "RunPostStart"
default:
return fmt.Sprintf("Unknown(%d)", int(o))
}
Expand All @@ -102,7 +125,8 @@ type Operation struct {
Network *types.NetworkConfig // for network operations
Volume *types.VolumeConfig // for volume operations
Timeout *time.Duration // for stop operations
CreateNodeID int // for OpRenameContainer: ID of the CreateContainer node whose result to rename
CreateNodeID int // for OpRenameContainer/start-phase ops: ID of the CreateContainer node whose result to target
Condition string // for OpWaitCondition: depends_on condition to wait for (service_healthy, ...)
// BestEffort marks an operation whose failure must not abort the plan. It is
// used for the optional removal of the old network on a rename: if the
// network is still in use (by non-Compose containers) the removal is skipped
Expand All @@ -118,6 +142,7 @@ type PlanNode struct {
Operation Operation
DependsOn []*PlanNode // prerequisite operations
Group string // event grouping key (e.g. "recreate:web:1"); empty for ungrouped nodes
Phase PlanPhase // lifecycle phase this node belongs to; zero is Create
}

// Plan is a directed acyclic graph of operations produced by the reconciler.
Expand Down Expand Up @@ -171,6 +196,9 @@ func (p *Plan) String() string {
if node.Group != "" {
fmt.Fprintf(&sb, " [%s]", node.Group)
}
if node.Phase == PhaseStart {
sb.WriteString(" {start}")
}
sb.WriteByte('\n')
}
return sb.String()
Expand Down
Loading
Loading