Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to override shm-size with docker plug-in #978

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
29 changes: 23 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -242,22 +242,39 @@ jobs:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Enable NuGet cache
uses: actions/cache@v3.3.1
uses: actions/cache@v3
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget


- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- name: Cache SonarCloud scanner
id: cache-sonar-scanner
uses: actions/cache@v3
with:
path: ./.sonar/scanner
key: ${{ runner.os }}-sonar-scanner
restore-keys: ${{ runner.os }}-sonar-scanner

- name: Install SonarCloud scanner
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
run: dotnet tool install --global dotnet-sonarscanner

run: |
mkdir -p ./.sonar/scanner
dotnet tool update dotnet-sonarscanner --tool-path ./.sonar/scanner

- name: Begin SonarScanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: dotnet sonarscanner begin /k:"Project-MONAI_monai-deploy-workflow-manager" /o:"project-monai" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths="../**/coverage.opencover.xml" /d:sonar.coverage.exclusions="src/WorkflowManager/Database/Repositories/**/*,src/TaskManager/Database/TaskDispatchEventRepository.cs,**/Migrations/M0*.cs"
run: ./.sonar/scanner/dotnet-sonarscanner begin /k:"Project-MONAI_monai-deploy-workflow-manager" /o:"project-monai" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths="../**/coverage.opencover.xml" /d:sonar.coverage.exclusions="src/WorkflowManager/Database/Repositories/**/*,src/TaskManager/Database/TaskDispatchEventRepository.cs,**/Migrations/M0*.cs"
working-directory: ./src

- name: Restore Solution
Expand All @@ -277,5 +294,5 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: dotnet sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
run: ./.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
working-directory: ./src
12 changes: 12 additions & 0 deletions src/TaskManager/Plug-ins/Docker/DockerPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,18 @@ private CreateContainerParameters BuildContainerSpecification(IList<ContainerVol
},
};

if (Event.TaskPluginArguments.ContainsKey(Keys.ShmSize))
{
if (long.TryParse(Event.TaskPluginArguments[Keys.ShmSize], out var shmsize))
{
parameters.HostConfig.ShmSize = shmsize;
}
else
{
_logger.InvalidShmSize(Event.TaskPluginArguments[Keys.ShmSize]);
}
}

if (Event.TaskPluginArguments.ContainsKey(Keys.User))
{
parameters.User = Event.TaskPluginArguments[Keys.User];
Expand Down
6 changes: 6 additions & 0 deletions src/TaskManager/Plug-ins/Docker/Keys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ internal static class Keys
/// </summary>
public static readonly string EnvironmentVariableKeyPrefix = "env_";

/// <summary>
/// Key for setting the shm size.
/// </summary>
public static readonly string ShmSize = "shm_size";

/// <summary>
/// Key to the intermediate volume map path.
/// </summary>
Expand All @@ -79,5 +84,6 @@ internal static class Keys
ContainerImage,
TemporaryStorageContainerPath
};

}
}
3 changes: 3 additions & 0 deletions src/TaskManager/Plug-ins/Docker/Logging/Log.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,8 @@ public static partial class Log

[LoggerMessage(EventId = 1031, Level = LogLevel.Error, Message = "Error setting directory {path} with permission {user}.")]
public static partial void ErrorSettingDirectoryPermission(this ILogger logger, string path, string user);

[LoggerMessage(EventId = 1032, Level = LogLevel.Error, Message = "Invalid size specified for /dev/shm: {size} Please use value between 1 and 9223372036854775807.")]
public static partial void InvalidShmSize(this ILogger logger, string size);
}
}
Loading