mirror of
https://github.com/actions/runner.git
synced 2025-12-12 15:13:30 +00:00
Add message size in chars and bytes (#1100)
* Add message size in chars and bytes * Log hash of message body
This commit is contained in:
@@ -3,6 +3,7 @@ using System.IO;
|
|||||||
using System.IO.Pipes;
|
using System.IO.Pipes;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using GitHub.Runner.Sdk;
|
||||||
|
|
||||||
namespace GitHub.Runner.Common
|
namespace GitHub.Runner.Common
|
||||||
{
|
{
|
||||||
@@ -68,6 +69,7 @@ namespace GitHub.Runner.Common
|
|||||||
|
|
||||||
public async Task SendAsync(MessageType messageType, string body, CancellationToken cancellationToken)
|
public async Task SendAsync(MessageType messageType, string body, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
|
Trace.Info($"Sending message of length {body.Length}, with hash '{IOUtil.GetSha256Hash(body)}'");
|
||||||
await _writeStream.WriteInt32Async((int)messageType, cancellationToken);
|
await _writeStream.WriteInt32Async((int)messageType, cancellationToken);
|
||||||
await _writeStream.WriteStringAsync(body, cancellationToken);
|
await _writeStream.WriteStringAsync(body, cancellationToken);
|
||||||
}
|
}
|
||||||
@@ -77,6 +79,7 @@ namespace GitHub.Runner.Common
|
|||||||
WorkerMessage result = new WorkerMessage(MessageType.NotInitialized, string.Empty);
|
WorkerMessage result = new WorkerMessage(MessageType.NotInitialized, string.Empty);
|
||||||
result.MessageType = (MessageType)await _readStream.ReadInt32Async(cancellationToken);
|
result.MessageType = (MessageType)await _readStream.ReadInt32Async(cancellationToken);
|
||||||
result.Body = await _readStream.ReadStringAsync(cancellationToken);
|
result.Body = await _readStream.ReadStringAsync(cancellationToken);
|
||||||
|
Trace.Info($"Receiving message of length {result.Body.Length}, with hash '{IOUtil.GetSha256Hash(result.Body)}'");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ namespace GitHub.Runner.Listener.Configuration
|
|||||||
|
|
||||||
public string GetUniqueRunnerGroupName()
|
public string GetUniqueRunnerGroupName()
|
||||||
{
|
{
|
||||||
return RunnerServiceLocalGroupPrefix + IOUtil.GetPathHash(HostContext.GetDirectory(WellKnownDirectory.Bin)).Substring(0, 5);
|
return RunnerServiceLocalGroupPrefix + IOUtil.GetSha256Hash(HostContext.GetDirectory(WellKnownDirectory.Bin)).Substring(0, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool LocalGroupExists(string groupName)
|
public bool LocalGroupExists(string groupName)
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ namespace GitHub.Runner.Sdk
|
|||||||
return StringUtil.ConvertFromJson<T>(json);
|
return StringUtil.ConvertFromJson<T>(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetPathHash(string path)
|
public static string GetSha256Hash(string path)
|
||||||
{
|
{
|
||||||
string hashString = path.ToLowerInvariant();
|
string hashString = path.ToLowerInvariant();
|
||||||
using (SHA256 sha256hash = SHA256.Create())
|
using (SHA256 sha256hash = SHA256.Create())
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ namespace GitHub.Runner.Worker.Container
|
|||||||
{
|
{
|
||||||
base.Initialize(hostContext);
|
base.Initialize(hostContext);
|
||||||
DockerPath = WhichUtil.Which("docker", true, Trace);
|
DockerPath = WhichUtil.Which("docker", true, Trace);
|
||||||
DockerInstanceLabel = IOUtil.GetPathHash(hostContext.GetDirectory(WellKnownDirectory.Root)).Substring(0, 6);
|
DockerInstanceLabel = IOUtil.GetSha256Hash(hostContext.GetDirectory(WellKnownDirectory.Root)).Substring(0, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<DockerVersion> DockerVersion(IExecutionContext context)
|
public async Task<DockerVersion> DockerVersion(IExecutionContext context)
|
||||||
|
|||||||
Reference in New Issue
Block a user