Uh oh!
There was an error while loading. Please reload this page.
validate: Code optimization - #486
Conversation
| if ns.Path != "" && !filepath.IsAbs(ns.Path) { | ||
| return false | ||
| return fmt.Errorf("%v is not an absolute path", ns.Path) |
There was a problem hiding this comment.
maybe fmt.Errorf(path %v of namespace %v is not absolute, ns.Type, ns.Path) better?
| case rspec.CgroupNamespace: | ||
| default: | ||
| return false | ||
| return fmt.Errorf("invalid namespace type %s", ns.Type) |
There was a problem hiding this comment.
The spec actually has no RFC 2119 wording for this check, saying only “The following namespace types are supported”. It doesn't say that runtimes MUST support them, or that they MUST NOT support additional values, or even that configurations SHOULD use values from that list. I'd guess the spec-maintainer intention was closer to:
Configurations SHOULD use, and runtimes SHOULD support, the following values:
Compliance testing would be easier with “runtimes MUST support”, but see opencontainers/runtime-spec#813.
Anyhow, from the config-validation side, I'd be happier seeing this supported by an effective-SHOULD, similar to what I've proposed in #481.
| if ns.Path != "" && !filepath.IsAbs(ns.Path) { | ||
| return false | ||
| return fmt.Errorf("path %v of namespace %v is not absolute path", ns.Path, ns) |
There was a problem hiding this comment.
I think the 1.0 spec is clearer on this point, but I've filed opencontainers/runtime-spec#925 to attach a MUST to this condition. I'm fine treating the requirement as an implicit-MUST in the meantime.
wking
commented
Sep 28, 2017
This PR belongs in v0.3.0. It's not using |
2711261 to
674d195Comparezhouhao3
commented
Oct 18, 2017
updated, @Mashimiao@liangchenye@wking PTAL |
| func init() { | ||
| register(DefaultFilesystems, rfc2119.Should, defaultFilesystemsRef) | ||
| register(NamespacesType, rfc2119.Should, namespacesRef) |
There was a problem hiding this comment.
The spec says: "The following namespace types are supported", We don't have key words like 'SHOULD'. Maybe we can add a PR to spec project?
There was a problem hiding this comment.
Maybe we can add a PR to spec project?
Approve.
| // DefaultFilesystems represents "The following filesystems SHOULD be made available in each container's filesystem:" | ||
| DefaultFilesystems = "The following filesystems SHOULD be made available in each container's filesystem:" | ||
| NamespacesType = "The following namespace types are supported:" | ||
| NamespacesPath = "This value MUST be an absolute path." |
There was a problem hiding this comment.
I prefer to extend it to "This value MUST be an absolute path in the runtime mount namespace. "
There are several 'an absolute path' RFCs, https://github.com/opencontainers/runtime-tools/blob/master/specerror/config.go#L32, https://github.com/opencontainers/runtime-tools/blob/master/specerror/config.go#L42.
It will be easier to differentiate them.
| // DefaultFilesystems represents "The following filesystems SHOULD be made available in each container's filesystem:" | ||
| DefaultFilesystems = "The following filesystems SHOULD be made available in each container's filesystem:" | ||
| NamespacesType = "The following namespace types are supported:" | ||
| NamespacesPath = "This value MUST be an absolute path." |
There was a problem hiding this comment.
rename to NamespacePathAbs?
The naming is a problem, maybe we can add a document to specerror directory to tell our naming rule.
0fc41b9 to
57601a4Compareliangchenye
commented
Nov 3, 2017
rebase required |
Signed-off-by: zhouhao <zhouhao@cn.fujitsu.com>
zhouhao3
commented
Nov 3, 2017
rebased. |
zhouhao3
commented
Dec 13, 2017
Closed because the code has been deleted. |
Make the error message more specific.
Signed-off-by: zhouhao zhouhao@cn.fujitsu.com