Skip to content

Commit

Permalink
feat(#694): Add Resource Reaper (Ryuk) privileged mode support (#710)
Browse files Browse the repository at this point in the history
  • Loading branch information
HofmeisterAn committed Dec 12, 2022
1 parent 8db93b2 commit 29367a8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
- 531 Add Docker health status wait strategy (@kfrajtak)
- 640 Add `ITestcontainersBuilder<TDockerContainer>.WithResourceMapping` to copy files or or any binary contents into the created container even before it is started
- 654 Add `ITestcontainersNetworkBuilder.WithOption` (@vlaskal)
- 678 Add support of custom configuration `TESTCONTAINERS_HOST_OVERRIDE` and `TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE`.
- 678 Add support of custom configuration `TESTCONTAINERS_HOST_OVERRIDE` and `TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE`
- 694 Add Resource Reaper (Ryuk) privileged mode support (`TESTCONTAINERS_RYUK_CONTAINER_PRIVILEGED`)

### Changed

Expand Down
7 changes: 7 additions & 0 deletions src/Testcontainers/Configurations/TestcontainersSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@ static TestcontainersSettings()
public static bool ResourceReaperEnabled { get; set; }
= !PropertiesFileConfiguration.Instance.GetRyukDisabled() && !EnvironmentConfiguration.Instance.GetRyukDisabled();

/// <summary>
/// Gets or sets a value indicating whether the <see cref="ResourceReaper" /> privileged mode is enabled or not.
/// </summary>
[PublicAPI]
public static bool ResourceReaperPrivilegedModeEnabled { get; set; }
= PropertiesFileConfiguration.Instance.GetRyukContainerPrivileged() || EnvironmentConfiguration.Instance.GetRyukContainerPrivileged();

/// <summary>
/// Gets or sets the <see cref="ResourceReaper" /> image.
/// </summary>
Expand Down
5 changes: 4 additions & 1 deletion src/Testcontainers/Containers/ResourceReaper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ private ResourceReaper(Guid sessionId, IDockerEndpointAuthenticationConfiguratio
.WithName($"testcontainers-ryuk-{sessionId:D}")
.WithDockerEndpoint(dockerEndpointAuthConfig)
.WithImage(resourceReaperImage)
.WithPrivileged(requiresPrivilegedMode)
.WithAutoRemove(true)
.WithCleanUp(false)
.WithExposedPort(RyukPort)
Expand Down Expand Up @@ -131,7 +132,9 @@ await DefaultLock.WaitAsync(ct)

var resourceReaperImage = TestcontainersSettings.ResourceReaperImage ?? RyukImage;

defaultInstance = await GetAndStartNewAsync(DefaultSessionId, dockerEndpointAuthConfig, resourceReaperImage, UnixSocketMount.Instance, ct: ct)
var requiresPrivilegedMode = TestcontainersSettings.ResourceReaperPrivilegedModeEnabled;

defaultInstance = await GetAndStartNewAsync(DefaultSessionId, dockerEndpointAuthConfig, resourceReaperImage, UnixSocketMount.Instance, requiresPrivilegedMode, ct: ct)
.ConfigureAwait(false);

return defaultInstance;
Expand Down

0 comments on commit 29367a8

Please sign in to comment.