Skip to content

Adding ability to change max download attempts (carry 39413)#39949

Merged
thaJeztah merged 1 commit into
moby:masterfrom
thaJeztah:carry_39413
Sep 24, 2019
Merged

Adding ability to change max download attempts (carry 39413)#39949
thaJeztah merged 1 commit into
moby:masterfrom
thaJeztah:carry_39413

Conversation

@thaJeztah

@thaJeztah thaJeztah commented Sep 18, 2019

Copy link
Copy Markdown
Member

carry of #39413
closes #39413

- What I did
Moby works perfectly when you are in a situation when one has a good and stable internet connection. Operating in area's where internet connectivity is likely to be lost in undetermined intervals, like a satellite connection or 4G/LTE in rural area's, can become a problem when pulling a new image. When connection is lost while image layers are being pulled, Moby will try to reconnect up to 5 times. If this fails, the incompletely downloaded layers are lost will need to be completely downloaded again during the next pull request. This means that we are using more data than we might have to.

Pulling a layer multiple times from the start can become costly over a satellite or 4G/LTE connection. As these techniques (especially 4G) quite common in IoT and Moby is used to run Azure IoT Edge devices, I would like to add a settable maximum download attempts. The maximum download attempts is currently set at 5 (distribution/xfer/download.go). I would like to change this constant to a variable that the user can set. The default will still be 5, so nothing will change from the current version unless specified when starting the daemon with the added flag or in the config file.

- How I did it
I added a default value of 5 for DefaultMaxDownloadAttempts and a settable max-download-attempts in the daemon config file. It is also added to the config of dockerd so it can be set with a flag when starting the daemon. This value gets stored in the imageService of the daemon when it is initiated and can be passed to the NewLayerDownloadManager as a parameter. It will be stored in the LayerDownloadManager when initiated. This enables us to set the max amount of retries in makeDownoadFunc equal to the max download attempts.

I also added some tests that are based on maxConcurrentDownloads/maxConcurrentUploads.

- How to verify it
You can pull this version and test in a development container. Either create a config file /etc/docker/daemon.json with {"max-download-attempts"=3}, or use dockerd --max-download-attempts=3 -D & to start up the dockerd. Start downloading a container and disconnect from the internet whilst downloading. The result would be that it stops pulling after three attempts.

- Description for the changelog

Added ability to change the number of reconnect attempts during connection loss while pulling an image by adding max-download-attempts to the config file.

- A picture of a cute animal (not mandatory but encouraged)
cute animal

@Lah123

Lah123 commented Sep 18, 2019

Copy link
Copy Markdown
Contributor

@thaJeztah , thanks for helping with my rebase issue. It seems that everything now works as expected :).

@thaJeztah

Copy link
Copy Markdown
Member Author

oh! needs another rebase, lol

@thaJeztah

Copy link
Copy Markdown
Member Author

rebased

@Lah123

Lah123 commented Sep 19, 2019

Copy link
Copy Markdown
Contributor

That's odd, it did not give that error earlier (unnecessary conversion). With your permission I could try to force push a version without the conversion.

@thaJeztah

Copy link
Copy Markdown
Member Author

Oh, probably because we enabled a new linter; I have the branch open, will push a fix shortly

Moby works perfectly when you are in a situation when one has a good and stable
internet connection. Operating in area's where internet connectivity is likely
to be lost in undetermined intervals, like a satellite connection or 4G/LTE in
rural area's, can become a problem when pulling a new image. When connection is
lost while image layers are being pulled, Moby will try to reconnect up to 5 times.
If this fails, the incompletely downloaded layers are lost will need to be completely
downloaded again during the next pull request. This means that we are using more
data than we might have to.

Pulling a layer multiple times from the start can become costly over a satellite
or 4G/LTE connection. As these techniques (especially 4G) quite common in IoT and
Moby is used to run Azure IoT Edge devices, I would like to add a settable maximum
download attempts. The maximum download attempts is currently set at 5
(distribution/xfer/download.go). I would like to change this constant to a variable
that the user can set. The default will still be 5, so nothing will change from
the current version unless specified when starting the daemon with the added flag
or in the config file.

I added a default value of 5 for DefaultMaxDownloadAttempts and a settable
max-download-attempts in the daemon config file. It is also added to the config
of dockerd so it can be set with a flag when starting the daemon. This value gets
stored in the imageService of the daemon when it is initiated and can be passed
to the NewLayerDownloadManager as a parameter. It will be stored in the
LayerDownloadManager when initiated. This enables us to set the max amount of
retries in makeDownoadFunc equal to the max download attempts.

I also added some tests that are based on maxConcurrentDownloads/maxConcurrentUploads.

You can pull this version and test in a development container. Either create a config
`file /etc/docker/daemon.json` with `{"max-download-attempts"=3}``, or use
`dockerd --max-download-attempts=3 -D &` to start up the dockerd. Start downloading
a container and disconnect from the internet whilst downloading. The result would
be that it stops pulling after three attempts.

Signed-off-by: Lukas Heeren <[email protected]>
Signed-off-by: Sebastiaan van Stijn <[email protected]>
@Lah123

Lah123 commented Sep 19, 2019

Copy link
Copy Markdown
Contributor

Thanks! Now it passes all the tests :).

@thaJeztah thaJeztah left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

LGTM

@thaJeztah

Copy link
Copy Markdown
Member Author

@kolyshkin @vdemeester ptal

@kolyshkin kolyshkin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@thaJeztah

Copy link
Copy Markdown
Member Author

let me get this one in

@thaJeztah
thaJeztah merged commit 30c5ec4 into moby:master Sep 24, 2019
@thaJeztah
thaJeztah deleted the carry_39413 branch September 24, 2019 16:22
@thaJeztah

Copy link
Copy Markdown
Member Author

This needs a follow-up to update the dockerd reference docs; @Lah123 are you interested in making those change in the docker/cli repository?

I think it'll need the new option (both flag and the configuration file option) added in;

@Lah123

Lah123 commented Sep 25, 2019

Copy link
Copy Markdown
Contributor

Sure! I will get to that this or next week.

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.

3 participants