Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Include container runtime name in error messages
- Updated error log and exception messages to include container runtime name
- Changed from "Container runtime is not running" to "Container runtime '{name}' is not running"
- Updated test assertions to match new error message format
- Improves error diagnostics by showing which runtime (docker/podman) is being checked

Co-authored-by: captainsafia <1857993+captainsafia@users.noreply.github.com>
  • Loading branch information
2 people authored and github-actions committed Dec 16, 2025
commit f6d99b9312c4d3dfd43b412cfd578fa55c61dddb
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
public string? OutputPath { get; set; }
public ContainerImageFormat? ImageFormat { get; set; }
public ContainerTargetPlatform? TargetPlatform { get; set; }
public ContainerImageDestination? Destination { get; set; }

Check failure on line 153 in src/Aspire.Hosting/Publishing/ResourceContainerImageManager.cs

View workflow job for this annotation

GitHub Actions / Tests / Setup for tests (Windows)

The type or namespace name 'ContainerImageDestination' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 153 in src/Aspire.Hosting/Publishing/ResourceContainerImageManager.cs

View workflow job for this annotation

GitHub Actions / Tests / Setup for tests (Windows)

The type or namespace name 'ContainerImageDestination' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 153 in src/Aspire.Hosting/Publishing/ResourceContainerImageManager.cs

View workflow job for this annotation

GitHub Actions / Tests / Setup for tests (Linux)

The type or namespace name 'ContainerImageDestination' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 153 in src/Aspire.Hosting/Publishing/ResourceContainerImageManager.cs

View workflow job for this annotation

GitHub Actions / Tests / Setup for tests (Linux)

The type or namespace name 'ContainerImageDestination' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 153 in src/Aspire.Hosting/Publishing/ResourceContainerImageManager.cs

View workflow job for this annotation

GitHub Actions / Tests / Setup for tests (macOS)

The type or namespace name 'ContainerImageDestination' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 153 in src/Aspire.Hosting/Publishing/ResourceContainerImageManager.cs

View workflow job for this annotation

GitHub Actions / Tests / Setup for tests (macOS)

The type or namespace name 'ContainerImageDestination' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 153 in src/Aspire.Hosting/Publishing/ResourceContainerImageManager.cs

View check run for this annotation

Azure Pipelines / dotnet.aspire (Build Linux)

src/Aspire.Hosting/Publishing/ResourceContainerImageManager.cs#L153

src/Aspire.Hosting/Publishing/ResourceContainerImageManager.cs(153,16): error CS0246: (NETCORE_ENGINEERING_TELEMETRY=Build) The type or namespace name 'ContainerImageDestination' could not be found (are you missing a using directive or an assembly reference?)
public string LocalImageName { get; set; } = string.Empty;
public string LocalImageTag { get; set; } = "latest";
}
Expand Down Expand Up @@ -194,8 +194,8 @@

if (!containerRuntimeHealthy)
{
logger.LogError("Container runtime is not running or is unhealthy. Cannot build container images.");
throw new InvalidOperationException("Container runtime is not running or is unhealthy.");
logger.LogError("Container runtime '{ContainerRuntimeName}' is not running or is unhealthy. Cannot build container images.", ContainerRuntime.Name);
throw new InvalidOperationException($"Container runtime '{ContainerRuntime.Name}' is not running or is unhealthy.");
}

logger.LogDebug("{ContainerRuntimeName} is healthy", ContainerRuntime.Name);
Expand Down Expand Up @@ -225,8 +225,8 @@

if (!containerRuntimeHealthy)
{
logger.LogError("Container runtime is not running or is unhealthy. Cannot build container image.");
throw new InvalidOperationException("Container runtime is not running or is unhealthy.");
logger.LogError("Container runtime '{ContainerRuntimeName}' is not running or is unhealthy. Cannot build container image.", ContainerRuntime.Name);
throw new InvalidOperationException($"Container runtime '{ContainerRuntime.Name}' is not running or is unhealthy.");
}

logger.LogDebug("{ContainerRuntimeName} is healthy", ContainerRuntime.Name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -616,12 +616,13 @@ public async Task BuildImageAsync_ThrowsInvalidOperationException_WhenDockerRunt
var exception = await Assert.ThrowsAsync<InvalidOperationException>(() =>
imageBuilder.BuildImagesAsync([container.Resource], cts.Token));

Assert.Equal("Container runtime is not running or is unhealthy.", exception.Message);
Assert.Contains("Container runtime", exception.Message);
Assert.Contains("is not running or is unhealthy", exception.Message);

var collector = app.Services.GetFakeLogCollector();
var logs = collector.GetSnapshot();

Assert.Contains(logs, log => log.Message.Contains("Container runtime is not running or is unhealthy. Cannot build container images."));
Assert.Contains(logs, log => log.Message.Contains("is not running or is unhealthy. Cannot build container images."));
}

[Fact]
Expand Down Expand Up @@ -1163,7 +1164,7 @@ public async Task BuildImagesAsync_WithRegistryDestination_ChecksContainerRuntim
var exception = await Assert.ThrowsAsync<InvalidOperationException>(
() => imageManager.BuildImagesAsync([servicea.Resource], cts.Token));

Assert.Contains("Container runtime is not running or is unhealthy", exception.Message);
Assert.Contains("is not running or is unhealthy", exception.Message);

// Verify CheckIfRunningAsync was called in the upfront check
Assert.Equal(1, fakeContainerRuntime.CheckIfRunningCallCount);
Expand Down Expand Up @@ -1196,7 +1197,7 @@ public async Task BuildImageAsync_DockerfileResource_RequiresContainerRuntime()
var exception = await Assert.ThrowsAsync<InvalidOperationException>(
() => imageManager.BuildImageAsync(container.Resource, cts.Token));

Assert.Contains("Container runtime is not running or is unhealthy", exception.Message);
Assert.Contains("is not running or is unhealthy", exception.Message);

// Verify CheckIfRunningAsync was called in BuildImageAsync
Assert.Equal(1, fakeContainerRuntime.CheckIfRunningCallCount);
Expand Down Expand Up @@ -1239,7 +1240,7 @@ public async Task BuildImagesAsync_MixedDestinations_ChecksRuntimeWhenAnyResourc
var exception = await Assert.ThrowsAsync<InvalidOperationException>(
() => imageManager.BuildImagesAsync([servicea.Resource, serviceb.Resource], cts.Token));

Assert.Contains("Container runtime is not running or is unhealthy", exception.Message);
Assert.Contains("is not running or is unhealthy", exception.Message);

// Verify CheckIfRunningAsync was called once for the entire batch
Assert.Equal(1, fakeContainerRuntime.CheckIfRunningCallCount);
Expand Down Expand Up @@ -1272,7 +1273,7 @@ public async Task BuildImagesAsync_NoDestinationSet_ChecksContainerRuntime()
var exception = await Assert.ThrowsAsync<InvalidOperationException>(
() => imageManager.BuildImagesAsync([servicea.Resource], cts.Token));

Assert.Contains("Container runtime is not running or is unhealthy", exception.Message);
Assert.Contains("is not running or is unhealthy", exception.Message);

// Verify CheckIfRunningAsync was called
Assert.Equal(1, fakeContainerRuntime.CheckIfRunningCallCount);
Expand Down
Loading