Skip to content

Commit

Permalink
[#242] #REMOVE 'assemblyName: DotNet.Testcontainers; function: PurgeO…
Browse files Browse the repository at this point in the history
…rphanedContainersArgs'

{Remove PurgeOrphanedContainersArgs.}
  • Loading branch information
HofmeisterAn committed Feb 19, 2021
1 parent 464f147 commit 98b0747
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 97 deletions.
2 changes: 1 addition & 1 deletion build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Task("Tests")
Verbosity = param.Verbosity,
NoRestore = true,
NoBuild = true,
Logger = "trx",
Loggers = new[] { "trx" },
Filter = param.TestFilter,
ResultsDirectory = param.Paths.Directories.TestResults,
ArgumentCustomization = args => args
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion src/DotNet.Testcontainers/Clients/DockerApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ internal abstract class DockerApiClient
private static readonly ConcurrentDictionary<Uri, IDockerClient> Clients = new ConcurrentDictionary<Uri, IDockerClient>();

protected DockerApiClient(Uri endpoint) : this(
Clients.GetOrAdd(endpoint, key => new DockerClientConfiguration(endpoint).CreateClient()))
Clients.GetOrAdd(endpoint, _ => new DockerClientConfiguration(endpoint).CreateClient()))
{
}

Expand Down
41 changes: 0 additions & 41 deletions src/DotNet.Testcontainers/Clients/PurgeOrphanedContainersArgs.cs

This file was deleted.

13 changes: 1 addition & 12 deletions src/DotNet.Testcontainers/Clients/TestcontainersClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ internal sealed class TestcontainersClient : ITestcontainersClient
this.containers = containerOperations;
this.images = imageOperations;
this.system = systemOperations;

AppDomain.CurrentDomain.ProcessExit += this.PurgeOrphanedContainers;
Console.CancelKeyPress += this.PurgeOrphanedContainers;
}

~TestcontainersClient()
Expand All @@ -73,8 +70,6 @@ public bool IsRunningInsideDocker

public void Dispose()
{
AppDomain.CurrentDomain.ProcessExit -= this.PurgeOrphanedContainers;
Console.CancelKeyPress -= this.PurgeOrphanedContainers;
GC.SuppressFinalize(this);
}

Expand Down Expand Up @@ -125,7 +120,7 @@ await this.containers.RemoveAsync(id, ct)
}
catch (DockerApiException e)
{
// The Docker daemon may already start the progress to remove the container (AutoRemove).
// The Docker daemon may already start the progress to removes the container (AutoRemove).
// https://docs.docker.com/engine/api/v1.41/#operation/ContainerCreate.
if (!e.Message.Contains($"removal of container {id} is already in progress"))
{
Expand Down Expand Up @@ -199,11 +194,5 @@ public Task<string> BuildAsync(IImageFromDockerfileConfiguration configuration,
{
return this.images.BuildAsync(configuration, ct);
}

private void PurgeOrphanedContainers(object sender, EventArgs args)
{
var arguments = new PurgeOrphanedContainersArgs(this.endpoint, this.registryService.GetRegisteredContainers());
_ = new Process { StartInfo = { FileName = "docker", Arguments = arguments.ToString() } }.Start();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ await Task.WhenAll(attachTask, startTask)
await this.configuration.StartupCallback(this, ct)
.ConfigureAwait(false);

// Do not use a to small frequency. Especially with a lot of containers,
// Do not use a too small frequency. Especially with a lot of containers,
// we send many operations to the Docker endpoint. The endpoint may cancel operations.
foreach (var waitStrategy in this.configuration.WaitStrategies)
{
Expand Down

0 comments on commit 98b0747

Please sign in to comment.