From 4c2b1d40a49b0de5eed24c329833d9fdc10a860a Mon Sep 17 00:00:00 2001 From: Edward J Date: Fri, 10 Oct 2025 13:50:55 -0700 Subject: [PATCH 1/5] Return error when cfn template container does not have an image --- src/pkg/clouds/aws/ecs/cfn/setup.go | 7 ++++++- src/pkg/clouds/aws/ecs/cfn/template.go | 8 ++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/pkg/clouds/aws/ecs/cfn/setup.go b/src/pkg/clouds/aws/ecs/cfn/setup.go index 7796b3c73..ab0802d5c 100644 --- a/src/pkg/clouds/aws/ecs/cfn/setup.go +++ b/src/pkg/clouds/aws/ecs/cfn/setup.go @@ -134,7 +134,12 @@ func (a *AwsEcs) createStackAndWait(ctx context.Context, templateBody string) er } func (a *AwsEcs) SetUp(ctx context.Context, containers []types.Container) error { - template, err := createTemplate(a.stackName, containers, TemplateOverrides{VpcID: a.VpcID, Spot: a.Spot}).YAML() + tmpl, err := createTemplate(a.stackName, containers, TemplateOverrides{VpcID: a.VpcID, Spot: a.Spot}) + if err != nil { + return err + } + + template, err := tmpl.YAML() if err != nil { return err } diff --git a/src/pkg/clouds/aws/ecs/cfn/template.go b/src/pkg/clouds/aws/ecs/cfn/template.go index 6a67c9950..df91d5082 100644 --- a/src/pkg/clouds/aws/ecs/cfn/template.go +++ b/src/pkg/clouds/aws/ecs/cfn/template.go @@ -4,6 +4,7 @@ import ( "crypto/sha256" "encoding/hex" "encoding/json" + "fmt" "math" "os" "strconv" @@ -58,7 +59,7 @@ type TemplateOverrides struct { const TemplateRevision = 1 // bump this when the template changes! -func createTemplate(stack string, containers []types.Container, overrides TemplateOverrides) *cloudformation.Template { +func createTemplate(stack string, containers []types.Container, overrides TemplateOverrides) (*cloudformation.Template, error) { prefix := stack + "-" defaultTags := []tags.Tag{ @@ -182,6 +183,9 @@ func createTemplate(stack string, containers []types.Container, overrides Templa // TODO: support pull through cache for other registries // TODO: support private repos (with or without pull-through cache) } + if image == "" { + return nil, fmt.Errorf("container %v is using invalid image: %q", task.Name, task.Image) + } images = append(images, image) } @@ -545,5 +549,5 @@ func createTemplate(stack string, containers []types.Container, overrides Templa Value: cloudformation.Int(TemplateRevision), } - return template + return template, nil } From 0ec895d6b1f2c8aff36851dc0b22707304f83a7b Mon Sep 17 00:00:00 2001 From: Edward J Date: Fri, 10 Oct 2025 13:54:40 -0700 Subject: [PATCH 2/5] Trim space before test image empty --- src/pkg/clouds/aws/ecs/cfn/template.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pkg/clouds/aws/ecs/cfn/template.go b/src/pkg/clouds/aws/ecs/cfn/template.go index df91d5082..57668c630 100644 --- a/src/pkg/clouds/aws/ecs/cfn/template.go +++ b/src/pkg/clouds/aws/ecs/cfn/template.go @@ -183,7 +183,7 @@ func createTemplate(stack string, containers []types.Container, overrides Templa // TODO: support pull through cache for other registries // TODO: support private repos (with or without pull-through cache) } - if image == "" { + if strings.TrimSpace(image) == "" { return nil, fmt.Errorf("container %v is using invalid image: %q", task.Name, task.Image) } images = append(images, image) From 8e626a006cb687d38979b539eef2d50d3748ac70 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Tue, 14 Oct 2025 10:00:38 -0700 Subject: [PATCH 3/5] Update src/pkg/clouds/aws/ecs/cfn/setup.go Co-authored-by: Jordan Stephens --- src/pkg/clouds/aws/ecs/cfn/setup.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pkg/clouds/aws/ecs/cfn/setup.go b/src/pkg/clouds/aws/ecs/cfn/setup.go index ab0802d5c..1aabf0c8d 100644 --- a/src/pkg/clouds/aws/ecs/cfn/setup.go +++ b/src/pkg/clouds/aws/ecs/cfn/setup.go @@ -136,7 +136,7 @@ func (a *AwsEcs) createStackAndWait(ctx context.Context, templateBody string) er func (a *AwsEcs) SetUp(ctx context.Context, containers []types.Container) error { tmpl, err := createTemplate(a.stackName, containers, TemplateOverrides{VpcID: a.VpcID, Spot: a.Spot}) if err != nil { - return err + return fmt.Errorf("failed to create cloud formation template: %w", err) } template, err := tmpl.YAML() From 0506d7b54ff33032b468e059ef4abd05746a8167 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Tue, 14 Oct 2025 10:01:01 -0700 Subject: [PATCH 4/5] Update src/pkg/clouds/aws/ecs/cfn/setup.go Co-authored-by: Jordan Stephens --- src/pkg/clouds/aws/ecs/cfn/setup.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pkg/clouds/aws/ecs/cfn/setup.go b/src/pkg/clouds/aws/ecs/cfn/setup.go index 1aabf0c8d..60b33e775 100644 --- a/src/pkg/clouds/aws/ecs/cfn/setup.go +++ b/src/pkg/clouds/aws/ecs/cfn/setup.go @@ -141,7 +141,7 @@ func (a *AwsEcs) SetUp(ctx context.Context, containers []types.Container) error template, err := tmpl.YAML() if err != nil { - return err + return fmt.Errorf("failed to marshal Cloud Formation template as YAML: %w", err) } // Upsert From 24c27d1f8cd8ecf967eae2ca63d97b568d0b6d07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lio=E6=9D=8E=E6=AD=90?= Date: Wed, 15 Oct 2025 20:20:14 +0200 Subject: [PATCH 5/5] Update src/pkg/clouds/aws/ecs/cfn/setup.go --- src/pkg/clouds/aws/ecs/cfn/setup.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pkg/clouds/aws/ecs/cfn/setup.go b/src/pkg/clouds/aws/ecs/cfn/setup.go index 60b33e775..8be7a95da 100644 --- a/src/pkg/clouds/aws/ecs/cfn/setup.go +++ b/src/pkg/clouds/aws/ecs/cfn/setup.go @@ -136,12 +136,12 @@ func (a *AwsEcs) createStackAndWait(ctx context.Context, templateBody string) er func (a *AwsEcs) SetUp(ctx context.Context, containers []types.Container) error { tmpl, err := createTemplate(a.stackName, containers, TemplateOverrides{VpcID: a.VpcID, Spot: a.Spot}) if err != nil { - return fmt.Errorf("failed to create cloud formation template: %w", err) + return fmt.Errorf("failed to create CloudFormation template: %w", err) } template, err := tmpl.YAML() if err != nil { - return fmt.Errorf("failed to marshal Cloud Formation template as YAML: %w", err) + return fmt.Errorf("failed to marshal CloudFormation template as YAML: %w", err) } // Upsert