From 7d7464fea3acbf1fcaafc7db151fea2c358fe565 Mon Sep 17 00:00:00 2001 From: Paolo Di Tommaso Date: Thu, 8 Jun 2023 12:02:53 +0200 Subject: [PATCH] Consolidate Wave retryPolicy options Signed-off-by: Paolo Di Tommaso --- docs/wave.md | 16 ++++++++++++---- .../wave/plugin/config/WaveConfig.groovy | 2 +- .../wave/plugin/config/WaveConfigTest.groovy | 18 +++++++++++++++++- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/docs/wave.md b/docs/wave.md index 9717d04f95..cc7b04be96 100644 --- a/docs/wave.md +++ b/docs/wave.md @@ -202,14 +202,22 @@ The following configuration options are available: `wave.report.file` (preview) : The name of the containers report file (default: `containers-.config` requires version `23.06.0-edge` or later). -`wave.retry.delay` +`wave.retryPolicy.delay` +: :::{versionadded} 22.06.0-edge + ::: : The initial delay when a failing HTTP request is retried (default: `150ms`). -`wave.retry.maxDelay` +`wave.retryPolicy.maxDelay` +: :::{versionadded} 22.06.0-edge + ::: : The max delay when a failing HTTP request is retried (default: `90 seconds`). -`wave.retry.maxAttempts` +`wave.retryPolicy.maxAttempts` +: :::{versionadded} 22.06.0-edge + ::: : The max number of attempts a failing HTTP request is retried (default: `5`). -`wave.retry.jitter` +`wave.retryPolicy.jitter` +: :::{versionadded} 22.06.0-edge + ::: : Sets the jitterFactor to randomly vary retry delays by (default: `0.25`). diff --git a/plugins/nf-wave/src/main/io/seqera/wave/plugin/config/WaveConfig.groovy b/plugins/nf-wave/src/main/io/seqera/wave/plugin/config/WaveConfig.groovy index 2a91c210b2..68c8fa1774 100644 --- a/plugins/nf-wave/src/main/io/seqera/wave/plugin/config/WaveConfig.groovy +++ b/plugins/nf-wave/src/main/io/seqera/wave/plugin/config/WaveConfig.groovy @@ -57,7 +57,7 @@ class WaveConfig { this.strategy = parseStrategy(opts.strategy) this.bundleProjectResources = opts.bundleProjectResources this.reportOpts = new ReportOpts(opts.report as Map ?: Map.of()) - this.retryOpts = new RetryOpts(opts.retry as Map ?: Map.of()) + this.retryOpts = new RetryOpts(opts.retryPolicy as Map ?: Map.of()) if( !endpoint.startsWith('http://') && !endpoint.startsWith('https://') ) throw new IllegalArgumentException("Endpoint URL should start with 'http:' or 'https:' protocol prefix - offending value: $endpoint") } diff --git a/plugins/nf-wave/src/test/io/seqera/wave/plugin/config/WaveConfigTest.groovy b/plugins/nf-wave/src/test/io/seqera/wave/plugin/config/WaveConfigTest.groovy index 1809e980ce..ea79eab48c 100644 --- a/plugins/nf-wave/src/test/io/seqera/wave/plugin/config/WaveConfigTest.groovy +++ b/plugins/nf-wave/src/test/io/seqera/wave/plugin/config/WaveConfigTest.groovy @@ -17,7 +17,7 @@ package io.seqera.wave.plugin.config - +import nextflow.util.Duration import spock.lang.Specification import spock.lang.Unroll @@ -168,4 +168,20 @@ class WaveConfigTest extends Specification { def e = thrown(IllegalArgumentException) e.message == "Invalid value for 'wave.strategy' configuration attribute - offending value: foo" } + + def 'should get retry policy' () { + when: + def opts = new WaveConfig([:]) + then: + opts.retryOpts().maxAttempts == 5 + opts.retryOpts().maxDelay == Duration.of('90s') + + when: + opts = new WaveConfig([retryPolicy:[ maxAttempts: 20, jitter: 1.0, delay: '1s', maxDelay: '10s' ]]) + then: + opts.retryOpts().maxAttempts == 20 + opts.retryOpts().jitter == 1.0d + opts.retryOpts().delay == Duration.of('1s') + opts.retryOpts().maxDelay == Duration.of('10s') + } }