Docker.DotNet
Docker.DotNet copied to clipboard
GetContainerLogsAsync with cancellation token and progress monitor throws IOException when canceled
Output of dotnet --info:
.NET SDK (reflecting any global.json):
Version: 5.0.202
Commit: db7cc87d51
Runtime Environment:
OS Name: arch
OS Version:
OS Platform: Linux
RID: arch-x64
Base Path: /usr/share/dotnet/sdk/5.0.202/
Host (useful for support):
Version: 5.0.5
Commit: 2f740adc14
.NET SDKs installed:
3.1.114 [/usr/share/dotnet/sdk]
5.0.202 [/usr/share/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 3.1.14 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.5 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.2.8 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.14 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.5 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-download
What version of Docker.DotNet?:
3.125.4
Steps to reproduce the issue:
- Use the GetContainerLogsAsync method with an progress
and a cancellation token - Cancel the token at some point in the report delegate
var progress = new Progress<string>(message => {
if (message.Contains("listening on"))
{
cancellation.Cancel();
}
});
try
{
await _dockerClient.Containers.GetContainerLogsAsync(_containerId,
new ContainerLogsParameters {Follow = true, ShowStderr = true, ShowStdout = true},
cancellation.Token, progress);
}
What actually happened?: IOException was thrown, wrapping a SocketException:
What did you expect to happen?:
OperationCanceledException should be thrown with message Unable to read data from the transport connection: Operation canceled.
Additional information:
stack trace:
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.GetResult(Int16 token)
at System.Threading.Tasks.ValueTask`1.ValueTaskSourceAsTask.<>c.<.cctor>b__4_0(Object state)
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.Net.Http.Client.BufferedReadStream.EnsureBufferedAsync(CancellationToken cancel)
at Microsoft.Net.Http.Client.BufferedReadStream.ReadLineAsync(CancellationToken cancel)
at Microsoft.Net.Http.Client.ChunkedReadStream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)
at System.IO.StreamReader.ReadBufferAsync(CancellationToken cancellationToken)
at System.IO.StreamReader.ReadLineAsyncInternal()
at Docker.DotNet.Models.StreamUtil.MonitorStreamAsync(Task`1 streamTask, DockerClient client, CancellationToken cancel, IProgress`1 progress)
at Com.Chimerys.Service.Accounting.Test.Postgres.Postgres.WaitForPostgresToStartListeningWithProgress() in /home/hannes/apollo/chimerys/services/accounting/test/Com.Chimerys.Service.Accounting.Test/Postgres/Postgres.cs:line 104
Did you try this with the current repository code? I believe this was solved, but nuget package wasn't updated then
Fixed in Release v3.125.5
@galvesribeiro This issue looks fixed. I think we can close it.