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: add Hooks validation #49

Merged

Conversation

Mashimiao
Copy link

Signed-off-by: Ma Shimiao mashimiao.fnst@cn.fujitsu.com

@@ -106,6 +107,29 @@ func checkMounts(mounts []rspec.Mount, rootfs string) {
}
}

func checkHooks(process rspec.Hooks, rootfs string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

process is a strange name for this variable. How about hooks? And hooks are in the host mount namespace, so I don't think we need rootfs.

Copy link
Author

Choose a reason for hiding this comment

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

@wking change process to hooks is fine.
hooks are in the host mount namespace I'm not sure what it means.
Do you mean hooks is not in OCI bundle?

Copy link
Contributor

Choose a reason for hiding this comment

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

On Thu, Apr 28, 2016 at 07:54:26PM -0700, Ma Shimiao wrote:

hooks are in the host mount namespace I'm not sure what it means.
Do you mean hooks is not in OCI bundle?

The may be in the bundle, but if they are, the path will be
/path/to/bundle/and/hook, not /and/hook. Specs are 1:

“Hook paths are absolute and are executed from the host's
filesystem.”

Although I'd be happier if the wording used “runtime namespace” 2 so
it was explicit about other namespaces as well (e.g. hooks are also in
the host network namepace, the host ipc namespace, …).

@wking
Copy link
Contributor

wking commented Apr 28, 2016

This sort of validation would be easier if we could recycle the
process validator 1.

 Subject: Unify container-process and hook-process structures
 Date: Mon, 4 Jan 2016 21:56:37 -0800
 Message-ID: <20160105055637.GG6362@odin.tremily.us>

@liangchenye
Copy link
Member

Thanks @Mashimiao,
if we want to check hook, we can just check hook.Path directly, there is no need to join the rootfs.

Hook paths are absolute and are executed from the host's filesystem.

Also, since the hook command exists in the host's filesystem, we can not check that in bundle validation.go. (But we reuse this code in runtime test.)

@wking
Copy link
Contributor

wking commented May 3, 2016

On Tue, May 03, 2016 at 02:36:04AM -0700, 梁辰晔 (Liang Chenye) wrote:

Also, since the hook command exists in the host's filesystem, we can
not check that in bundle validation.go.

We can check “Does the hook command exist in the host's filesystem?”,
it's just that the check will not be portable. I think it's still
worth performing the check (e.g. see opencontainers/runtime-spec#418),
but it's probably worth putting that sort of thing behind a flag
(--host-checks?). I don't really have a preference for the flag name
or whether it's opt-in or opt-out.

@Mashimiao Mashimiao force-pushed the add-hooks-bundle-validation branch 2 times, most recently from 4b3b29e to 6ed1bd2 Compare May 9, 2016 06:28
@Mashimiao
Copy link
Author

@wking @liangchenye
This validation, as @wking said we can check “Does the hook command exist in the host's filesystem?”.
config.json belongs to OCI bundle. I think we check hook command exist or not is to check whether config.json is configured correct or not, is to check OCI bundle.
@wking I'm not sure what portability problem exists. If there was no hooks configured, the hook validation would not be executed.

@liangchenye
Copy link
Member

The hook configuration is a little tricky, it is not portable.
If it was verified on hostA, it could still fail on hostB.
If it fails on hostA, it is hard to say this is an invalid bundle.
But it is helpful to a user who tries to use it, so agree with WKing, we can add a flag to bundle validate.

@Mashimiao Mashimiao force-pushed the add-hooks-bundle-validation branch from 6ed1bd2 to 29a4d8e Compare May 10, 2016 03:47
@Mashimiao
Copy link
Author

@wking @liangchenye PR updated

@@ -20,6 +21,9 @@ Validate an OCI bundle
**--path="PATH"
Path to bundle

**--hooks-check**
Specify check hooks on host, default is false.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd have gone with --hook-paths or some such, but I expect folks will get the idea regardless. It's probably worth detailing what the hook checks are and why this is optional. The only check that needs to be toggle-able is “Does the path exist (and point to an executable)?”, and there is other validation that you can do beyond that (e.g. “Are there equals signs in all the env values?”).

@Mashimiao Mashimiao force-pushed the add-hooks-bundle-validation branch 2 times, most recently from 52bc38a to 028d996 Compare May 16, 2016 01:14
@Mashimiao
Copy link
Author

ping @liangchenye

@@ -6,6 +6,9 @@ ocitools-validate - Validate a OCI bundle

# SYNOPSIS
**ocitools validate** *[OPTIONS]*
[**--help**]
[**--path**[=*PATH*]
[**--hooks-check**[=*true*|*false*]
Copy link
Contributor

Choose a reason for hiding this comment

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

Listing specific options here rolls back part of c1df0ce (Fixup man pages for consistency, 2016-05-07, #65). I like the shorter [OPTIONS] for generate (see #42) because it has lots of options. I don't care either way for validate, but we probably want to pick one approach and not flip back and forth without motivation ;).

@Mashimiao Mashimiao force-pushed the add-hooks-bundle-validation branch 3 times, most recently from c71d294 to f54700d Compare May 16, 2016 08:38
@liangchenye
Copy link
Member

Thanks @Mashimiao

LGTM

@wking
Copy link
Contributor

wking commented May 17, 2016 via email

@Mashimiao
Copy link
Author

ping @mrunalp

@liangchenye
Copy link
Member

liangchenye commented May 20, 2016

Hi @Mashimiao,
I added another task to #66
'Hooks paths are absolute'.
It is different but related to this PR. We need to check if a path is absolute by default (without hooksCheck set to true). If you like to implement it (in this PR maybe), I'll add a WIP link.

@Mashimiao
Copy link
Author

Mashimiao commented May 20, 2016

@liangchenye OK, I can implement it in this PR.
implemented, please review.

@Mashimiao Mashimiao force-pushed the add-hooks-bundle-validation branch from f54700d to 51d1cc6 Compare May 20, 2016 06:32
@wking
Copy link
Contributor

wking commented May 20, 2016 via email

@wking
Copy link
Contributor

wking commented May 20, 2016

Ah, actually 51d1cc6 does not look good to me ;). The absolute-path
check needs to happen regardless of whether folks have set the
host-specific switch 1. Maybe we want to lump all of the
host-specific checks behind a --host-specific option?

@liangchenye liangchenye mentioned this pull request May 20, 2016
76 tasks
@Mashimiao Mashimiao force-pushed the add-hooks-bundle-validation branch from 51d1cc6 to ce49f78 Compare May 20, 2016 08:29
@Mashimiao
Copy link
Author

@wking Ah, yes. I did not read @liangchenye 's words carefully. How about now?

@wking
Copy link
Contributor

wking commented May 20, 2016

On Fri, May 20, 2016 at 01:30:20AM -0700, Ma Shimiao wrote:

How about now?

ce49f78 looks great :).

@@ -18,6 +18,9 @@ Validate an OCI bundle
**--path=PATH
Path to bundle

**--hooks**
Specify check hooks exists and executable on host, default is false.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Check specified hooks exist and are executable on the host.

Copy link
Author

@Mashimiao Mashimiao May 23, 2016

Choose a reason for hiding this comment

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

@mrunalp fixed.

@Mashimiao Mashimiao force-pushed the add-hooks-bundle-validation branch from ce49f78 to f11bccf Compare May 23, 2016 02:45
@@ -19,6 +20,7 @@ import (

var bundleValidateFlags = []cli.Flag{
cli.StringFlag{Name: "path", Usage: "path to a bundle"},
cli.BoolFlag{Name: "hooks", Usage: "Specify check hooks on host, default is false"},
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you change it here as well? Thanks!

Copy link
Author

Choose a reason for hiding this comment

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

@mrunalp sorry, miss it. fixed.

@Mashimiao Mashimiao force-pushed the add-hooks-bundle-validation branch from f11bccf to 8f62787 Compare May 24, 2016 01:14
@mrunalp
Copy link
Contributor

mrunalp commented May 24, 2016

Needs rebase

Signed-off-by: Ma Shimiao <mashimiao.fnst@cn.fujitsu.com>
@Mashimiao Mashimiao force-pushed the add-hooks-bundle-validation branch from 8f62787 to d5f4bb2 Compare May 24, 2016 01:41
@Mashimiao
Copy link
Author

@mrunalp rebased.

@mrunalp
Copy link
Contributor

mrunalp commented May 24, 2016

LGTM

@mrunalp mrunalp merged commit 7543087 into opencontainers:master May 24, 2016
@Mashimiao Mashimiao deleted the add-hooks-bundle-validation branch November 14, 2016 09:34
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