Skip to content

Commit dc07a7f

Browse files
committed
add status stopped
1 parent 12a78db commit dc07a7f

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

internal/orchestrator/helpers.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,12 @@ type AppStatusInfo struct {
4444
// For app that have at least 1 dependency, we calculate the overall state
4545
// as follow:
4646
//
47-
// running: all running
48-
// stopped: all stopped
49-
// failed: at least one failed
50-
// stopping: at least one stopping
51-
// starting: at least one starting
47+
// running: all running
48+
// stopped: all stopped
49+
// failed: at least one failed
50+
// stopped: at least one stopped
51+
// stopping: at least one stopping
52+
// starting: at least one starting
5253
func parseAppStatus(containers []container.Summary) []AppStatusInfo {
5354
apps := make([]AppStatusInfo, 0, len(containers))
5455
appsStatusMap := make(map[string][]Status)
@@ -84,7 +85,7 @@ func parseAppStatus(containers []container.Summary) []AppStatusInfo {
8485
}
8586

8687
// ...else we have multiple different status we calculate the status
87-
// among the possible left: {failed, stopping, starting}
88+
// among the possible left: {failed, stopping, stopped, starting}
8889
if slices.ContainsFunc(s, func(v Status) bool { return v == StatusFailed }) {
8990
appendResult(appPath, StatusFailed)
9091
continue
@@ -93,6 +94,10 @@ func parseAppStatus(containers []container.Summary) []AppStatusInfo {
9394
appendResult(appPath, StatusStopping)
9495
continue
9596
}
97+
if slices.ContainsFunc(s, func(v Status) bool { return v == StatusStopped }) {
98+
appendResult(appPath, StatusFailed)
99+
continue
100+
}
96101
if slices.ContainsFunc(s, func(v Status) bool { return v == StatusStarting }) {
97102
appendResult(appPath, StatusStarting)
98103
continue

internal/orchestrator/helpers_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func TestParseAppStatus(t *testing.T) {
4646
},
4747
{
4848
name: "failed container takes precedence over stopping and starting",
49-
containerState: []container.ContainerState{container.StateRunning, container.StateDead, container.StateRemoving, container.StateRestarting},
49+
containerState: []container.ContainerState{container.StateRunning, container.StateDead, container.StateRemoving, container.StateRestarting, container.StateExited},
5050
want: StatusFailed,
5151
},
5252
{
@@ -61,7 +61,7 @@ func TestParseAppStatus(t *testing.T) {
6161
},
6262
{
6363
name: "starting",
64-
containerState: []container.ContainerState{container.StateRestarting, container.StateExited},
64+
containerState: []container.ContainerState{container.StateRestarting},
6565
want: StatusStarting,
6666
},
6767
}

0 commit comments

Comments
 (0)