-
Notifications
You must be signed in to change notification settings - Fork 142
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
rebase the specerror framework ; complete rfc code of config.md #458
Conversation
I'll rebase it after #455. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of:
ProcessCWDAbs represents the error code of absolute path test of process
cwd
can we inline the 1.0.0 spec language?
ProcessCWDAbs represents the "This value MUST be an absolute path" process.cwd requirement.
The Go comments are not printed as part of the test output, but inlining spec language gives Go devs clarity until opencontainers/runtime-spec#634 is re-opened and addressed.
And while we're cleaning this up, I'd recommend Version
or OCIVersion
where you currently have SpecVersion
, because you don't currently prefix other codes with Spec
.
error/runtime_spec.go
Outdated
// Process | ||
// ProcessOnStart represents the error code of process property test when 'start' is called | ||
ProcessOnStart | ||
// ProcessIngnoreConsoleSize represents the error code of console size test when terminal is `false` or unset |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: you seem to go back and forth between backticks (like your false
here) and single quotes (like your 'start'
two lines up). It would be nice to pick one and stick with it. Go's comment → HTML converter doesn't render Markdown or have a way to get <code>…</code>
spans, so I'd recommend using single quotes. But I'll be happy as long as we're consistent one way or the other.
error/runtime_spec.go
Outdated
// PosixHookPathAbs represents the error code of absolute path test of posix hook path | ||
PosixHookPathAbs | ||
// PosixHookTimeout represents the error code of hook timeout test | ||
PosixHookTimeout |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd recommend more specific names for future-proofing. For example, PosixHookTimeoutPositive
for “If set, timeout
MUST be greater than zero”.
error/runtime_spec.go
Outdated
@@ -30,7 +30,7 @@ const ( | |||
RootOnNonHyperV | |||
// RootOnHyperV represents the error code of root setting test on hyper-v containers | |||
RootOnHyperV | |||
// PathFormatOnWindows represents the error code of the path format test on Window | |||
// PathFormatOnWindows represents the error code of the path format test on Windows | |||
PathFormatOnWindows | |||
// PathName represents the error code of the path name test | |||
PathName |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be more specific, e.g. PosixRootPathConvention
or PosixRootPathRootfs
, because it's a POSIX-only SHOULD about root.path
suggesting “the conventional rootfs
”.
error/runtime_spec.go
Outdated
@@ -41,6 +41,73 @@ const ( | |||
// ReadonlyOnWindows represents the error code of readonly setting test on Windows | |||
ReadonlyOnWindows |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be a more specific WindowsRootReadonlyFalse
, and the earlier ReadonlyFilesystem
could be RootReadonlyImplemented
or some such, to distinguish from other root.readonly
issues like using a non-boolean value.
error/runtime_spec.go
Outdated
// MountDestinationAbs represents the error code of absolute path test of mount destination | ||
MountDestinationAbs | ||
// MountNotNestedOnWindows represents the error code of nested mount point on Windows | ||
MountNotNestedOnWindows |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend consistent platform namespacing. You have an OnWindows
suffix here, but have other entries with a platform prefix (e.g. WindowsPlatform
, LinuxOomScoreAdj
, PosixHookPathAbs
). I recommend a template like:
{platform, if platform-specific}{JSON path in camelCase}{something about what's being tested}
which would make this one WindowsMountsDestinationNotNested
.
error/runtime_spec.go
Outdated
// RlimitHardMax represents the error code of rlimit hard test | ||
RlimitHardMax | ||
// RlimitDuplicated represents the error code of rlimit duplicate type test | ||
RlimitDuplicated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see an entry in your rlimits codes for “For each entry in rlimits
, a getrlimit(3)
on type
MUST succeed”. That would be something like PosixProcessRlimitsTypeGet
.
error/runtime_spec.go
Outdated
// PosixHookStateOverStdin represents the error code of `state` information test if it was passed to hook process | ||
PosixHookStateOverStdin | ||
// PosixHookPrestartOrder represents the error code of order test of pre-start hook | ||
PosixHookPrestartOrder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a subcase of PosixHookCalledInOrder
? Or is this intended for “The pre-start hooks MUST be called after the start operation is called but before the user-specified program command is executed”? I don't see a need for the former, and think a better name for the latter would be PosixHooksPrestartTiming
or something so we can distinguish between the order of one hook relative to another and the order of the hooks as a whole relative to the surrounding lifecycle.
error/runtime_spec.go
Outdated
|
||
// Annotations | ||
// AnnotationKeyValue represents the error code of annotations key-value map test | ||
AnnotationKeyValue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are several RFC 2119 conditions for annotations, but you only have one code here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw they were quoted, should we remove the this quote from the spec?
Keys MUST be strings.
Keys MUST NOT be an empty string.
Keys SHOULD be named using a reverse domain notation - e.g. `com.example.myKey`.
Keys using the `org.opencontainers` namespace are reserved and MUST NOT be used by subsequent specifications.
Implementations that are reading/processing this configuration file MUST NOT generate an error if they encounter an unknown annotation key.
Values MUST be strings.
Values MAY be an empty string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw they were quoted…
I see some backticks in the spec you reference, but no quotes. And backticks are just markup, they don't affect the number of RFC 2119 conditions contained in the text.
error/runtime_spec.go
Outdated
|
||
// Extensibility | ||
// IgnoreUnknownProperties represents the error code of unknown properties test | ||
IgnoreUnknownProperties |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two MUSTs for this in the spec, but I've filed opencontainers/runtime-spec#916 to collapse them to one.
@wking I'll use the inline language. It is always difficult for me to find suitable English word to describe a spec error. |
On Fri, Sep 01, 2017 at 03:07:19AM +0000, 梁辰晔 (Liang Chenye) wrote:
Ideally, if we have more specific
opencontainers/runtime-spec#634, we can
generate the spec error code from spec files automatically.
Yeah, that would be good. But I'd much rather have gotten them via
opencontainers/runtime-spec#628 and am not interested in maintaining
per-sentence link anchors by hand (the approach taken with
opencontainers/runtime-spec#634). If someone else wants to step up
and add those to the spec, then great, but I'll be very surprised if
it happens in the next three months ;).
|
I wrote a simple tool today to help make life easier: |
We have several
|
39cb55c
to
f1b5d4f
Compare
updated base on https://github.com/liangchenye/markdown-to-json/blob/master/testdata/config.output
The |
f1b5d4f
to
27503c5
Compare
awesome! |
The https://github.com/liangchenye/markdown-to-json tool is updated, I try to make as useful as i18n tool ( |
specerror/error.go
Outdated
RootPathExist: {Level: rfc2119.Must, Reference: rootRef}, | ||
RootReadonlyImplement: {Level: rfc2119.Must, Reference: rootRef}, | ||
RootReadonlyOnWindowsFalse: {Level: rfc2119.Must, Reference: rootRef}, | ||
// Mounts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The constants now have namespaced names (e.g. Mounts*
), so there's no need for comments like // Mounts
, your earlier // Root
, etc. There may still be a use for the file-level comments (// Bundle.md
and // Config.md
) with the current names, but in order to avoid collisions it may be better to include that level in the constant names too (ConfigFileExistence
→ BundleConfigFileExistence
, RootOnWindowsRequired
→ ConfigRootOnWindowsRequired
, etc.).
Based on #465, this should go on the v0.3.0 milestone. |
yes, marked |
The spec isn't particuarly clear on this, saying [1]: * Linux: valid values are defined in the [`getrlimit(2)`][getrlimit.2] man page, such as `RLIMIT_MSGQUEUE`. * Solaris: valid values are defined in the [`getrlimit(3)`][getrlimit.3] man page, such as `RLIMIT_CORE`. and [2]: For each entry in `rlimits`, a [`getrlimit(3)`][getrlimit.3] on `type` MUST succeed. It doesn't say: Linux: The value MUST be listed in the getrlimit(2) man page... and it doesn't require the runtime to support the values listed in the man page [3,4]. So there are three sets: * Values listed in the man page * Values supported by the host kernel * Values supported by the runtime And as the spec stands, these sets are only weakly coupled, and any of them could be a sub- or superset of any other. In practice, I expect the sets to all coincide, with the kernel occasionally adding or removing values, and the man page and runtimes trailing along behind. To address that, this commit weakens the previous hard error to a SHOULD-level error. The PosixProcRlimitsValueError constant is new to this commit, because the spec contains neither a MUST nor a SHOULD for this condition, although I expect a SHOULD-level suggestion was implied by [1]. The posixProcRef constant is cherry-picked from 27503c5 (complete spec errors of config.md, 2017-09-05, opencontainers#458). [1]: https://github.com/opencontainers/runtime-spec/blame/v1.0.0/config.md#L168-L169 [2]: https://github.com/opencontainers/runtime-spec/blame/v1.0.0/config.md#L168-L169 [3]: opencontainers/runtime-spec#813 [4]: https://github.com/opencontainers/runtime-spec/blame/v1.0.0/config.md#L463 Signed-off-by: W. Trevor King <[email protected]>
The spec isn't particuarly clear on this, saying [1]: * Linux: valid values are defined in the [`getrlimit(2)`][getrlimit.2] man page, such as `RLIMIT_MSGQUEUE`. * Solaris: valid values are defined in the [`getrlimit(3)`][getrlimit.3] man page, such as `RLIMIT_CORE`. and [2]: For each entry in `rlimits`, a [`getrlimit(3)`][getrlimit.3] on `type` MUST succeed. It doesn't say: Linux: The value MUST be listed in the getrlimit(2) man page... and it doesn't require the runtime to support the values listed in the man page [3,4]. So there are three sets: * Values listed in the man page * Values supported by the host kernel * Values supported by the runtime And as the spec stands, these sets are only weakly coupled, and any of them could be a sub- or superset of any other. In practice, I expect the sets to all coincide, with the kernel occasionally adding or removing values, and the man page and runtimes trailing along behind. To address that, this commit weakens the previous hard error to a SHOULD-level error. The PosixProcRlimitsValueError constant is new to this commit, because the spec contains neither a MUST nor a SHOULD for this condition, although I expect a SHOULD-level suggestion was implied by [1]. The posixProcRef constant is cherry-picked from 27503c5 (complete spec errors of config.md, 2017-09-05, opencontainers#458). [1]: https://github.com/opencontainers/runtime-spec/blame/v1.0.0/config.md#L168-L169 [2]: https://github.com/opencontainers/runtime-spec/blame/v1.0.0/config.md#L168-L169 [3]: opencontainers/runtime-spec#813 [4]: https://github.com/opencontainers/runtime-spec/blame/v1.0.0/config.md#L463 Signed-off-by: W. Trevor King <[email protected]>
The spec isn't particuarly clear on this, saying [1]: * Linux: valid values are defined in the [`getrlimit(2)`][getrlimit.2] man page, such as `RLIMIT_MSGQUEUE`. * Solaris: valid values are defined in the [`getrlimit(3)`][getrlimit.3] man page, such as `RLIMIT_CORE`. and [2]: For each entry in `rlimits`, a [`getrlimit(3)`][getrlimit.3] on `type` MUST succeed. It doesn't say: Linux: The value MUST be listed in the getrlimit(2) man page... and it doesn't require the runtime to support the values listed in the man page [3,4]. So there are three sets: * Values listed in the man page * Values supported by the host kernel * Values supported by the runtime And as the spec stands, these sets are only weakly coupled, and any of them could be a sub- or superset of any other. In practice, I expect the sets to all coincide, with the kernel occasionally adding or removing values, and the man page and runtimes trailing along behind. To address that, this commit weakens the previous hard error to a SHOULD-level error. The PosixProcRlimitsValueError constant is new to this commit, because the spec contains neither a MUST nor a SHOULD for this condition, although I expect a SHOULD-level suggestion was implied by [1]. The posixProcRef constant is cherry-picked from 27503c5 (complete spec errors of config.md, 2017-09-05, opencontainers#458). Also make CheckRlimits a no-op on Windows, because the spec does not define process.rlimits for that OS [5]. [1]: https://github.com/opencontainers/runtime-spec/blame/v1.0.0/config.md#L168-L169 [2]: https://github.com/opencontainers/runtime-spec/blame/v1.0.0/config.md#L168-L169 [3]: opencontainers/runtime-spec#813 [4]: https://github.com/opencontainers/runtime-spec/blame/v1.0.0/config.md#L463 [5]: https://github.com/opencontainers/runtime-spec/blob/v1.0.0/config.md#posix-process Signed-off-by: W. Trevor King <[email protected]>
The spec isn't particuarly clear on this, saying [1]: * Linux: valid values are defined in the [`getrlimit(2)`][getrlimit.2] man page, such as `RLIMIT_MSGQUEUE`. * Solaris: valid values are defined in the [`getrlimit(3)`][getrlimit.3] man page, such as `RLIMIT_CORE`. and [2]: For each entry in `rlimits`, a [`getrlimit(3)`][getrlimit.3] on `type` MUST succeed. It doesn't say: Linux: The value MUST be listed in the getrlimit(2) man page... and it doesn't require the runtime to support the values listed in the man page [3,4]. So there are three sets: * Values listed in the man page * Values supported by the host kernel * Values supported by the runtime And as the spec stands, these sets are only weakly coupled, and any of them could be a sub- or superset of any other. In practice, I expect the sets to all coincide, with the kernel occasionally adding or removing values, and the man page and runtimes trailing along behind. To address that, this commit weakens the previous hard error to a SHOULD-level error. The PosixProcRlimitsValueError constant is new to this commit, because the spec contains neither a MUST nor a SHOULD for this condition, although I expect a SHOULD-level suggestion was implied by [1]. The posixProcRef constant is cherry-picked from 27503c5 (complete spec errors of config.md, 2017-09-05, opencontainers#458). Also make CheckRlimits a no-op on Windows, because the spec does not define process.rlimits for that OS [5]. [1]: https://github.com/opencontainers/runtime-spec/blame/v1.0.0/config.md#L168-L169 [2]: https://github.com/opencontainers/runtime-spec/blame/v1.0.0/config.md#L168-L169 [3]: opencontainers/runtime-spec#813 [4]: https://github.com/opencontainers/runtime-spec/blame/v1.0.0/config.md#L463 [5]: https://github.com/opencontainers/runtime-spec/blob/v1.0.0/config.md#posix-process Signed-off-by: W. Trevor King <[email protected]>
27503c5
to
42fde59
Compare
I got near 200 RFC errors and found it is difficult to maintain all of them in one file. |
655cb94
to
ce4fbd0
Compare
PTAL @wking @Mashimiao @q384566678 |
specerror/error.go
Outdated
return fmt.Sprintf(referenceTemplate, version, "runtime.md#create"), nil | ||
var ociErrors = map[Code]errorTemplate{} | ||
|
||
func registOCIError(code Code, level rfc2119.Level, ref func(versiong string) (string, error)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This package is just about runtime-spec requirement, so this can be register
. No need to have OCI
or error
in the name, because they're covered by the package path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I‘ll change it tomorrow morning.
specerror/error.go
Outdated
|
||
func registOCIError(code Code, level rfc2119.Level, ref func(versiong string) (string, error)) { | ||
if _, ok := ociErrors[code]; ok { | ||
panic(fmt.Sprintf("should not regist a same code twice: %s", code)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe: regist a
-> register the
.
specerror/bundle.go
Outdated
@@ -0,0 +1,31 @@ | |||
// Package specerror implements runtime-spec-specific tooling for | |||
// tracking RFC 2119 violations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To stay DRY, I think you only want this comment in error.go
.
// define error codes | ||
const ( | ||
// 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:" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this really our only config-linux.md
requirement? Either way, I'd rather get this PR landed, because the change feels to big to wait until it's complete and perfect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no,these items were already recorded in runtime tools implementation. I add them first. The whole rfc errors will come later.
Signed-off-by: Liang Chenye <[email protected]>
updated, rename registOCIError to |
Signed-off-by: Liang Chenye [email protected]