juju / charm-helpers

Apache License 2.0
18 stars 127 forks source link

Fail and retry on "Some index files failed to download" #911

Open nobuto-m opened 1 month ago

nobuto-m commented 1 month ago

APT doesn't error out even in the following case since it's a warning instead of an error. And it allows charms to move on without having a proper APT index and let them install unwanted versions of software for example. The apt_update part should fail if it's marked as fatal in such cases so that it can be retried or charm can raise it as an error to users appropriately.

"--error-on=any" is supported for >= bionic. https://bugs.launchpad.net/ubuntu/+source/apt/+bug/1693900

Closes: #910

[w/o "--error-on=any"]

$ sudo apt-get update; echo $?

...

Err:2 http://security.ubuntu.com/ubuntu jammy-security InRelease
  Could not connect to squid-deb-proxy.lxd:8000 (10.0.8.2).
    - connect (113: No route to host)
Err:1 http://archive.ubuntu.com/ubuntu jammy InRelease
  Could not connect to squid-deb-proxy.lxd:8000 (10.0.8.2).
    - connect (113: No route to host)
Err:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease
  Unable to connect to squid-deb-proxy.lxd:8000:
Err:4 http://archive.ubuntu.com/ubuntu jammy-backports InRelease
  Unable to connect to squid-deb-proxy.lxd:8000:
Reading package lists... Done
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/jammy/InRelease
  Could not connect to squid-deb-proxy.lxd:8000 (10.0.8.2).
    - connect (113: No route to host)
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/jammy-updates/InRelease
  Unable to connect to squid-deb-proxy.lxd:8000:

...

W: Some index files failed to download. They have been ignored, or old ones used instead.

-> 0

[w/ "--error-on=any"]

$ sudo apt-get --error-on=any update; echo $?

...

E: Some index files failed to download. They have been ignored, or old ones used instead.

-> 100