mirror of
https://github.com/actions/runner.git
synced 2025-12-12 15:13:30 +00:00
Print service containers only if they were healthy
Unhealthy service logs are printed in ContainerHealthCheckLogs called prior to this step.
This commit is contained in:
@@ -302,14 +302,18 @@ namespace GitHub.Runner.Worker
|
|||||||
{
|
{
|
||||||
if (!container.IsJobContainer)
|
if (!container.IsJobContainer)
|
||||||
{
|
{
|
||||||
// Print logs for service container jobs (not the "action" job itself b/c that's already logged).
|
var healthcheck = await Healthcheck(executionContext, container);
|
||||||
executionContext.Output($"Print service container logs: {container.ContainerDisplayName}");
|
if (string.Equals(healthcheck, "healthy", StringComparison.OrdinalIgnoreCase)){
|
||||||
|
// Print logs for service container jobs (not the "action" job itself b/c that's already logged).
|
||||||
|
// Print them only if the service was healthy, else they were already logged via ContainerHealthCheckLogs.
|
||||||
|
executionContext.Output($"Print service container logs: {container.ContainerDisplayName}");
|
||||||
|
|
||||||
int logsExitCode = await _dockerManager.DockerLogs(executionContext, container.ContainerId);
|
int logsExitCode = await _dockerManager.DockerLogs(executionContext, container.ContainerId);
|
||||||
if (logsExitCode != 0)
|
if (logsExitCode != 0)
|
||||||
{
|
{
|
||||||
executionContext.Warning($"Docker logs fail with exit code {logsExitCode}");
|
executionContext.Warning($"Docker logs fail with exit code {logsExitCode}");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
executionContext.Output($"Stop and remove container: {container.ContainerDisplayName}");
|
executionContext.Output($"Stop and remove container: {container.ContainerDisplayName}");
|
||||||
|
|||||||
Reference in New Issue
Block a user