Concourse: basic support for 'timeout' attribute

This commit is contained in:
Kris De Volder
2016-12-21 16:54:30 -08:00
parent 7bbdffbff5
commit 65451b0ff2
6 changed files with 124 additions and 2 deletions

View File

@@ -52,6 +52,9 @@ public class PipelineYmlSchema implements YamlSchema {
YType t_params = f.ymap(t_string, t_any);
YType t_string_params = f.ymap(t_string, t_string);
YAtomicType t_duration = f.yatomic("Duration");
t_duration.parseWith(ValueParsers.DURATION);
YAtomicType t_version = f.yatomic("Version");
t_version.addHints("latest", "every");
@@ -142,6 +145,7 @@ public class PipelineYmlSchema implements YamlSchema {
prop(step, "ensure", step);
prop(step, "attempts", t_strictly_pos_integer);
prop(step, "tags", t_strings);
prop(step, "timeout", t_duration);
YBeanType resource = f.ybean("Resource");
prop(resource, "name", t_ne_string);

View File

@@ -11,6 +11,7 @@
package org.springframework.ide.vscode.concourse;
import org.springframework.ide.vscode.commons.util.Assert;
import org.springframework.ide.vscode.commons.util.RegexpParser;
import org.springframework.ide.vscode.commons.util.StringUtil;
import org.springframework.ide.vscode.commons.util.ValueParser;
@@ -56,5 +57,16 @@ public class ValueParsers {
}
};
}
public static ValueParser DURATION = new RegexpParser(
"^(([0-9]+(.[0-9]+)?)(ns|us|µs|ms|s|h|m))+$",
"Duration",
" A duration string is a sequence of decimal numbers, each with "
+ "optional fraction and a unit suffix, such as '300ms', '1.5h' or"
+ " '2h45m'. Valid time units are 'ns', 'us' (or 'µs'), 'ms', 's', "
+ "'m', 'h'."
);
}

View File

@@ -0,0 +1,17 @@
Enforce a time limit on a step.
Any step can have a hard time limit enforced by attaching timeout and the number of seconds to limit it to.
timeout: duration
The amount of time to limit the step's execution to, e.g. `30m` for 30 minutes.
When exceeded, the step will be interrupted, with the same semantics as aborting the build (except the build will be `failed`, not `aborted`, to distinguish between human intervention and timeouts being enforced).
The following will run the task, and cancel it if it takes longer than 1 hour and 30 minutes:
plan:
- get: foo
- task: unit
file: foo/unit.yml
timeout: 1h30m