Skip to content

Commit

Permalink
Read healthcheck "start_interval" in docker compose/stack config
Browse files Browse the repository at this point in the history
  • Loading branch information
gesellix committed Feb 7, 2024
1 parent fb9f9f3 commit 345ced1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,7 @@ class DeployConfigReader {
if (networkConfig?.external?.external) {
if (networkConfig?.external?.name) {
return networkConfig.external.name
}
else {
} else {
return networkName
}
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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),
Expand All @@ -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),
Expand Down Expand Up @@ -653,8 +648,7 @@ class DeployConfigReader {
null,
null)
source = stackVolume.external.name
}
else {
} else {
Map<String, String> labels = stackVolume?.labels?.entries ?: [:]
labels[(ManageStackClient.LabelNamespace)] = namespace
volumeOptions = new MountVolumeOptions(
Expand Down Expand Up @@ -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
}
}
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
)
}

Expand Down

0 comments on commit 345ced1

Please sign in to comment.