mirror of
https://github.com/actions/runner.git
synced 2025-12-13 19:03:44 +00:00
Compare commits
6 Commits
v2.289.2
...
fhammerl/d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
079ee2afef | ||
|
|
46258428cd | ||
|
|
eb9a604b63 | ||
|
|
8792d8e5ee | ||
|
|
87e86e3d72 | ||
|
|
48b6cd9a42 |
@@ -1,7 +1,11 @@
|
|||||||
## Features
|
## Features
|
||||||
|
|
||||||
## Bugs
|
## 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
|
## Windows x64
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
2.289.2
|
<Update to ./src/runnerversion when creating release>
|
||||||
|
|||||||
@@ -143,10 +143,8 @@ namespace GitHub.Runner.Common
|
|||||||
|
|
||||||
public ValueTask DisposeAsync()
|
public ValueTask DisposeAsync()
|
||||||
{
|
{
|
||||||
CloseWebSocket(WebSocketCloseStatus.NormalClosure, CancellationToken.None);
|
_websocketClient?.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, "Shutdown", CancellationToken.None);
|
||||||
|
|
||||||
GC.SuppressFinalize(this);
|
GC.SuppressFinalize(this);
|
||||||
|
|
||||||
return ValueTask.CompletedTask;
|
return ValueTask.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,8 +248,7 @@ namespace GitHub.Runner.Common
|
|||||||
if (failedAttemptsToPostBatchedLinesByWebsocket * 100 / totalBatchedLinesAttemptedByWebsocket > _minWebsocketFailurePercentageAllowed)
|
if (failedAttemptsToPostBatchedLinesByWebsocket * 100 / totalBatchedLinesAttemptedByWebsocket > _minWebsocketFailurePercentageAllowed)
|
||||||
{
|
{
|
||||||
Trace.Info($"Exhausted websocket allowed retries, we will not attempt websocket connection for this job to post lines again.");
|
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
|
// By setting it to null, we will ensure that we never try websocket path again for this job
|
||||||
_websocketClient = null;
|
_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)
|
public Task<TaskAttachment> CreateAttachmentAsync(Guid scopeIdentifier, string hubName, Guid planId, Guid timelineId, Guid timelineRecordId, string type, string name, Stream uploadStream, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
CheckConnection();
|
CheckConnection();
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ using GitHub.Runner.Sdk;
|
|||||||
|
|
||||||
namespace GitHub.Runner.Worker.Container
|
namespace GitHub.Runner.Worker.Container
|
||||||
{
|
{
|
||||||
[ServiceLocator(Default = typeof(DockerCommandManager))]
|
[ServiceLocator(Default = typeof(DockerHookCommandManager))]
|
||||||
public interface IDockerCommandManager : IRunnerService
|
public interface IDockerCommandManager : IRunnerService
|
||||||
{
|
{
|
||||||
string DockerPath { get; }
|
string DockerPath { get; }
|
||||||
@@ -188,7 +188,7 @@ namespace GitHub.Runner.Worker.Container
|
|||||||
return outputStrings.FirstOrDefault();
|
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>();
|
IList<string> dockerOptions = new List<string>();
|
||||||
// OPTIONS
|
// OPTIONS
|
||||||
@@ -258,7 +258,7 @@ namespace GitHub.Runner.Worker.Container
|
|||||||
return await ExecuteDockerCommandAsync(context, "run", optionsString, container.ContainerEnvironmentVariables, stdoutDataReceived, stderrDataReceived, context.CancellationToken);
|
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);
|
return await ExecuteDockerCommandAsync(context, "start", containerId, context.CancellationToken);
|
||||||
}
|
}
|
||||||
|
|||||||
50
src/Runner.Worker/Container/DockerHookCommandManager.cs
Normal file
50
src/Runner.Worker/Container/DockerHookCommandManager.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1 +1 @@
|
|||||||
2.289.2
|
2.289.1
|
||||||
|
|||||||
Reference in New Issue
Block a user