Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

cli: add guest hook path option (v2) #834

Merged
merged 1 commit into from
Oct 30, 2018

Conversation

flx42
Copy link
Contributor

@flx42 flx42 commented Oct 17, 2018

Replaces #720

Copy link
Member

@bergwolf bergwolf left a comment

Choose a reason for hiding this comment

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

Just two minor comments. Otherwise looks good to me.

Gopkg.toml Outdated
@@ -24,7 +24,7 @@

[[constraint]]
name = "github.com/opencontainers/runtime-spec"
revision = "4e3b9264a330d094b0386c3703c5f379119711e8"
revision = "5806c35637336642129d03657419829569abc5aa"
Copy link
Member

Choose a reason for hiding this comment

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

In the introduced spec changes, I don't see any hooks related change. Why do you need to update runtime-spec?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because of this: https://github.com/kata-containers/agent/blob/master/Gopkg.toml#L19

$ sed -i 's/7e8e20b10b71fe3044a24175b8a686421e9d2c24/03f040f14dceb858f6411db275fcac77f9f42a8d/' Gopkg.toml
$ dep ensure -update github.com/kata-containers/agent
Solving failure: No versions of github.com/kata-containers/agent met constraints:
        03f040f14dceb858f6411db275fcac77f9f42a8d: Could not introduce github.com/kata-containers/agent@03f040f14dceb858f6411db275fcac77f9f42a8d, as it has a dependency on github.com/opencontainers/runtime-spec with constraint 5806c35637336642129d03657419829569abc5aa, which has no overlap with existing constraint 4e3b9264a330d094b0386c3703c5f379119711e8 from (root)
[...]

Makefile Outdated
@@ -149,6 +149,7 @@ DEFENABLEDEBUG := false
DEFDISABLENESTINGCHECKS := false
DEFMSIZE9P := 8192
DEFHOTPLUGVFIOONROOTBUS := false
DEFGUESTHOOKPATH :=
Copy link
Member

Choose a reason for hiding this comment

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

If the default value is empty, please drop DEFGUESTHOOKPATH.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will use /usr/share/oci/hooks, if that's fine for you. The option is commented by default anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I missed the part where it's used for generating default values in a Go file.
To untangle the two I can remove the template from the toml file and put /usr/share/oci/hooks, and drop this variable from the Makefile. Is that what you prefer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated my PR with what I mentioned above, in case my description was not clear. Let me know if I should change it back.

@@ -167,6 +167,13 @@ enable_iothreads = @DEFENABLEIOTHREADS@
# all practical purposes.
#entropy_source= "@DEFENTROPYSOURCE@"

# If set to an absolute path within the guest rootfs, the agent will search
# this directory for OCI hooks and add them to the guest container's lifecycle.
Copy link
Member

Choose a reason for hiding this comment

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

Please emphasize the fact that the hooks are executed in the guest rather than in the host.

Copy link
Contributor

Choose a reason for hiding this comment

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

You could also add a comment along the lines of:

This is an advanced option. Since OCI hooks are always run on the host, most users can leave this variable unset.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jodh-intel

Since OCI hooks are always run on the host

Did you mean "guest"? Or are you referring to OCI hooks from the original OCI runtime spec?

@jodh-intel
Copy link
Contributor

For the re-vendoring, please can you list all the commits pulled in to those vendor packages using git log as specified here:

Copy link
Contributor

@jodh-intel jodh-intel left a comment

Choose a reason for hiding this comment

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

Hi @flx42 - Thanks for raising! Just a few minor comments.

@@ -167,6 +167,13 @@ enable_iothreads = @DEFENABLEIOTHREADS@
# all practical purposes.
#entropy_source= "@DEFENTROPYSOURCE@"

# If set to an absolute path within the guest rootfs, the agent will search
# this directory for OCI hooks and add them to the guest container's lifecycle.
Copy link
Contributor

Choose a reason for hiding this comment

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

You could also add a comment along the lines of:

This is an advanced option. Since OCI hooks are always run on the host, most users can leave this variable unset.

@flx42
Copy link
Contributor Author

flx42 commented Oct 18, 2018

For the re-vendoring, please can you list all the commits pulled in to those vendor packages using git log as specified here

Given that I need to update runtime-spec too (see #834 (comment)), should I split the revendoring commit in two?

@raravena80
Copy link
Member

@flx42 @jodh-intel any updates? Thx.

@flx42
Copy link
Contributor Author

flx42 commented Oct 22, 2018

@raravena80 I'm waiting for more feedback. I don't think I need to change anything else, unless I missed something.

# of the guest. See the official documentation:
# https://github.com/opencontainers/runtime-spec/blob/v1.0.1/config.md#posix-platform-hooks
# Hooks must be stored in a subdirectory of guest_hook_path named after the
# hook type, e.g. prestart hooks must be in "guest_hook_path/prestart/"
Copy link
Contributor

Choose a reason for hiding this comment

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

A few points that I think need to be clarified in this comment:

  • When you say, "Path to OCI hook binaries in the guest rootfs" do you mean that this path must already exist in the (implicitly custom) image?
  • What order will hooks be called in?
  • Do hooks have to be executable? If not, is this logged?
  • If I create guest_hook_path/prestart/foo/bar/baz.sh, will it be run? You use the term "search" above which might imply "recursive" unless you specify the precise behaviour :)
  • It would be worth noting what is / isn't logged (success, failure, hook name being executed) and where it gets logged.
  • It probably wouldn't hurt to list all the sub-directories that will be checked for hooks (since there are only 3 of them).
  • I still think the comment needs to be clearer in stating that this is entirely optional and that the "normal" set of OCI hooks will be run (on the host) regardless. It needs to be clearer that these are an "additional" set of hooks I think.

@jodh-intel
Copy link
Contributor

Hi @flx42 - thanks for updating the re-vendor commit. However, please can you add details to the main commit. Yes, our process does have a certain amount of redundancy (since there is a reference to the github issue), but after yesterday, I think it's clear we cannot necessarily assume full access to this site so we always add in full descriptions in the commit message as well as on the issue "just in case" :)

@jodh-intel
Copy link
Contributor

Once these two quick-to-fix issues have been addressed, I think we'll be good to go on this PR.

@jodh-intel
Copy link
Contributor

btw - please do ping us here as a simple re-push is silent and we often don't notice as a result ;)

@amshinde
Copy link
Member

amshinde commented Oct 23, 2018

lgtm

Approved with PullApprove

@amshinde
Copy link
Member

/test

@codecov
Copy link

codecov bot commented Oct 23, 2018

Codecov Report

Merging #834 into master will increase coverage by 0.57%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master     #834      +/-   ##
==========================================
+ Coverage   65.71%   66.28%   +0.57%     
==========================================
  Files          88       87       -1     
  Lines       10692    10591     -101     
==========================================
- Hits         7026     7020       -6     
+ Misses       2926     2866      -60     
+ Partials      740      705      -35

@flx42
Copy link
Contributor Author

flx42 commented Oct 24, 2018

Updated :)

@caoruidong
Copy link
Member

/test

@jodh-intel
Copy link
Contributor

jodh-intel commented Oct 24, 2018

Thanks @flx42!

lgtm

A couple of CI builds failed due to timeouts so I've restarted them.

Approved with PullApprove

@WeiZhang555
Copy link
Member

WeiZhang555 commented Oct 29, 2018

Runtime-spec and agent are updated in another PR, so I think you can drop the "vendor" commit to resolv the conflicts.

Another hint is that if you want to replace your previous PR, you can just amend your original commits and push -f to same branch, another PR isn't necessary. See https://github.com/kata-containers/community/blob/master/CONTRIBUTING.md#normal-pr-workflow

Thanks for doing this feature! 😄

LGTM

Approved with PullApprove

@flx42
Copy link
Contributor Author

flx42 commented Oct 29, 2018

Another hint is that if you want to replace your previous PR, you can just amend your original commits and push -f to same branch, another PR isn't necessary

The previous PR wasn't from me :)

Copy link
Member

@bergwolf bergwolf left a comment

Choose a reason for hiding this comment

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

Please rebase to resolve merge conflicts though. Thanks!

Add support for specifying an optional drop-in path for guest OCI hooks.
This is the runtime side for leveraging the agent change introduced in
kata-containers/agent@980023e

Fixes: kata-containers#720

Co-authored-by: Edward Guzman <[email protected]>
Co-authored-by: Felix Abecassis <[email protected]>
Signed-off-by: Felix Abecassis <[email protected]>
@flx42
Copy link
Contributor Author

flx42 commented Oct 29, 2018

Rebased on master and dropped the revendoring commit.

@bergwolf
Copy link
Member

/test

@WeiZhang555
Copy link
Member

Merging. Thanks for your nice patch! @flx42

@WeiZhang555 WeiZhang555 merged commit 58ce1b8 into kata-containers:master Oct 30, 2018
egernst pushed a commit to egernst/runtime that referenced this pull request Feb 9, 2021
The agent needs to update device entries in the OCI spec so that it has the
correct major:minor numbers for the guest, which may differ from the host.

Entries in the main device list are looked up by device path, but entries
in the device resources list are looked up by (host) major:minor.  This is
done one device at a time, updating as we go in updateSpecDeviceList().

But since the host and guest have different namespaces, one device might
have the same major:minor as a different device on the host.  In that case
we could update one resource entry to the correct guest values, then
mistakenly update it again because it now matches a different host device.

To avoid this, rather than looking up and updating one by one, we make all
the lookups in advance, creating a map from (host) device path to the
indices in the spec where the device and resource entries can be found.

Fixes: kata-containers#834

Signed-off-by: David Gibson <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants