Compare commits

..

6 Commits

Author SHA1 Message Date
Ferenc Hammerl
079ee2afef Use hardcoded docker override 2022-03-22 06:35:11 -07:00
Thomas Boop
46258428cd 2.289.1 release notes (#1771) 2022-03-18 14:22:24 -04:00
Thomas Boop
eb9a604b63 Revert "Added repository name and workflow file name to console output (#1761)" (#1770)
98aa9c1152
2022-03-18 14:09:01 -04:00
Thomas Boop
8792d8e5ee cleanup message displayed on job started/completed hooks (#1769) 2022-03-18 14:08:50 -04:00
Thomas Boop
87e86e3d72 2.289.0 release notes (#1766) 2022-03-18 16:12:50 +01:00
Thomas Boop
48b6cd9a42 Update dependencies to latest versions (#1756) 2022-03-17 23:21:35 -04:00
6 changed files with 62 additions and 24 deletions

View File

@@ -1,7 +1,11 @@
## Features
## Bugs
- Fixed an issue where websockets failed to successfully close when posting log lines (#1790)
- Fixed a crash on runner startup (#1770)
## Misc
- Clarified the type of step running when running job started or completed hooks (#1769)
## Windows x64

View File

@@ -1 +1 @@
2.289.2
<Update to ./src/runnerversion when creating release>

View File

@@ -143,10 +143,8 @@ namespace GitHub.Runner.Common
public ValueTask DisposeAsync()
{
CloseWebSocket(WebSocketCloseStatus.NormalClosure, CancellationToken.None);
_websocketClient?.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, "Shutdown", CancellationToken.None);
GC.SuppressFinalize(this);
return ValueTask.CompletedTask;
}
@@ -250,8 +248,7 @@ namespace GitHub.Runner.Common
if (failedAttemptsToPostBatchedLinesByWebsocket * 100 / totalBatchedLinesAttemptedByWebsocket > _minWebsocketFailurePercentageAllowed)
{
Trace.Info($"Exhausted websocket allowed retries, we will not attempt websocket connection for this job to post lines again.");
CloseWebSocket(WebSocketCloseStatus.InternalServerError, cancellationToken);
_websocketClient?.CloseOutputAsync(WebSocketCloseStatus.InternalServerError, "Shutdown due to failures", cancellationToken);
// By setting it to null, we will ensure that we never try websocket path again for this job
_websocketClient = null;
}
@@ -279,19 +276,6 @@ namespace GitHub.Runner.Common
}
}
private void CloseWebSocket(WebSocketCloseStatus closeStatus, CancellationToken cancellationToken)
{
try
{
_websocketClient?.CloseOutputAsync(closeStatus, "Closing websocket", cancellationToken);
}
catch (Exception websocketEx)
{
// In some cases this might be okay since the websocket might be open yet, so just close and don't trace exceptions
Trace.Info($"Failed to close websocket gracefully {websocketEx.GetType().Name}");
}
}
public Task<TaskAttachment> CreateAttachmentAsync(Guid scopeIdentifier, string hubName, Guid planId, Guid timelineId, Guid timelineRecordId, string type, string name, Stream uploadStream, CancellationToken cancellationToken)
{
CheckConnection();

View File

@@ -11,7 +11,7 @@ using GitHub.Runner.Sdk;
namespace GitHub.Runner.Worker.Container
{
[ServiceLocator(Default = typeof(DockerCommandManager))]
[ServiceLocator(Default = typeof(DockerHookCommandManager))]
public interface IDockerCommandManager : IRunnerService
{
string DockerPath { get; }
@@ -188,7 +188,7 @@ namespace GitHub.Runner.Worker.Container
return outputStrings.FirstOrDefault();
}
public async Task<int> DockerRun(IExecutionContext context, ContainerInfo container, EventHandler<ProcessDataReceivedEventArgs> stdoutDataReceived, EventHandler<ProcessDataReceivedEventArgs> stderrDataReceived)
public virtual async Task<int> DockerRun(IExecutionContext context, ContainerInfo container, EventHandler<ProcessDataReceivedEventArgs> stdoutDataReceived, EventHandler<ProcessDataReceivedEventArgs> stderrDataReceived)
{
IList<string> dockerOptions = new List<string>();
// OPTIONS
@@ -258,7 +258,7 @@ namespace GitHub.Runner.Worker.Container
return await ExecuteDockerCommandAsync(context, "run", optionsString, container.ContainerEnvironmentVariables, stdoutDataReceived, stderrDataReceived, context.CancellationToken);
}
public async Task<int> DockerStart(IExecutionContext context, string containerId)
public virtual async Task<int> DockerStart(IExecutionContext context, string containerId)
{
return await ExecuteDockerCommandAsync(context, "start", containerId, context.CancellationToken);
}

View File

@@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using GitHub.DistributedTask.Pipelines;
using GitHub.Runner.Common.Util;
using GitHub.Runner.Worker.Handlers;
namespace GitHub.Runner.Worker.Container
{
public class DockerHookCommandManager : DockerCommandManager
{
public override async Task<int> DockerStart(IExecutionContext context, string containerId)
{
// check for env var
// execute script
// Create the handler data.
var path = "/home/ferenc/Documents/runner/_layout/docker_run.sh";
var scriptDirectory = Path.GetDirectoryName(path);
var stepHost = HostContext.CreateService<IDefaultStepHost>();
var prependPath = string.Join(Path.PathSeparator.ToString(), context.Global.PrependPath.Reverse<string>());
Dictionary<string, string> inputs = new()
{
["script"] = $"CONT_ID={containerId} " + "/usr/bin/bash" + " " + path,
// /bin/bash
["shell"] = ScriptHandlerHelpers.GetDefaultShellForScript(path, Trace, prependPath)
};
// Create the handler
var handlerFactory = HostContext.GetService<IHandlerFactory>();
var handler = handlerFactory.Create(
context,
action: new ScriptReference(),
stepHost,
new ScriptActionExecutionData(),
inputs,
environment: new Dictionary<string, string>(VarUtil.EnvironmentVariableKeyComparer),
context.Global.Variables,
actionDirectory: scriptDirectory,
localActionContainerSetupSteps: null);
handler.PrepareExecution(ActionRunStage.Main); // TODO: find out stage
await handler.RunAsync(ActionRunStage.Main);
return ((int?) handler.ExecutionContext.CommandResult) ?? 0;
}
}
}

View File

@@ -1 +1 @@
2.289.2
2.289.1