Skip to content

Commit 6d9bc18

Browse files
committed
fix(Solution): Minor fixes and improvements
Signed-off-by: Charles d'Avernas <[email protected]>
1 parent f2ace89 commit 6d9bc18

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/runner/Synapse.Runner/Services/Executors/ContainerProcessExecutor.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ namespace Synapse.Runner.Services.Executors;
2424
/// <param name="context">The current <see cref="ITaskExecutionContext"/></param>
2525
/// <param name="schemaHandlerProvider">The service used to provide <see cref="ISchemaHandler"/> implementations</param>
2626
/// <param name="serializer">The service used to serialize/deserialize objects to/from JSON</param>
27-
public class ContainerProcessExecutor(IServiceProvider serviceProvider, ILogger<ContainerProcessExecutor> logger, ITaskExecutionContextFactory executionContextFactory, ITaskExecutorFactory executorFactory, IContainerPlatform containers, ITaskExecutionContext<RunTaskDefinition> context, ISchemaHandlerProvider schemaHandlerProvider, IJsonSerializer serializer)
27+
/// <param name="options">The service used to access the current <see cref="RunnerOptions"/></param>
28+
public class ContainerProcessExecutor(IServiceProvider serviceProvider, ILogger<ContainerProcessExecutor> logger, ITaskExecutionContextFactory executionContextFactory, ITaskExecutorFactory executorFactory,
29+
IContainerPlatform containers, ITaskExecutionContext<RunTaskDefinition> context, ISchemaHandlerProvider schemaHandlerProvider, IJsonSerializer serializer, IOptions<RunnerOptions> options)
2830
: TaskExecutor<RunTaskDefinition>(serviceProvider, logger, executionContextFactory, executorFactory, context, schemaHandlerProvider, serializer)
2931
{
3032

@@ -38,6 +40,11 @@ public class ContainerProcessExecutor(IServiceProvider serviceProvider, ILogger<
3840
/// </summary>
3941
protected ContainerProcessDefinition ProcessDefinition => this.Task.Definition.Run.Container!;
4042

43+
/// <summary>
44+
/// Gets the current <see cref="RunnerOptions"/>
45+
/// </summary>
46+
protected RunnerOptions Options { get; } = options.Value;
47+
4148
/// <summary>
4249
/// Gets the <see cref="IContainer"/> to run
4350
/// </summary>
@@ -57,6 +64,7 @@ protected override async Task DoExecuteAsync(CancellationToken cancellationToken
5764
await this.Container!.StartAsync(cancellationToken).ConfigureAwait(false);
5865
await this.Container.WaitForExitAsync(cancellationToken).ConfigureAwait(false);
5966
var standardOutput = (this.Container.StandardOutput == null ? null : await this.Container.StandardOutput.ReadToEndAsync(cancellationToken).ConfigureAwait(false))?.Trim();
67+
if (this.Options.Containers.Platform == ContainerPlatform.Docker) standardOutput = standardOutput?[8..];
6068
var standardError = (this.Container.StandardError == null ? null : await this.Container.StandardError.ReadToEndAsync(cancellationToken).ConfigureAwait(false))?.Trim();
6169
var result = standardOutput; //todo: do something with return data encoding (ex: plain-text, json);
6270
await this.SetResultAsync(result, this.Task.Definition.Then, cancellationToken).ConfigureAwait(false);

src/runtime/Synapse.Runtime.Kubernetes/Services/KubernetesWorkflowProcess.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,10 @@ protected virtual async Task WaitForReadyAsync(CancellationToken cancellationTok
123123
/// <inheritdoc/>
124124
public virtual async Task WaitForExitAsync(CancellationToken cancellationToken = default)
125125
{
126-
var response = this.Kubernetes.CoreV1.ListNamespacedPodWithHttpMessagesAsync(this.Pod.Namespace(), fieldSelector: $"metadata.name={Pod.Name()}", cancellationToken: cancellationToken);
126+
var response = this.Kubernetes.CoreV1.ListNamespacedPodWithHttpMessagesAsync(this.Pod.Namespace(), fieldSelector: $"metadata.name={Pod.Name()}", watch: true, cancellationToken: cancellationToken);
127127
await foreach (var (_, item) in response.WatchAsync<V1Pod, V1PodList>(cancellationToken: cancellationToken).ConfigureAwait(false))
128128
{
129-
if (item.Status.Phase != "Succeeded" || item.Status.Phase != "Failed") continue;
129+
if (item.Status.Phase != "Succeeded" && item.Status.Phase != "Failed") continue;
130130
var containerStatus = item.Status.ContainerStatuses.FirstOrDefault();
131131
this._exitCode = containerStatus?.State.Terminated?.ExitCode ?? -1;
132132
break;

0 commit comments

Comments
 (0)