From 912d7d69323ee18b5f03b5188c529a6b0c03e6b9 Mon Sep 17 00:00:00 2001 From: JoannaaKL Date: Tue, 13 Sep 2022 12:44:22 +0000 Subject: [PATCH] Remove unnecessary 'IsAnyUnhealthy' flag --- src/Runner.Worker/ContainerOperationProvider.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Runner.Worker/ContainerOperationProvider.cs b/src/Runner.Worker/ContainerOperationProvider.cs index ee2b51c14..d809aa731 100644 --- a/src/Runner.Worker/ContainerOperationProvider.cs +++ b/src/Runner.Worker/ContainerOperationProvider.cs @@ -100,33 +100,33 @@ namespace GitHub.Runner.Worker } executionContext.Output("##[group]Waiting for all services to be ready"); - bool IsAnyUnhealthy = false; + _dockerManager.UnhealthyContainers = new List(); foreach (var container in containers.Where(c => !c.IsJobContainer)) { var healthcheck = await Healthcheck(executionContext, container); + if (!string.Equals(healthcheck, "healthy", StringComparison.OrdinalIgnoreCase)) { - IsAnyUnhealthy = true; _dockerManager.UnhealthyContainers.Add(container); } else { executionContext.Output($"{container.ContainerNetworkAlias} service is healthy."); - } - } + } + } executionContext.Output("##[endgroup]"); - if (IsAnyUnhealthy) - { + if (_dockerManager.UnhealthyContainers.Count > 0) + { foreach (var container in _dockerManager.UnhealthyContainers) { executionContext.Output($"##[group]Service container {container.ContainerNetworkAlias} failed."); await ContainerErrorLogs(executionContext, container); - executionContext.Output("##[endgroup]"); + executionContext.Output("##[endgroup]"); } throw new InvalidOperationException("One or more containers failed to start."); - } + } } public void printHello()