Fix Mirror sync problem ( take 2 )
What
In !16145 (merged) I made an attempt to fix a flakiness in the CI related to how apt update it's repositories.
However, despite testing, it seems the script introduced in 16145 does not work as intended.
This MR tried to amend to problem and fix the script.
Now we are also able to better test the script locally.
Why
How
The problem in the script was related to the fact that the global
setting for the script set -e was making the script exiting prematurely
before we could attempt a retry on apt.
To fix this problem, in the function apt_get_with_retries I disable set -e
execute apt ( and catch its output ) and then I re-enable set +e . Doing this
I make sure the script continue its execution even if apt-get fails. And we can
retry, for two possible flakiness conditions, to execute the command again.
Manually testing the MR
To execute the script manually, you can use the following command:
DISTRIBUTION=debian RELEASE=bookworm scripts/packaging/tests/systemd-docker-test.sh docs/introduction/install-bin-deb.sh images/packages/debian-systemd-tests.Dockerfile
This will launch locally a container and execute the script within this container.
Instead of running the entire test script docs/introduction/install-bin-deb.sh
you can also run a smaller script ( remember to copy the apt_get_with_retries function ).
For example, in the example below, you can see the second
successful attempt of apt after the --------
$ DISTRIBUTION=debian RELEASE=bookworm scripts/packaging/tests/systemd-docker-test.sh docs/introduction/install-bin-deb.sh images/packages/debian-systemd-tests.Dockerfile
[...]
+ apt_get_with_retries update
+ set +x
-----------
Attempt 1 of 5...
Error detected. Retrying in 1 seconds...
Get:1 http://deb.debian.org/debian bookworm InRelease [151 kB]
Err:1 http://deb.debian.org/debian bookworm InRelease
Unknown error executing apt-key
Get:2 http://deb.debian.org/debian bookworm-updates InRelease [55.4 kB]
Get:3 http://deb.debian.org/debian-security bookworm-security InRelease [48.0 kB]
Get:4 http://deb.debian.org/debian bookworm-updates/main amd64 Packages [13.5 kB]
Get:5 http://deb.debian.org/debian-security bookworm-security/main amd64 Packages [243 kB]
Reading package lists...
W: GPG error: http://deb.debian.org/debian bookworm InRelease: Unknown error executing apt-key
E: The repository 'http://deb.debian.org/debian bookworm InRelease' is not signed.
-----------
Get:1 http://deb.debian.org/debian bookworm InRelease [151 kB]
Hit:2 http://deb.debian.org/debian bookworm-updates InRelease
Hit:3 http://deb.debian.org/debian-security bookworm-security InRelease
Get:4 http://deb.debian.org/debian bookworm/main amd64 Packages [8792 kB]
Fetched 8792 kB in 5s (1940 kB/s)
Checklist
-
Document the interface of any function added or modified (see the coding guidelines) -
Document any change to the user interface, including configuration parameters (see node configuration) -
Provide automatic testing (see the testing guide). -
For new features and bug fixes, add an item in the appropriate changelog ( docs/protocols/alpha.rstfor the protocol and the environment,CHANGES.rstat the root of the repository for everything else). -
Select suitable reviewers using the Reviewersfield below. -
Select as Assigneethe next person who should take action on that MR