Skip to content

Commit 09691b6

Browse files
committed
add status stopped
1 parent 12a78db commit 09691b6

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

internal/orchestrator/helpers.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ 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+
// starting: at least one starting
5252
func parseAppStatus(containers []container.Summary) []AppStatusInfo {
5353
apps := make([]AppStatusInfo, 0, len(containers))
5454
appsStatusMap := make(map[string][]Status)
@@ -93,6 +93,10 @@ func parseAppStatus(containers []container.Summary) []AppStatusInfo {
9393
appendResult(appPath, StatusStopping)
9494
continue
9595
}
96+
if slices.ContainsFunc(s, func(v Status) bool { return v == StatusStopped }) {
97+
appendResult(appPath, StatusFailed)
98+
continue
99+
}
96100
if slices.ContainsFunc(s, func(v Status) bool { return v == StatusStarting }) {
97101
appendResult(appPath, StatusStarting)
98102
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)