Skip to content

Test: Retry apt and snap downloads#1140

Merged
roosterfish merged 5 commits intocanonical:mainfrom
roosterfish:retry_downloads
Dec 12, 2025
Merged

Test: Retry apt and snap downloads#1140
roosterfish merged 5 commits intocanonical:mainfrom
roosterfish:retry_downloads

Conversation

@roosterfish
Copy link
Contributor

@roosterfish roosterfish commented Dec 12, 2025

Try to better deal with stability issues in the infrastructure when performing apt/snap downloads.

Also added a commit to drop the check_snap_channels func to reduce noise in the pipeline summary page.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a retry mechanism to handle transient failures when downloading packages from external sources during test execution. The changes add a retry() function that attempts operations up to 10 times with exponential backoff (5, 10, 15... 50 seconds between retries).

  • Implements a new retry() helper function with exponential backoff
  • Wraps all apt-get update/install operations with retry logic
  • Wraps all snap refresh and snap install operations (from external sources) with retry logic

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
test/includes/microcloud.sh Adds the retry() function and wraps apt-get and snap install commands in the system setup with retry logic
test/suites/upgrade.sh Wraps all snap refresh commands during upgrade tests with retry logic to handle download failures
test/suites/basic.sh Wraps snap refresh command in the service mismatch test with retry logic

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

This allows running an arbitrary command ten times.

Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
As we are now running tests actively on both edge and candidate channels, we should rather not have this check
to also keep the noise on the pipeline summary page low.

Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
@roosterfish roosterfish marked this pull request as ready for review December 12, 2025 13:58
Comment on lines +1291 to +1292
retry lxc exec "${name}" -- snap install snapd
retry lxc exec "${name}" -- snap install yq
Copy link
Member

Choose a reason for hiding this comment

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

For another PR, yq is best installed with apt-get on 24.04 as it's faster than pulling the snap.

For now, I think just snap install yq will also bring snapd

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yes, I remember you providing this hint some time ago, most likely in the LXD CI repo when I was adding checks for the backup configs which use YAML.
Will fix in a follow up PR.

@@ -723,7 +723,7 @@ test_service_mismatch() {
reset_systems 1 3 1

lxc exec micro01 -- sh -c "echo 1 > /proc/sys/net/ipv6/conf/enp5s0/disable_ipv6"
Copy link
Member

Choose a reason for hiding this comment

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

Unrelated but the sh wrapper could be avoided:

Suggested change
lxc exec micro01 -- sh -c "echo 1 > /proc/sys/net/ipv6/conf/enp5s0/disable_ipv6"
lxc exec micro01 -- sysctl net.ipv6.conf.eth0.disable_ipv6=1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, let me fix this in a follow up.

@roosterfish roosterfish merged commit 9a47ebe into canonical:main Dec 12, 2025
52 of 53 checks passed
@roosterfish roosterfish deleted the retry_downloads branch December 12, 2025 15:19
roosterfish added a commit that referenced this pull request Dec 12, 2025
Just found two more snap installs in our custom `system-test` GH action.
One of them just recently failed here during install:
https://github.com/canonical/microcloud/actions/runs/20171402120/job/57908105443?pr=1132.

To reuse the same `retry` func, I am sourcing the respective file.

The PR also addresses the comments in
#1140.
roosterfish added a commit that referenced this pull request Dec 12, 2025
Backports until 1817b57 (December 12,
2025)
Skipped commits:
*
950ae87
(respective MicroCeph docs not yet released for squid)

Open as draft until the LXD 6.6 support PR is merged so we can also
include those commits.

Closes #1113.
Closes #1107.

Can only be merged after
#1140.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants