Skip to content
Closed
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
4 changes: 4 additions & 0 deletions internal/pkg/cli/task_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,10 @@ func (o *runTaskOpts) runTask() ([]*task.Task, error) {
o.spinner.Start(fmt.Sprintf("Waiting for %s to be running for %s.", english.Plural(o.count, "task", ""), o.groupName))
tasks, err := o.runner.Run()
if err != nil {
if errors.Is(err, task.ErrNoSubnetFound) {
log.Warningf("Subnets need to be tagged with %s and %s. Are your subnets tagged?\n", deploy.AppTagKey, deploy.EnvTagKey)
}

o.spinner.Stop(log.Serrorf("Failed to run %s.\n\n", o.groupName))
return nil, fmt.Errorf("run task %s: %w", o.groupName, err)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/task/config_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (r *NetworkConfigRunner) Run() ([]*Task, error) {
return nil, fmt.Errorf(fmtErrDefaultSubnets, err)
}
if len(subnets) == 0 {
return nil, errNoSubnetFound
return nil, ErrNoSubnetFound
}

r.Subnets = subnets
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/task/env_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (r *EnvRunner) Run() ([]*Task, error) {
return nil, fmt.Errorf(fmtErrPublicSubnetsFromEnv, r.Env, err)
}
if len(subnets) == 0 {
return nil, errNoSubnetFound
return nil, ErrNoSubnetFound
}

// Use only environment security group https://github.com/aws/copilot-cli/issues/1882.
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/task/env_runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func TestEnvRunner_Run(t *testing.T) {
m.EXPECT().SecurityGroups(gomock.Any()).AnyTimes()
},
mockStarter: mockStarterNotRun,
wantedError: errNoSubnetFound,
wantedError: ErrNoSubnetFound,
},
"failed to get security groups": {
MockClusterGetter: MockClusterGetter,
Expand Down
3 changes: 2 additions & 1 deletion internal/pkg/task/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import (
"fmt"
)

// Errors returned while trying to run a task.
var (
errNoSubnetFound = errors.New("no subnets found")
ErrNoSubnetFound = errors.New("no subnets found")
Comment on lines 12 to +13
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a top-level comment here since we now have exported errors

Suggested change
var (
errNoSubnetFound = errors.New("no subnets found")
ErrNoSubnetFound = errors.New("no subnets found")
// Errors returned while trying to run a task.
var (
ErrNoSubnetFound = errors.New("no subnets found")


errVPCGetterNil = errors.New("vpc getter is not set")
errClusterGetterNil = errors.New("cluster getter is not set")
Expand Down