Skip to content

Commit

Permalink
fix: Prevent invalid negative timestamps getting container logs (#1038)
Browse files Browse the repository at this point in the history
Co-authored-by: Andre Hofmeister <[email protected]>
  • Loading branch information
mausch and HofmeisterAn authored Nov 1, 2023
1 parent 082eea4 commit 5d5cb2d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Testcontainers/Clients/DockerContainerOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ public async Task<long> GetExitCodeAsync(string id, CancellationToken ct = defau
{
ShowStdout = true,
ShowStderr = true,
Since = since.TotalSeconds.ToString("0", CultureInfo.InvariantCulture),
Until = until.TotalSeconds.ToString("0", CultureInfo.InvariantCulture),
Since = Math.Max(0, since.TotalSeconds).ToString("0", CultureInfo.InvariantCulture),
Until = Math.Max(0, until.TotalSeconds).ToString("0", CultureInfo.InvariantCulture),
Timestamps = timestampsEnabled,
};

Expand Down
4 changes: 2 additions & 2 deletions src/Testcontainers/Clients/TestcontainersClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ public Task<long> GetContainerExitCodeAsync(string id, CancellationToken ct = de

if (default(DateTime).Equals(since))
{
since = DateTime.MinValue;
since = unixEpoch;
}

if (default(DateTime).Equals(until))
{
until = DateTime.MaxValue;
until = unixEpoch;
}

return Container.GetLogsAsync(id, since.ToUniversalTime().Subtract(unixEpoch), until.ToUniversalTime().Subtract(unixEpoch), timestampsEnabled, ct);
Expand Down

0 comments on commit 5d5cb2d

Please sign in to comment.