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

Remove string pointers #653

Merged
merged 1 commit into from
Jan 13, 2017
Merged

Conversation

mrunalp
Copy link
Contributor

@mrunalp mrunalp commented Jan 12, 2017

An empty string works as null value for strings so we don't need string pointers.

Signed-off-by: Mrunal Patel mrunalp@gmail.com

Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
@crosbymichael
Copy link
Member

crosbymichael commented Jan 12, 2017

LGTM

Approved with PullApprove

@duglin
Copy link
Contributor

duglin commented Jan 12, 2017

Not sure if this is an issue or not but wanted to mention it in case there's a hidden issue.... but the pointer allowed for the receiving side to know when the sender didn't mention the property at all vs they specified "". This is useful when you need to know when the user wants the default value (not mentioned) vs they explicitly want an empty string as the value. Just thought I'd mention it.

@duglin
Copy link
Contributor

duglin commented Jan 12, 2017

none of those fields look like they would have an issue with this, but others would know for sure.

@wking
Copy link
Contributor

wking commented Jan 12, 2017 via email

@wking
Copy link
Contributor

wking commented Jan 12, 2017 via email

@mrunalp
Copy link
Contributor Author

mrunalp commented Jan 12, 2017

@duglin Thanks! I think cgroupPath should be fine as empty could mean let runtime handle it. For cpuset cpus/mems, I see that when we create a new cgroup it is empty :/ @crosbymichael @hqhq WDYT we should do about that?

@wking
Copy link
Contributor

wking commented Jan 12, 2017 via email

@crosbymichael
Copy link
Member

I think those are fine to keep as a non pointer because empty values on the cpus and mems is invalid

@wking
Copy link
Contributor

wking commented Jan 12, 2017

I think those are fine to keep as a non pointer because empty values on the cpus and mems is invalid

Actually, an empty value for cpus seems to be legal:

# cd /sys/fs/cgroup/cpuset
# mkdir bob
# cat bob/cpuset.cpus

# echo 1 >bob/cpuset.cpus
# cat bob/cpuset.cpus
1
# echo >bob/cpuset.cpus
# cat bob/cpuset.cpus

And the docs have:

If hotplug functionality is used to remove all the CPUs that are currently assigned to a cpuset, then all the tasks in that cpuset will be moved to the nearest ancestor with non-empty cpus.

So we may want to retain the ability to explicitly write an empty string to cpuset.cpus.

@crosbymichael
Copy link
Member

@wking its incorrect

@wking
Copy link
Contributor

wking commented Jan 12, 2017

@wking its incorrect

The kernel allows it (and for cpuset.mems), at least with my vanilla 4.7. If the OCI position is that the kernel is wrong and the empty string is not something that you should be able to specify, it's probably worth explaining the reasoning behind that position.

@crosbymichael
Copy link
Member

@wking your example only works because you don't have any processes in the cgroup

@wking
Copy link
Contributor

wking commented Jan 12, 2017

@wking your example only works because you don't have any processes in the cgroup

Ah, that makes sense then. We're more restricted than the kernel (not allowing empty strings for cpuset.cpus or cpuset.mems) because we are always configuring cgroups immediately before adding a process to that cgroup. So I'm back to having no fundamental concerns about this approach for these settings.

868e631 is still missing JSON Schema and style.md updates, though. If @mrunalp doesn't want to address that himself, I can file a fixup PR against this one or a followup PR if/when this one lands.

@crosbymichael
Copy link
Member

You know, it gets really old having to argue with you about everything, all the time. Can ya stop plz? I'm getting really frustrated.

@wking
Copy link
Contributor

wking commented Jan 12, 2017

You know, it gets really old having to argue with you about everything…

Dropping the ability to set an empty-string value seems like something that should be backed up with at least a line or two of motivation for why you don't need that ability. I'm fairly sure someone else besides me will wonder why we don't support the empty-string cpus/mems values that the kernel allows in general, and now we can point them to your comment to clear them up.

I've filed the remaining changes I'd like to see against this branch in mrunalp#1 in case that helps.

@hqhq
Copy link
Contributor

hqhq commented Jan 13, 2017

LGTM

@wking You can file schema changes as a followup PR, thanks.

Approved with PullApprove

@hqhq hqhq merged commit 5398f4e into opencontainers:master Jan 13, 2017
wking added a commit to wking/opencontainer-runtime-spec that referenced this pull request Jan 13, 2017
Catch up with 868e631 (Remove string pointers, 2017-01-12, opencontainers#653).

Signed-off-by: W. Trevor King <wking@tremily.us>
wking added a commit to wking/opencontainer-runtime-spec that referenced this pull request Jan 13, 2017
Catch up with 868e631 (Remove string pointers, 2017-01-12, opencontainers#653).

Signed-off-by: W. Trevor King <wking@tremily.us>
wking added a commit to wking/opencontainer-runtime-spec that referenced this pull request Apr 15, 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.

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>
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.

5 participants