-
Notifications
You must be signed in to change notification settings - Fork 95
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
CDH | add image pull API #608
CDH | add image pull API #608
Conversation
Do you think we should do this before doing encryped/signed images in Kata? Also, are we going to run into problems here if we don't have init-data supported? I saw you mentioned some problems with provisioning the config file on your encrypted image PR. |
@fitzthum Before initdata is implemented, the config for CDH is hard to inject so we might need to wait for that. So logically we might still merge to main with what we are doing, and then initdata, and then this PR and move things to CDH in kata. |
4e1d4d3
to
e021335
Compare
e021335
to
2a5588e
Compare
Ok, for image decryption, it does not work because some dead lock happens inside ocicrypt-rs. let me try to refactor some code inside ocicrypt-rs to make it work |
4f9c7ca
to
e23effe
Compare
@@ -37,7 +37,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { | |||
.include("src/utils") | |||
.rust_protobuf() | |||
.customize(ttrpc_codegen::Customize { | |||
async_all: true, | |||
async_all: false, |
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.
Hi @arronwy , I changed the ttrpc client to sync here. Please take a look if it is good to you
1017c52
to
1b8e10c
Compare
Sorry to ping, now it passes! Hi @fitzthum @stevenhorsman I think this is now ready for review. |
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.
A few comments/questions from me, but overall it's looking good.
c808e1d
to
64255ea
Compare
64255ea
to
3de4344
Compare
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.
Nice. A couple initial comments.
17710a4
to
c9fbddd
Compare
cc @bpradipt |
I think an error below for s390x looks legit:
Thanks! |
this error is not related to this PR. Probably we could fix it in another pr then |
316ac26
to
3fd0233
Compare
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.
A few more comments. These are mainly about the config file. I think we can take this opportunity to clarify a lot of our parameter names.
We should also make sure we have really clear documentation of all the parameters either in the source or in the sample config.
6cd213a
to
0c02ec5
Compare
@fitzthum I changed the config names, ptal |
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.
Looking good. I appreciate the changes to the config. I think combining the flags to enable the features with the URIs was a good idea.
I have a few more comments. Let's just try to settle on the names for the parameters. We can tweak the descriptions in a follow-up.
0c02ec5
to
a83b1f2
Compare
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.
Overall code looks good to me. LGTM ! thanks @Xynnn007
a83b1f2
to
3190f33
Compare
Just did a rebase to resolve conflicts. |
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 left one possibly suggestion but generally I think this is good.
I can live with no_proxy
for now I guess and we can clean up the docs a little bit later.
|
||
if let Some(number) = config.image.max_concurrent_layer_downloads_per_image { | ||
image_client.config.max_concurrent_download = number; | ||
} |
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.
Do you think it would make sense to move this logic into the initializer for the image_client
(and pass config.image
into that) rather than putting all this image-specific stuff in this function?
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.
There are some barriers because the parameters is different from image-rs
's. If you are worrying about the exposion of the args of iamge_client
, we can add a Builder
logic to ImageClient
. If you are worrying about the duplication of settings, we could do a refactoring upon image-rs to have a ClientBuilder
logic to make it better.
wdyt?
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 guess the fundamental issue is duplication. We have configs for image-rs but we also have the image config for the CDH. Ideally those might be the same thing, which would simplify this code. That would take some messing around, though, so we can skip it for now.
This commit adds a new API `pull_image()` for Confidential DataHub. This new api will converge all operations related to image pull to one API, hinting that image signature validation, auth file retrievement, security policy enforcement will all be done inside CDH. Related configurations is included in CDH's config.image item. Signed-off-by: Xynnn007 <xynnn@linux.alibaba.com>
actions-rs/toolchain@v1 is now out of data. Also, we need extra permission to run CDH tests. Signed-off-by: Xynnn007 <xynnn@linux.alibaba.com>
The original ttrpc keyprovider client is marked `async`, but we use it as sync version by fork a new thread and create a new tokio runtime. This commit changes the client into sync version, this will match the original usage. Why we need this commit is the original fork-thread-and-tokio-runtime way would create a dead lock for CDH's image-pull API when an encrypted image is pulled. When we bring in a tokio::spawn_blocking in image-rs, the tokio runtime would have possibility to switch context thus a dead lock can be avoided. Signed-off-by: Xynnn007 <xynnn@linux.alibaba.com>
meta_store stores the metadata about the pulled images. Using Mutex would block the concurrent performance when there are few write cases to meta_store, like pulling a lot of pulled images. Signed-off-by: Xynnn007 <xynnn@linux.alibaba.com>
meta store json file records the current state of pulled images and the layers. Before this commit, the json file is not ever written back to local filesystem. For legacy CoCo, everytime a new pull request comes, a new ImageClient would be specified a new workdir, thus there is no re-use of the meta-store and works fine. With this commit, when a ImageClient with same workdir restarts, it still can share the same metadata of pulled images. Signed-off-by: Xynnn007 <xynnn@linux.alibaba.com>
Before this commit, different Overlayfs mounts of a same ImageClient would mark its mounts as 1, 2, 3... Thus there will be 0,1,2... under $work_dir/overlayfs. If a ImageClient with same work dir launches, new mounts will fail as the original index cannot be correctly read from the meta store json file. To make it easy, we changed the way to distinguish different mounts, by calculating a hash from (overlay layer paths, mount paths, time). As the three variables should not be the same, thus we could avoid collisions of overlayfs working dir. Signed-off-by: Xynnn007 <xynnn@linux.alibaba.com>
/run is a tmpfs workdir that would live inside guest memory for CoCo, while `/var/lib` is on disk. This would help CDH to avoid setting another default image workdir. As image-rs is able to set any workdir from its config, this patch will not influence the flexibility. Signed-off-by: Xynnn007 <xynnn@linux.alibaba.com>
3190f33
to
8480ae9
Compare
This commit adds a new API
pull_image()
for Confidential DataHub. This new api will converge all operations related to image pull to one API, hinting that image signature validation, auth file retrievement, security policy enforcement will all be done inside CDH.Related configurations is included in CDH's config.image item.
Although the basic workflow passes due to the unit test, let's keep this PR as draft because some details still needs to promote.
Related to kata-containers/kata-containers#9266