-
Notifications
You must be signed in to change notification settings - Fork 96
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
DockerImage build step #572
base: master
Are you sure you want to change the base?
Conversation
06d6039
to
2cfe178
Compare
2cfe178
to
e024ce1
Compare
@tailhook Could you review the PR |
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.
Other than a bit tricky async code and the absense of docs look good.
Also did you do any semantic changes in tar file handling, except making it more configurable? It's hard to spot if there is something significant changed.
src/builder/commands/docker.rs
Outdated
}); | ||
|
||
let mut layers_tasks = vec!(); | ||
for (digest, tx) in layers_digests.iter().zip(downloaded_layer_txs.into_iter()) { |
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.
Instead of spawning tasks, it's better to use FuturesUnordered
, like this:
let layers = layers_digests.iter().zip(downloaded_layer_txs.into_iter())
.map(|(digest, tx)| {
async move {
// same code as in task
}
})
.collect::<FuturesUnordered<_>>()
.try_collect().await?;
This way you don't need channels (results returned right into the collection), and cancellation works seamlesly.
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.
This way you don't need channels
I need channels to notify an unpack task that a corresponding layer was downloaded. Thus unpacking downloaded layers occurs while other layers are still downloading.
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.
You can put unpack task just next to the download task into the same future, but yeah, you have to wait that previous layer is unpacked, right? So yes, oneshot
is probably a way to ensure that.
I'm considering not doing а concurrent download of docker layers. |
Why? |
With I've tested a concurrent downloading a little. Large images become ready for use faster when their layers are downloaded in a sequence. Especially when the first layer is huge. |
I would rather use mpmc channel for a concurrent layers downloading. But I think it's redundant as the concurrent downloading cannot significantly increase total downloading speed due to limited network bandwidth. |
It's the same issue with spawned futures :) Just add a way to sync this. Something like this: let channels = (0..layers.len()+1).map(|_| oneshot::channel()).collect::<Vec<_>>();
let tx = channels.map(|(tx, _)| tx);
let rx = channels.map(|(tx, _)| rx);
tx.remove(0).send(|()| ()); // Activate first one
layers.zip(tx).zip(rx).map(|((l, tx), rx)| async {
download().await;
rx.recv().await;
unpack().await;
tx.send(()).await;
}).collect::<FuturesUnordered>().await; (and maybe also add a semaphore to limit number of simultaneous downloads)
Downloading in parallel to unpacking, and also setup cost on small files could make it not as clean. But yes, we can try simpler implementation first. Also indicatif is quite useful on big files. |
docs/settings.rst
Outdated
|
||
(default ``[localhost]``) A list of docker insecure registries. |
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.
What is insecure registry? Does it allow no-TLS access?
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.
Yes, insecure registries don't support https
.
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.
Yeah, I mean can you add a tiny clarification to the docs?
Yeah, I know the first implementation also could download image layers out of order.
Progress bar is on the todo list. But I decided to do it later. Guess I can implement it in this PR. |
Updated documentation. We need to know size of a layer to display a downloading progress. But with current |
@tailhook Could you review it and merge if all is OK |
The certificate for ubuntu.zerogw.com expired on 4/23/2022. |
@@ -26,6 +26,7 @@ of empty container): | |||
* :step:`SubConfig` | |||
* :step:`Container` | |||
* :step:`Tar` | |||
* :step:`DockerImage` |
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.
Should this option really use the "Docker" branding in the name? It'd be confusing for the Podman users as well for anything else coming later. I saw that the tests seem to refer to buildah
and the OCI Images. So maybe just play with OCI instead of specific brand names?
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.
Possibly just Image
would be ok. I don't know any other container standarts.
Another choice: FetchImage
Implemented:
registry
,image
,tag
,path
,insecure
!DockerImage python
,!DockerImage python:3.10-slim