Skip to content

Resolved an issue in DockerRuntime where it failed to check for the presence of the image locally, resulting in the image not being pulled when necessary. #503

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/runtime/Synapse.Runtime.Docker/Services/DockerRuntime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
using Docker.DotNet.Models;
using Microsoft.Extensions.DependencyInjection;
using Synapse.Runtime.Services;
using static Synapse.SynapseDefaults.Resources;
using System.Net;

namespace Synapse.Runtime.Docker.Services;

Expand Down Expand Up @@ -76,8 +78,20 @@ public override async Task<IWorkflowProcess> CreateProcessAsync(Workflow workflo
try
{
this.Logger.LogDebug("Creating a new Docker container for workflow instance '{workflowInstance}'...", workflowInstance.GetQualifiedName());
if (this.Docker == null) await this.InitializeAsync(cancellationToken).ConfigureAwait(false);
if (this.Docker == null) await this.InitializeAsync(cancellationToken).ConfigureAwait(false);
var container = this.Runner.Runtime.Docker!.ContainerTemplate.Clone()!;
try
{
await this.Docker!.Images.InspectImageAsync(container.Image, cancellationToken).ConfigureAwait(false);
}
catch (DockerApiException ex) when (ex.StatusCode == HttpStatusCode.NotFound)
{
var downloadProgress = new Progress<JSONMessage>();
var imageComponents = container.Image.Split(':');
var imageName = imageComponents[0];
var imageTag = imageComponents.Length > 1 ? imageComponents[1] : null;
await this.Docker!.Images.CreateImageAsync(new() { FromImage = imageName, Tag = imageTag }, new(), downloadProgress, cancellationToken).ConfigureAwait(false);
}
container.SetEnvironmentVariable(SynapseDefaults.EnvironmentVariables.Runner.Namespace, workflowInstance.GetNamespace()!);
container.SetEnvironmentVariable(SynapseDefaults.EnvironmentVariables.Runner.Name, $"{workflowInstance.GetName()}-{Guid.NewGuid().ToString("N")[..12].ToLowerInvariant()}");
container.SetEnvironmentVariable(SynapseDefaults.EnvironmentVariables.Api.Uri, this.Runner.Api.Uri.OriginalString);
Expand Down