Skip to content
This repository has been archived by the owner on Apr 6, 2024. It is now read-only.

Fix runtime panic when watching task #30

Merged
merged 3 commits into from
May 1, 2023
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: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# Changelog

## 0.2.1

* Fix runtime panic when watching task - https://github.com/shipatlas/ecs-toolkit/pull/30.

## 0.2.0

* Remove source modification info from `version` command.
* Remove source modification info from `version` command - https://github.com/shipatlas/ecs-toolkit/pull/28.

## 0.1.0

Expand Down
1 change: 0 additions & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ var (
ecs-toolkit version --short`)

versionCmdOptions = &versionOptions{}
versionSourceModified bool
versionSourceRevision string
versionSourceTime time.Time
versionTag string
Expand Down
21 changes: 17 additions & 4 deletions pkg/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"fmt"
"regexp"
"strconv"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -259,17 +260,29 @@ func watchTask(cluster *string, taskNo *int, task *types.Task, client *ecs.Clien
if *task.LastStatus == "STOPPED" {
nonZeroExit := false
for _, container := range task.Containers {
containerReason := "none"
var (
containerExitCode = "none"
containerName = "unknown"
containerReason = "none"
)

if container.ExitCode != nil {
containerExitCode = strconv.Itoa(int(*container.ExitCode))

if *container.ExitCode != 0 {
nonZeroExit = true
}
}

if container.ExitCode != nil && *container.ExitCode != 0 {
nonZeroExit = true
if container.Name != nil {
containerName = strings.ToLower(*container.Name)
}

if container.Reason != nil {
containerReason = strings.ToLower(*container.Reason)
}

taskSublogger.Debugf("stopped task [%d] container [%s] ... exit code: %d, reason: %s", *taskNo, *container.Name, *container.ExitCode, containerReason)
taskSublogger.Debugf("stopped task [%d] container [%s] ... exit code: %s, reason: %s", *taskNo, containerName, containerExitCode, containerReason)
}

exitMessage := fmt.Sprintf("stopped task [%d], reason: %s", *taskNo, strings.ToLower(string(*task.StoppedReason)))
Expand Down