Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config: Require strictly-positive timeout values #764

Merged

Conversation

wking
Copy link
Contributor

@wking wking commented Apr 7, 2017

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.

Removing the pointer is not strictly required, but keeps up with our anti-pointer zero-value style now that Go's zero-value is clearly invalid.

@mrunalp
Copy link
Contributor

mrunalp commented Apr 12, 2017

LGTM

Approved with PullApprove

@crosbymichael
Copy link
Member

I don't think the pointer should be removed here

@wking
Copy link
Contributor Author

wking commented Apr 13, 2017

I don't think the pointer should be removed here

Because? We removed similar unnecessary pointers in #653.

@erikh
Copy link

erikh commented Apr 13, 2017

This was done for similar reasons (which I presume are nulls being supported) in image-spec recently, it seems like a valid place here: opencontainers/image-spec#633

Just seagulling, hope it's ok.

@wking
Copy link
Contributor Author

wking commented Apr 13, 2017 via email

@@ -126,7 +126,7 @@ type Hook struct {
Path string `json:"path"`
Args []string `json:"args,omitempty"`
Env []string `json:"env,omitempty"`
Timeout *int `json:"timeout,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add back the pointer to this field so we can validate a actual user provided 0 value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add back the pointer to this field so we can validate a actual user provided 0 value.

This seems like it would be an issue with the string properties de-pointerized by #653. I think that validation tools should be using the JSON Schema or interface{} parsing to check this sort of thing (pull request to get that to happen in opencontainers/runtime-tools#197). If the goal is to be able to distinguish “unset” from “set to an invalid/no-op value”, then we do want a pointer here, but probably also want to get the pointer back for CgroupsPath, etc. Or is there a reason why we want to be able to easily identify “timeout set to 0” in Go but don't need that for “cgroupsPath set to an empty string”?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the interest of landing the normative spec change, I've dropped the de-pointerization here with 8510055ecf7314 and opened #772 around whether we need invalid-zero-value detection for optional parameters.

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]: opencontainers#764 (comment)
[2]: opencontainers#653 (comment)

Signed-off-by: W. Trevor King <wking@tremily.us>
@mrunalp
Copy link
Contributor

mrunalp commented May 9, 2017

LGTM

Approved with PullApprove

Copy link
Member

@crosbymichael crosbymichael left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@crosbymichael
Copy link
Member

crosbymichael commented May 9, 2017

LGTM

Approved with PullApprove

@crosbymichael crosbymichael merged commit e1b2e61 into opencontainers:master May 9, 2017
@wking wking deleted the strictly-positive-timeout branch May 9, 2017 23:49
@vbatts vbatts mentioned this pull request Jul 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants