-
Notifications
You must be signed in to change notification settings - Fork 157
validation: add linux resource check #195
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
validation: add linux resource check #195
Conversation
cmd/ocitools/validate.go
Outdated
logrus.Debugf("check linux resources") | ||
|
||
if r.OOMScoreAdj != nil && (int(*r.OOMScoreAdj) < -1000 || int(*r.OOMScoreAdj) > 1000) { | ||
msgs = append(msgs, fmt.Sprintf("OOMScoreAdj range is from -1000 to 1000")) |
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 think we should leverage runtime-spec's JSON Schema for this sort of thing. Validation should validate against the JSON Schema, and then run additional checks that can't be addressed in JSON Schema (like your limit/swap comparison below).
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.
On 08/18/2016 12:13 AM, W. Trevor King wrote:
I think we should leverage runtime-spec's JSON Schema https://github.com/opencontainers/runtime-spec/blob/v1.0.0-rc1/schema/schema-linux.json#L64-L69 for this sort of thing. Validation should validate against the JSON Schema, and then run additional checks that can't be addressed in JSON Schema (like your limit/swap comparison below).
Well, I didn't know about runtime-spec's JSON Schema before...
It seems it has function to validate min and max value.
But I think it's a little inconvenient to validate bundle by two tools as ocitools and this one.
I think ocitools should have this functions when validating bundle.
can we merge this into ocitools?
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.
On Wed, Aug 17, 2016 at 06:28:27PM -0700, Ma Shimiao wrote:
I think ocitools should have this functions when validating bundle.
can we merge this into ocitools?
I don't think we need to merge the tool, since 1 is so tiny. My
preferred approach would be to have something like
opencontainers/runtime-spec#490 so we could pull the schema JSON from
opencontainers.org (if folks ever get around to publishing it there ;)
or raw.githubusercontent.com (if they don't). The ocitools validate
flow would be:
- Invoked on a given config.
- Find the ociVersion.
- Figure out the URL for the associated JSON Schema (e.g. 2).
- Have xeipuuv/gojsonschema or similar use that schema to validate
the config. - Use Go (or Python Use Python's unittest for validating bundles and configurations? #98) to perform the checks that JSON Schema can't
handle (e.g. multi-param checks, host-specific checks, …).
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.
It looks like a good advice, we can implement it later.
Before implementing that, I think keep min and max check is OK.
Maybe they are some short of thing, but Ocitools and runtime schema are two projects and ocitools does not have these yet.
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.
On Wed, Aug 17, 2016 at 10:27:06PM -0700, Ma Shimiao wrote:
Maybe they are some short of thing, but Ocitools and runtime schema
are two projects and ocitools does not have these yet.
ocitools depends strongly on runtime-spec already, both for the
Markdown spec and the Go types. I don't see any new issues if we
start depending on the JSON Schema it provides as well. I'll file a
PR that adds a JSON Schema initial validation pass tonight.
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.
If so, I'm glade to remove these short of value checks
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.
On Wed, Aug 17, 2016 at 10:48:39PM -0700, Ma Shimiao wrote:
@@ -381,6 +386,47 @@ func checkLinux(spec rspec.Spec, rootfs string, hostCheck bool) (msgs []string)
return
}+func checkLinuxResources(r rspec.Resources, hostCheck bool) (msgs []string) {
- logrus.Debugf("check linux resources")
- if r.OOMScoreAdj != nil && (int(_r.OOMScoreAdj) < -1000 || int(_r.OOMScoreAdj) > 1000) {
msgs = append(msgs, fmt.Sprintf("OOMScoreAdj range is from -1000 to 1000"))
If so, I'm glade to remove these short of value checks
Filed against v1.0.0.rc1 as #197. Figuring out the right schema URL
for a -dev version is unclear to me, so we might have to wait on
forward-porting until runtime-spec cuts a v1.0.0-rc2.
Signed-off-by: Ma Shimiao <mashimiao.fnst@cn.fujitsu.com>
02a519e
to
9cad4d8
Compare
removed short of min and max check. implemented them in opencontainers/runtime-spec#533 |
On Thu, Aug 18, 2016 at 12:45:38AM -0700, Ma Shimiao wrote:
9cad4d8 looks good to me. I have a slight preference for: func checkLinuxResources(r *rspec.Resources, …) … over this PR's: func checkLinuxResources(r rspec.Resources, …) … because it lets us handle the nil check inside. But we can look at |
LGTM |
Signed-off-by: Ma Shimiao <mashimiao.fnst@cn.fujitsu.com> Backported to v1.0.0.rc1 from 9cad4d8 opencontainers#195 (cherry-pick applied cleanly). Signed-off-by: W. Trevor King <wking@tremily.us>
Signed-off-by: Ma Shimiao mashimiao.fnst@cn.fujitsu.com