Remove unnecessary 'IsAnyUnhealthy' flag

This commit is contained in:
JoannaaKL
2022-09-13 12:44:22 +00:00
parent 76e4f51a21
commit 912d7d6932

View File

@@ -100,14 +100,14 @@ namespace GitHub.Runner.Worker
} }
executionContext.Output("##[group]Waiting for all services to be ready"); executionContext.Output("##[group]Waiting for all services to be ready");
bool IsAnyUnhealthy = false;
_dockerManager.UnhealthyContainers = new List<ContainerInfo>(); _dockerManager.UnhealthyContainers = new List<ContainerInfo>();
foreach (var container in containers.Where(c => !c.IsJobContainer)) foreach (var container in containers.Where(c => !c.IsJobContainer))
{ {
var healthcheck = await Healthcheck(executionContext, container); var healthcheck = await Healthcheck(executionContext, container);
if (!string.Equals(healthcheck, "healthy", StringComparison.OrdinalIgnoreCase)) if (!string.Equals(healthcheck, "healthy", StringComparison.OrdinalIgnoreCase))
{ {
IsAnyUnhealthy = true;
_dockerManager.UnhealthyContainers.Add(container); _dockerManager.UnhealthyContainers.Add(container);
} }
else else
@@ -117,7 +117,7 @@ namespace GitHub.Runner.Worker
} }
executionContext.Output("##[endgroup]"); executionContext.Output("##[endgroup]");
if (IsAnyUnhealthy) if (_dockerManager.UnhealthyContainers.Count > 0)
{ {
foreach (var container in _dockerManager.UnhealthyContainers) foreach (var container in _dockerManager.UnhealthyContainers)
{ {