From 58de46d1945f16da669bf17a88e714ccd24750df Mon Sep 17 00:00:00 2001 From: Ludovic DEHON Date: Thu, 9 Nov 2023 21:34:31 +0100 Subject: [PATCH] feat(docker): add shmSize option --- .../exec/scripts/models/DockerOptions.java | 7 +++++++ .../exec/scripts/runners/DockerScriptRunner.java | 16 ++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/plugin-script/src/main/java/io/kestra/plugin/scripts/exec/scripts/models/DockerOptions.java b/plugin-script/src/main/java/io/kestra/plugin/scripts/exec/scripts/models/DockerOptions.java index 357c5a5c..aebe3c0c 100644 --- a/plugin-script/src/main/java/io/kestra/plugin/scripts/exec/scripts/models/DockerOptions.java +++ b/plugin-script/src/main/java/io/kestra/plugin/scripts/exec/scripts/models/DockerOptions.java @@ -111,6 +111,13 @@ public class DockerOptions { @PluginProperty(dynamic = false) protected Memory memory; + @Schema( + title = "Size of `/dev/shm` in bytes.", + description = "The size must be greater than 0. If omitted the system uses 64MB." + ) + @PluginProperty(dynamic = true) + private String shmSize; + @Introspected @Schema( title = "The PullPolicy for a container and the tag of the image affect when docker attempts to pull (download) the specified image." diff --git a/plugin-script/src/main/java/io/kestra/plugin/scripts/exec/scripts/runners/DockerScriptRunner.java b/plugin-script/src/main/java/io/kestra/plugin/scripts/exec/scripts/runners/DockerScriptRunner.java index e16d025b..20a07559 100644 --- a/plugin-script/src/main/java/io/kestra/plugin/scripts/exec/scripts/runners/DockerScriptRunner.java +++ b/plugin-script/src/main/java/io/kestra/plugin/scripts/exec/scripts/runners/DockerScriptRunner.java @@ -285,23 +285,19 @@ private CreateContainerCmd configure(CommandsWrapper commands, DockerClient dock } if (dockerOptions.getMemory().getMemorySwap() != null) { - hostConfig.withMemorySwap(convertBytes(runContext.render(dockerOptions.getMemory() - .getMemorySwap()))); + hostConfig.withMemorySwap(convertBytes(runContext.render(dockerOptions.getMemory().getMemorySwap()))); } if (dockerOptions.getMemory().getMemorySwappiness() != null) { - hostConfig.withMemorySwappiness(convertBytes(runContext.render(dockerOptions.getMemory() - .getMemorySwappiness()))); + hostConfig.withMemorySwappiness(convertBytes(runContext.render(dockerOptions.getMemory().getMemorySwappiness()))); } if (dockerOptions.getMemory().getMemoryReservation() != null) { - hostConfig.withMemoryReservation(convertBytes(runContext.render(dockerOptions.getMemory() - .getMemoryReservation()))); + hostConfig.withMemoryReservation(convertBytes(runContext.render(dockerOptions.getMemory().getMemoryReservation()))); } if (dockerOptions.getMemory().getKernelMemory() != null) { - hostConfig.withKernelMemory(convertBytes(runContext.render(dockerOptions.getMemory() - .getKernelMemory()))); + hostConfig.withKernelMemory(convertBytes(runContext.render(dockerOptions.getMemory().getKernelMemory()))); } if (dockerOptions.getMemory().getOomKillDisable() != null) { @@ -309,6 +305,10 @@ private CreateContainerCmd configure(CommandsWrapper commands, DockerClient dock } } + if (dockerOptions.getShmSize() != null) { + hostConfig.withShmSize(convertBytes(runContext.render(dockerOptions.getShmSize()))); + } + if (dockerOptions.getNetworkMode() != null) { hostConfig.withNetworkMode(runContext.render(dockerOptions.getNetworkMode(), additionalVars)); }