From 13e58805e80ade21a6dd14a8efebbb687cdc2e34 Mon Sep 17 00:00:00 2001 From: Tobias Gesellchen Date: Tue, 6 Feb 2024 23:15:27 +0100 Subject: [PATCH] Read healthcheck "start_interval" in docker compose/stack config Relates to https://github.com/docker-client/docker-compose-v3/pull/392 --- .../client/stack/DeployConfigReader.groovy | 31 +++++++------------ .../stack/DeployConfigReaderTest.groovy | 8 +++-- 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/client/src/main/groovy/de/gesellix/docker/client/stack/DeployConfigReader.groovy b/client/src/main/groovy/de/gesellix/docker/client/stack/DeployConfigReader.groovy index 185c2f95..0bf7ffaf 100644 --- a/client/src/main/groovy/de/gesellix/docker/client/stack/DeployConfigReader.groovy +++ b/client/src/main/groovy/de/gesellix/docker/client/stack/DeployConfigReader.groovy @@ -346,8 +346,7 @@ class DeployConfigReader { if (networkConfig?.external?.external) { if (networkConfig?.external?.name) { return networkConfig.external.name - } - else { + } else { return networkName } } @@ -403,10 +402,9 @@ class DeployConfigReader { if (healthcheck.startPeriod) { startPeriod = parseDuration(healthcheck.startPeriod).toNanos() } - // TODO add this one -// if (healthcheck.startInterval) { -// startInterval = parseDuration(healthcheck.startInterval).toNanos() -// } + if (healthcheck.startInterval) { + startInterval = parseDuration(healthcheck.startInterval).toNanos() + } return new HealthConfig( healthcheck.test.parts, @@ -504,8 +502,7 @@ class DeployConfigReader { default: throw new IllegalArgumentException("unknown restart policy: ${restart}") } - } - else { + } else { Long delay = null if (restartPolicy.delay) { delay = parseDuration(restartPolicy.delay).toNanos() @@ -564,8 +561,7 @@ class DeployConfigReader { if (limits.nanoCpus.contains('/')) { // TODO throw new UnsupportedOperationException("not supported, yet") - } - else { + } else { return new Limit( (parseDouble(limits.nanoCpus) * nanoMultiplier).longValue(), parseLong(limits.memory), @@ -588,8 +584,7 @@ class DeployConfigReader { if (reservations.nanoCpus.contains('/')) { // TODO throw new UnsupportedOperationException("not supported, yet") - } - else { + } else { return new ResourceObject( (parseDouble(reservations.nanoCpus) * nanoMultiplier).longValue(), parseLong(reservations.memory), @@ -653,8 +648,7 @@ class DeployConfigReader { null, null) source = stackVolume.external.name - } - else { + } else { Map labels = stackVolume?.labels?.entries ?: [:] labels[(ManageStackClient.LabelNamespace)] = namespace volumeOptions = new MountVolumeOptions( @@ -701,8 +695,7 @@ class DeployConfigReader { MountBindOptions getBindOptions(ServiceVolumeBind bind) { if (bind?.propagation) { return new MountBindOptions(MountBindOptions.Propagation.values().find { MountBindOptions.Propagation propagation -> propagation.getValue() == bind.propagation }, null) - } - else { + } else { return null } } @@ -760,11 +753,9 @@ class DeployConfigReader { null, getLabels(namespace, null) ) - } - else if (network?.external?.external) { + } else if (network?.external?.external) { externalNetworkNames << (network.external.name ?: internalName) - } - else { + } else { networkSpec[internalName] = new NetworkCreateRequest( internalName, true, diff --git a/client/src/test/groovy/de/gesellix/docker/client/stack/DeployConfigReaderTest.groovy b/client/src/test/groovy/de/gesellix/docker/client/stack/DeployConfigReaderTest.groovy index 2d8e9ca2..cb91a132 100644 --- a/client/src/test/groovy/de/gesellix/docker/client/stack/DeployConfigReaderTest.groovy +++ b/client/src/test/groovy/de/gesellix/docker/client/stack/DeployConfigReaderTest.groovy @@ -556,14 +556,16 @@ class DeployConfigReaderTest extends Specification { test: new Command(parts: ["EXEC", "touch", "/foo"]), timeout: "30s", interval: "2ms", - retries: 10 + retries: 10, + startPeriod: "1s", + startInterval: "500ms", )) == new HealthConfig( ["EXEC", "touch", "/foo"], Duration.of(2, ChronoUnit.MILLIS).toNanos().longValue(), Duration.of(30, ChronoUnit.SECONDS).toNanos().longValue(), 10, - null, - null + Duration.of(1, ChronoUnit.SECONDS).toNanos().longValue(), + Duration.of(500, ChronoUnit.MILLIS).toNanos().longValue() ) }