Skip to content

Commit

Permalink
Ability to override shmsize with docker plug-in
Browse files Browse the repository at this point in the history
Signed-off-by: Victor Chang <[email protected]>
  • Loading branch information
mocsharp committed Apr 4, 2024
1 parent a818376 commit 356a427
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
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);
}
}

0 comments on commit 356a427

Please sign in to comment.