Skip to content
Merged
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
13 changes: 10 additions & 3 deletions internal/pkg/object/command/ecs/ecs.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,10 @@ const (
)

var (
errMissingTemplate = fmt.Errorf("task definition template is required")
cleanupMethod = telemetry.NewMethod("ecs", "cleanup")
handlerMethod = telemetry.NewMethod("ecs", "handler")
errMissingTemplate = fmt.Errorf("task definition template is required")
errNoTasksAvailable = fmt.Errorf("no tasks available to retrieve logs")
cleanupMethod = telemetry.NewMethod("ecs", "cleanup")
handlerMethod = telemetry.NewMethod("ecs", "handler")
)

func New(commandCtx *heimdallContext.Context) (plugin.Handler, error) {
Expand Down Expand Up @@ -213,6 +214,7 @@ func (execCtx *executionContext) startTasks(ctx context.Context, jobID string) e
return err
}
taskName := fmt.Sprintf("%s%s-%d", startedByPrefix, jobID, i)
execCtx.runtime.Stdout.WriteString(fmt.Sprintf("ecs: started task name=%s arn=%s\n", taskName, taskARN))
execCtx.tasks[taskName] = &taskTracker{
Name: taskName,
ActiveARN: taskARN,
Expand Down Expand Up @@ -304,6 +306,7 @@ func (execCtx *executionContext) pollForCompletion(ctx context.Context) error {

// Assign the new task ARN to the tracker
tracker.ActiveARN = newTaskARN
execCtx.runtime.Stdout.WriteString(fmt.Sprintf("ecs: restarted task name=%s arn=%s retry=%d\n", tracker.Name, newTaskARN, tracker.Retries))

// Task failed but will be restarted, so mark as not complete
done = false
Expand Down Expand Up @@ -642,6 +645,10 @@ func (execCtx *executionContext) retrieveLogs(ctx context.Context) error {
writer = execCtx.runtime.Stdout
}

if selectedTask == nil {
return errNoTasksAvailable
}

// Extract task ID from ARN
arnParts := strings.Split(selectedTask.ActiveARN, "/")
if len(arnParts) < 2 {
Expand Down
Loading