From ecf73148cbbcd66747d9f58732997254784d8e27 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 7 Apr 2017 10:00:22 -0700 Subject: [PATCH] config: Require strictly-positive timeout values If the timeout value was zero, the hook would always error, and there doesn't seem to be much point to that. And I'm not sure what negative timeouts would mean. By adding this restriction, we do not limit useful hook entries, and we give the validation code grounds to warn users attempting to validate configs which are poorly defined or have useless hook entries. I'd like to remove the pointer from the Go type to comply with our anti-pointer zero-value style (style.md) now that Go's zero-value is clearly invalid. However, there has been maintainer resistance to removing the pointer [1] (although I don't think this is consistent with previous maintainer statements that we don't need pointers when the zero value is invalid [2]). In order to land the normative spec change, this commit keeps the current *int for Hook.Timeout and punts a consistent policy to future work. [1]: https://github.com/opencontainers/runtime-spec/pull/764#discussion_r111607155 [2]: https://github.com/opencontainers/runtime-spec/pull/653#issuecomment-272253010 Signed-off-by: W. Trevor King --- config.md | 1 + schema/defs.json | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/config.md b/config.md index 40d174480..e5ecaabed 100644 --- a/config.md +++ b/config.md @@ -357,6 +357,7 @@ Hooks allow for the configuration of custom actions related to the [lifecycle](r * **`args`** (array of strings, OPTIONAL) with the same semantics as [IEEE Std 1003.1-2001 `execv`'s *argv*][ieee-1003.1-2001-xsh-exec]. * **`env`** (array of strings, OPTIONAL) with the same semantics as [IEEE Std 1003.1-2001's `environ`][ieee-1003.1-2001-xbd-c8.1]. * **`timeout`** (int, OPTIONAL) is the number of seconds before aborting the hook. + If set, `timeout` MUST be greater than zero. * **`poststart`** (array of objects, OPTIONAL) is an array of [post-start hooks](#poststart). Entries in the array have the same schema as pre-start entries. * **`poststop`** (array of objects, OPTIONAL) is an array of [post-stop hooks](#poststop). diff --git a/schema/defs.json b/schema/defs.json index 126e285b4..b8161ac87 100644 --- a/schema/defs.json +++ b/schema/defs.json @@ -91,7 +91,8 @@ "$ref": "#/definitions/Env" }, "timeout": { - "type": "integer" + "type": "integer", + "minimum": 1 } }, "required": [