Skip to content

Commit

Permalink
fix errored
Browse files Browse the repository at this point in the history
  • Loading branch information
fujiwara committed Nov 4, 2022
1 parent de6885e commit 5389184
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func dispatchCLI(ctx context.Context, sub string, opts *CLIOptions) error {
if err != nil {
return err
}

app.Log("[DEBUG] dispatching subcommand: %s", sub)
switch sub {
case "deploy":
return app.Deploy(ctx, *opts.Deploy)
Expand Down
2 changes: 2 additions & 0 deletions deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ func calcDesiredCount(sv *Service, opt DeployOption) *int32 {
}

func (d *App) Deploy(ctx context.Context, opt DeployOption) error {
d.Log("[DEBUG] deploy")
d.LogJSON(opt)
ctx, cancel := d.Start(ctx)
defer cancel()

Expand Down
9 changes: 6 additions & 3 deletions ecspresso.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ type Option struct {
func (opt *Option) resolveDefaultConfigFilePath() (path string) {
path = DefaultConfigFilePath
defer func() {
log.Println("resolved config file path:", path)
opt.ConfigFilePath = path
if opt.InitOption != nil {
opt.InitOption.ConfigFilePath = &path
Expand Down Expand Up @@ -196,8 +195,12 @@ func (d *App) DescribeService(ctx context.Context) (*Service, error) {
if len(out.Services) == 0 {
return nil, ErrNotFound(fmt.Sprintf("service %s is not found", d.Service))
}
if s := aws.ToString(out.Services[0].Status); s == "INACTIVE" {
return nil, ErrNotFound(fmt.Sprintf("service %s is %s", d.Service, s))
status := aws.ToString(out.Services[0].Status)
switch status {
case "DRAINING":
d.Log("[WARNING] service %s is %s", d.Service, status)
case "INACTIVE":
return nil, ErrNotFound(fmt.Sprintf("service %s is %s", d.Service, status))
}
return newServiceFromTypes(out.Services[0]), nil
}
Expand Down
9 changes: 6 additions & 3 deletions run.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (d *App) Run(ctx context.Context, opt RunOption) error {
return err
}
watchContainer := containerOf(td, opt.WatchContainer)
d.Log("Watch container:", *watchContainer.Name)
d.Log("Watch container: %s", *watchContainer.Name)

task, err := d.RunTask(ctx, tdArn, &ov, &opt)
if err != nil {
Expand Down Expand Up @@ -134,12 +134,15 @@ func (d *App) RunTask(ctx context.Context, tdArn string, ov *types.TaskOverride,
}
d.Log("[DEBUG] propagate tags from service %s", *sv.ServiceArn, out)
in.Tags = append(in.Tags, out.Tags...)
case "":
in.PropagateTags = types.PropagateTagsNone
case "", "NONE":
// XXX ECS says > InvalidParameterException: Invalid value for propagateTags
// in.PropagateTags = types.PropagateTagsNone
in.PropagateTags = ""
default:
in.PropagateTags = types.PropagateTagsTaskDefinition
}
d.Log("[DEBUG] run task input %v", in)
d.LogJSON(in)

out, err := d.ecs.RunTask(ctx, in)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions scale.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type ScaleOption struct {

func (o *ScaleOption) DeployOption() DeployOption {
return DeployOption{
DesiredCount: o.DesiredCount,
DryRun: o.DryRun,
SkipTaskDefinition: ptr(true),
ForceNewDeployment: ptr(false),
Expand Down
2 changes: 2 additions & 0 deletions wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func (d *App) Wait(ctx context.Context, opt WaitOption) error {
if err != nil {
return err
}
d.LogJSON(sv.DeploymentController)
if sv.isCodeDeploy() {
err := d.WaitForCodeDeploy(ctx, sv)
if err != nil {
Expand Down Expand Up @@ -71,6 +72,7 @@ func (d *App) WaitServiceStable(ctx context.Context, sv *Service) error {
}

func (d *App) WaitForCodeDeploy(ctx context.Context, sv *Service) error {
d.Log("[DEBUG] wait for CodeDeploy")
dp, err := d.findDeploymentInfo(ctx)
if err != nil {
return err
Expand Down

0 comments on commit 5389184

Please sign in to comment.