Skip to content
Merged
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
6 changes: 6 additions & 0 deletions pkg/app/piped/planner/cloudrun/cloudrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func (p *Planner) Plan(ctx context.Context, in planner.Input) (out planner.Outpu
// we rely on the user's decision.
switch in.Deployment.Trigger.SyncStrategy {
case model.SyncStrategy_QUICK_SYNC:
out.SyncStrategy = model.SyncStrategy_QUICK_SYNC
out.Stages = buildQuickSyncPipeline(cfg.Input.AutoRollback, time.Now())
out.Summary = fmt.Sprintf("Quick sync to deploy image %s and configure all traffic to it (forced via web)", out.Version)
return
Expand All @@ -74,6 +75,7 @@ func (p *Planner) Plan(ctx context.Context, in planner.Input) (out planner.Outpu
err = fmt.Errorf("unable to force sync with pipeline because no pipeline was specified")
return
}
out.SyncStrategy = model.SyncStrategy_PIPELINE
out.Stages = buildProgressivePipeline(cfg.Pipeline, cfg.Input.AutoRollback, time.Now())
out.Summary = fmt.Sprintf("Sync with pipeline to deploy image %s (forced via web)", out.Version)
return
Expand All @@ -82,13 +84,15 @@ func (p *Planner) Plan(ctx context.Context, in planner.Input) (out planner.Outpu
// This is the first time to deploy this application or it was unable to retrieve that value.
// We just do the quick sync.
if in.MostRecentSuccessfulCommitHash == "" {
out.SyncStrategy = model.SyncStrategy_QUICK_SYNC
out.Stages = buildQuickSyncPipeline(cfg.Input.AutoRollback, time.Now())
out.Summary = fmt.Sprintf("Quick sync to deploy image %s and configure all traffic to it (it seems this is the first deployment)", out.Version)
return
}

// When no pipeline was configured, do the quick sync.
if cfg.Pipeline == nil || len(cfg.Pipeline.Stages) == 0 {
out.SyncStrategy = model.SyncStrategy_QUICK_SYNC
out.Stages = buildQuickSyncPipeline(cfg.Input.AutoRollback, time.Now())
out.Summary = fmt.Sprintf("Quick sync to deploy image %s and configure all traffic to it (pipeline was not configured)", out.Version)
return
Expand All @@ -98,12 +102,14 @@ func (p *Planner) Plan(ctx context.Context, in planner.Input) (out planner.Outpu
ds, err = in.RunningDSP.Get(ctx, ioutil.Discard)
if err == nil {
if lastVersion, e := p.determineVersion(ds.AppDir, cfg.Input.ServiceManifestFile); e == nil {
out.SyncStrategy = model.SyncStrategy_PIPELINE
out.Stages = buildProgressivePipeline(cfg.Pipeline, cfg.Input.AutoRollback, time.Now())
out.Summary = fmt.Sprintf("Sync with pipeline to update image from %s to %s", lastVersion, out.Version)
return
}
}

out.SyncStrategy = model.SyncStrategy_PIPELINE
out.Stages = buildProgressivePipeline(cfg.Pipeline, cfg.Input.AutoRollback, time.Now())
out.Summary = "Sync with the specified pipeline"
return
Expand Down
6 changes: 6 additions & 0 deletions pkg/app/piped/planner/ecs/ecs.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func (p *Planner) Plan(ctx context.Context, in planner.Input) (out planner.Outpu
// we rely on the user's decision.
switch in.Deployment.Trigger.SyncStrategy {
case model.SyncStrategy_QUICK_SYNC:
out.SyncStrategy = model.SyncStrategy_QUICK_SYNC
out.Stages = buildQuickSyncPipeline(cfg.Input.AutoRollback, time.Now())
out.Summary = fmt.Sprintf("Quick sync to deploy image %s and configure all traffic to it (forced via web)", out.Version)
return
Expand All @@ -74,6 +75,7 @@ func (p *Planner) Plan(ctx context.Context, in planner.Input) (out planner.Outpu
err = fmt.Errorf("unable to force sync with pipeline because no pipeline was specified")
return
}
out.SyncStrategy = model.SyncStrategy_PIPELINE
out.Stages = buildProgressivePipeline(cfg.Pipeline, cfg.Input.AutoRollback, time.Now())
out.Summary = fmt.Sprintf("Sync with pipeline to deploy image %s (forced via web)", out.Version)
return
Expand All @@ -82,13 +84,15 @@ func (p *Planner) Plan(ctx context.Context, in planner.Input) (out planner.Outpu
// If this is the first time to deploy this application or it was unable to retrieve last successful commit,
// we perform the quick sync strategy.
if in.MostRecentSuccessfulCommitHash == "" {
out.SyncStrategy = model.SyncStrategy_QUICK_SYNC
out.Stages = buildQuickSyncPipeline(cfg.Input.AutoRollback, time.Now())
out.Summary = fmt.Sprintf("Quick sync to deploy image %s and configure all traffic to it (it seems this is the first deployment)", out.Version)
return
}

// When no pipeline was configured, perform the quick sync.
if cfg.Pipeline == nil || len(cfg.Pipeline.Stages) == 0 {
out.SyncStrategy = model.SyncStrategy_QUICK_SYNC
out.Stages = buildQuickSyncPipeline(cfg.Input.AutoRollback, time.Now())
out.Summary = fmt.Sprintf("Quick sync to deploy image %s and configure all traffic to it (pipeline was not configured)", out.Version)
return
Expand All @@ -98,12 +102,14 @@ func (p *Planner) Plan(ctx context.Context, in planner.Input) (out planner.Outpu
ds, err = in.RunningDSP.Get(ctx, ioutil.Discard)
if err == nil {
if lastVersion, e := determineVersion(ds.AppDir, cfg.Input.TaskDefinitionFile); e == nil {
out.SyncStrategy = model.SyncStrategy_PIPELINE
out.Stages = buildProgressivePipeline(cfg.Pipeline, cfg.Input.AutoRollback, time.Now())
out.Summary = fmt.Sprintf("Sync with pipeline to update image from %s to %s", lastVersion, out.Version)
return
}
}

out.SyncStrategy = model.SyncStrategy_PIPELINE
out.Stages = buildProgressivePipeline(cfg.Pipeline, cfg.Input.AutoRollback, time.Now())
out.Summary = "Sync with the specified pipeline"
return
Expand Down
8 changes: 8 additions & 0 deletions pkg/app/piped/planner/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ func (p *Planner) Plan(ctx context.Context, in planner.Input) (out planner.Outpu
// we rely on the user's decision.
switch in.Deployment.Trigger.SyncStrategy {
case model.SyncStrategy_QUICK_SYNC:
out.SyncStrategy = model.SyncStrategy_QUICK_SYNC
out.Stages = buildQuickSyncPipeline(cfg.Input.AutoRollback, time.Now())
out.Summary = "Quick sync by applying all manifests (forced via web)"
return
Expand All @@ -109,6 +110,7 @@ func (p *Planner) Plan(ctx context.Context, in planner.Input) (out planner.Outpu
err = fmt.Errorf("unable to force sync with pipeline because no pipeline was specified")
return
}
out.SyncStrategy = model.SyncStrategy_PIPELINE
out.Stages = buildProgressivePipeline(cfg.Pipeline, cfg.Input.AutoRollback, time.Now())
out.Summary = "Sync with the specified pipeline (forced via web)"
return
Expand All @@ -117,6 +119,7 @@ func (p *Planner) Plan(ctx context.Context, in planner.Input) (out planner.Outpu
// If the progressive pipeline was not configured
// we have only one choise to do is applying all manifestt.
if cfg.Pipeline == nil || len(cfg.Pipeline.Stages) == 0 {
out.SyncStrategy = model.SyncStrategy_QUICK_SYNC
out.Stages = buildQuickSyncPipeline(cfg.Input.AutoRollback, time.Now())
out.Summary = "Quick sync by applying all manifests (no pipeline was configured)"
return
Expand All @@ -131,6 +134,7 @@ func (p *Planner) Plan(ctx context.Context, in planner.Input) (out planner.Outpu
return out, err
}
if pipelineRegex.MatchString(in.Deployment.Trigger.Commit.Message) {
out.SyncStrategy = model.SyncStrategy_PIPELINE
out.Stages = buildProgressivePipeline(cfg.Pipeline, cfg.Input.AutoRollback, time.Now())
out.Summary = fmt.Sprintf("Sync progressively because the commit message was matching %q", p)
return out, err
Expand All @@ -146,6 +150,7 @@ func (p *Planner) Plan(ctx context.Context, in planner.Input) (out planner.Outpu
return out, err
}
if syncRegex.MatchString(in.Deployment.Trigger.Commit.Message) {
out.SyncStrategy = model.SyncStrategy_QUICK_SYNC
out.Stages = buildQuickSyncPipeline(cfg.Input.AutoRollback, time.Now())
out.Summary = fmt.Sprintf("Quick sync by applying all manifests because the commit message was matching %q", s)
return out, err
Expand All @@ -156,6 +161,7 @@ func (p *Planner) Plan(ctx context.Context, in planner.Input) (out planner.Outpu
// or it was unable to retrieve that value.
// We just apply all manifests.
if in.MostRecentSuccessfulCommitHash == "" {
out.SyncStrategy = model.SyncStrategy_QUICK_SYNC
out.Stages = buildQuickSyncPipeline(cfg.Input.AutoRollback, time.Now())
out.Summary = "Quick sync by applying all manifests because it seems this is the first deployment"
return
Expand Down Expand Up @@ -185,10 +191,12 @@ func (p *Planner) Plan(ctx context.Context, in planner.Input) (out planner.Outpu
out.Summary = desc

if progressive {
out.SyncStrategy = model.SyncStrategy_PIPELINE
out.Stages = buildProgressivePipeline(cfg.Pipeline, cfg.Input.AutoRollback, time.Now())
return
}

out.SyncStrategy = model.SyncStrategy_QUICK_SYNC
out.Stages = buildQuickSyncPipeline(cfg.Input.AutoRollback, time.Now())
return
}
Expand Down
6 changes: 6 additions & 0 deletions pkg/app/piped/planner/lambda/lambda.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func (p *Planner) Plan(ctx context.Context, in planner.Input) (out planner.Outpu
// we rely on the user's decision.
switch in.Deployment.Trigger.SyncStrategy {
case model.SyncStrategy_QUICK_SYNC:
out.SyncStrategy = model.SyncStrategy_QUICK_SYNC
out.Stages = buildQuickSyncPipeline(cfg.Input.AutoRollback, time.Now())
out.Summary = fmt.Sprintf("Quick sync to deploy image %s and configure all traffic to it (forced via web)", out.Version)
return
Expand All @@ -74,6 +75,7 @@ func (p *Planner) Plan(ctx context.Context, in planner.Input) (out planner.Outpu
err = fmt.Errorf("unable to force sync with pipeline because no pipeline was specified")
return
}
out.SyncStrategy = model.SyncStrategy_PIPELINE
out.Stages = buildProgressivePipeline(cfg.Pipeline, cfg.Input.AutoRollback, time.Now())
out.Summary = fmt.Sprintf("Sync with pipeline to deploy image %s (forced via web)", out.Version)
return
Expand All @@ -82,13 +84,15 @@ func (p *Planner) Plan(ctx context.Context, in planner.Input) (out planner.Outpu
// If this is the first time to deploy this application or it was unable to retrieve last successful commit,
// we perform the quick sync strategy.
if in.MostRecentSuccessfulCommitHash == "" {
out.SyncStrategy = model.SyncStrategy_QUICK_SYNC
out.Stages = buildQuickSyncPipeline(cfg.Input.AutoRollback, time.Now())
out.Summary = fmt.Sprintf("Quick sync to deploy image %s and configure all traffic to it (it seems this is the first deployment)", out.Version)
return
}

// When no pipeline was configured, perform the quick sync.
if cfg.Pipeline == nil || len(cfg.Pipeline.Stages) == 0 {
out.SyncStrategy = model.SyncStrategy_QUICK_SYNC
out.Stages = buildQuickSyncPipeline(cfg.Input.AutoRollback, time.Now())
out.Summary = fmt.Sprintf("Quick sync to deploy image %s and configure all traffic to it (pipeline was not configured)", out.Version)
return
Expand All @@ -98,12 +102,14 @@ func (p *Planner) Plan(ctx context.Context, in planner.Input) (out planner.Outpu
ds, err = in.RunningDSP.Get(ctx, ioutil.Discard)
if err == nil {
if lastVersion, e := determineVersion(ds.AppDir, cfg.Input.FunctionManifestFile); e == nil {
out.SyncStrategy = model.SyncStrategy_PIPELINE
out.Stages = buildProgressivePipeline(cfg.Pipeline, cfg.Input.AutoRollback, time.Now())
out.Summary = fmt.Sprintf("Sync with pipeline to update image from %s to %s", lastVersion, out.Version)
return
}
}

out.SyncStrategy = model.SyncStrategy_PIPELINE
out.Stages = buildProgressivePipeline(cfg.Pipeline, cfg.Input.AutoRollback, time.Now())
out.Summary = "Sync with the specified pipeline"
return
Expand Down
7 changes: 4 additions & 3 deletions pkg/app/piped/planner/planner.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ type Input struct {
}

type Output struct {
Version string
Stages []*model.PipelineStage
Summary string
Version string
SyncStrategy model.SyncStrategy
Summary string
Stages []*model.PipelineStage
}

// MakeInitialStageMetadata makes the initial metadata for the given state configuration.
Expand Down