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

check the status of the state passed to hooks over stdin #608

Merged
merged 1 commit into from
May 22, 2018

Conversation

liangchenye
Copy link
Member

Signed-off-by: Liang Chenye liangchenye@huawei.com

@liangchenye
Copy link
Member Author

It is a successor PR of #589.
It only checks prestart status and poststart status.

The poststop status is not meaningful since the container will be deleted and the id might be reused.
I skip the poststop check.

Copy link
Contributor

@wking wking left a comment

Choose a reason for hiding this comment

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

It would be nice to pass the *tap.T into stdinStateCheck so it can add multiple errors instead of dying on the first.

return fmt.Errorf("wrong state %q in the stdin of %s hook, expected %q", state.Status, hookName, "running")
}
case "poststop":
// Not defined by runtime spec
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the current spec wants this to be stopped (more discussion in opencontainers/runtime-spec#958), although more spec clarity would be nice. But what the spec is clear about is that status must be set to something.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll update the code since 'status' must be set to something code. and wait for runtime-spec#958.

@liangchenye
Copy link
Member Author

Now we only output three 'OK or NOT' results, each result may have the detailed property errors information. I join the state property errors of a hook together by using multiple errors.

@dongsupark
Copy link
Contributor

@liangchenye
I happened to see this PR, as it's exactly what @alban and I were going to implement.
Though with this PR, the hooks_stdin.t test fails like it:

not ok 1 - the state of the container MUST be passed to "prestart" hook over stdin
  ---
  {
    "error": "1 error occurred:\n\n* wrong status \"\" in the stdin of prestart hook, expected \"created\"",
    "reference": "https://github.com/opencontainers/runtime-spec/blob/v1.0.0/config.md#posix-platform-hooks"
  }
  ...

It looks like Status is always being set to an empty string.

@wking
Copy link
Contributor

wking commented May 18, 2018

It looks like Status is always being set to an empty string.

That's opencontainers/runc#1741, which I'd also linked from here. I think we should land these better checks here withought waiting for runc to fix its behavior.

@dongsupark
Copy link
Contributor

@wking Thanks for the info.
I'll try to test it with the runc fix later. Anyway I'm fine with merging this PR without waiting for runc.

Signed-off-by: Liang Chenye <liangchenye@huawei.com>
@liangchenye
Copy link
Member Author

rebased PTAL @q384566678

@zhouhao3
Copy link

looks good, But when I run the test, I get the error.
@liangchenye Did you test successfully?

➜  runtime-tools git:(7c6996f) ✗ sudo ./hooks_stdin
TAP version 13
not ok 1 - the state of the container MUST be passed to "prestart" hook over stdin
  ---
  {
    "error": "1 error occurred:\n\n* wrong status \"\" in the stdin of prestart hook, expected \"created\"",
    "reference": "https://github.com/opencontainers/runtime-spec/blob/v1.0.0/config.md#posix-platform-hooks"
  }
  ...
not ok 2 - the state of the container MUST be passed to "poststart" hook over stdin
  ---
  {
    "error": "1 error occurred:\n\n* wrong status \"\" in the stdin of poststart hook, expected \"running\"",
    "reference": "https://github.com/opencontainers/runtime-spec/blob/v1.0.0/config.md#posix-platform-hooks"
  }
  ...
not ok 3 - the state of the container MUST be passed to "poststop" hook over stdin
  ---
  {                             
    "error": "1 error occurred:\n\n* status in the stdin of poststop hook should not be empty",
    "reference": "https://github.com/opencontainers/runtime-spec/blob/v1.0.0/config.md#posix-platform-hooks"
  }
  ...
1..3

@liangchenye
Copy link
Member Author

@q384566678 Yes, it does not work because of the runc bug

@zhouhao3
Copy link

zhouhao3 commented May 22, 2018

LGTM

Approved with PullApprove

@zhouhao3 zhouhao3 merged commit 42377d9 into opencontainers:master May 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants