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

validate: Soften unrecognized rlimit types to SHOULD violations #481

Merged

Conversation

wking
Copy link
Contributor

@wking wking commented Sep 21, 2017

This PR builds on #480; review that first.

The spec isn't particuarly clear on this, saying:

  • Linux: valid values are defined in the getrlimit(2) man page, such as RLIMIT_MSGQUEUE.
  • Solaris: valid values are defined in the getrlimit(3) man page, such as RLIMIT_CORE.

and:

For each entry in rlimits, a 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 (opencontainers/runtime-spec#813). 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 this. The posixProcRef constant is cherry-picked from #458.

Also make CheckRlimits a no-op on Windows, because the spec does not define process.rlimits for that OS.

@wking wking force-pushed the warn-on-potentially-invalid-rlimits branch 2 times, most recently from 0e28021 to 0696cb8 Compare September 21, 2017 18:32
@Mashimiao
Copy link

duplicate commit 894cae7 with #480 ?

@wking
Copy link
Contributor Author

wking commented Sep 22, 2017

duplicate commit 894cae7 with #480 ?

Yup, which is why I opened with:

This PR builds on #480; review that first.

If/when #480 settles, I'll rebase this one.

@wking wking force-pushed the warn-on-potentially-invalid-rlimits branch from 0696cb8 to d395004 Compare September 22, 2017 17:36
@wking
Copy link
Contributor Author

wking commented Sep 22, 2017 via email

@Mashimiao Mashimiao added this to the v0.3.0 milestone Sep 26, 2017
@@ -423,6 +423,10 @@ func (v *Validator) CheckCapabilities() (errs error) {

// CheckRlimits checks v.spec.Process.Rlimits
func (v *Validator) CheckRlimits() (errs error) {
if v.platform == "windows" {

Choose a reason for hiding this comment

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

Can you add a warning output on this side? such as:

logrus.Warnf("process.rlimits validation not yet implemented for platform %q", v.platform)

Also, does this have some overlap with the validation of the platform in rlimitValid?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you add a warning output on this side?

I don't think we want that. “Not yet implemented” warnings are for cases where runtime-tools has not yet caught up with the spec's requirements. But Windows does not, and likely never will support rlimits and the spec does not define rlimits for Windows.

Also, does this have some overlap with the validation of the platform in rlimitValid?

I'm touching rlimitValid in this PR. Do you think we need rlimitValid changes beyond those?

@zhouhao3 zhouhao3 requested a review from liangchenye October 11, 2017 03:06
@liangchenye
Copy link
Member

rebase required @wking , in the current specerror/config.go, the releated code is PosixProcRlimitsTypeGeneError.

@wking wking force-pushed the warn-on-potentially-invalid-rlimits branch from d395004 to 7553161 Compare October 23, 2017 19:24
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 PosixProcRlimitsTypeValueError 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].

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 <wking@tremily.us>
@wking
Copy link
Contributor Author

wking commented Oct 23, 2017 via email

@liangchenye
Copy link
Member

liangchenye commented Oct 24, 2017

LGTM

Approved with PullApprove

@liangchenye
Copy link
Member

and add an track liangchenye/markdown-to-json#1

@Mashimiao
Copy link

Mashimiao commented Oct 24, 2017

LGTM

Approved with PullApprove

@Mashimiao Mashimiao merged commit 8c00b14 into opencontainers:master Oct 24, 2017
@wking wking deleted the warn-on-potentially-invalid-rlimits branch November 7, 2017 04:39
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