Skip to content

Retry the Package Upgrade Once After a Mirror Mismatch in upgrade-host.sh #4530

Done

Description

@ptr727

Problem

host-setup/linux/upgrade-host.sh runs apt_get update and then apt_get full-upgrade once each. When a third-party repository's index and its files are briefly out of step, full-upgrade exits 100 and the whole transaction is dropped. A nightly-republished channel is the usual cause. Every other pending upgrade is lost along with the one bad package, and the host's nightly maintenance reports failed: packages.

Seen 2026-11-28 on a fleet host tracking Netdata's nightly edge repository. Two of its 21 pending upgrades came back a few bytes larger than the Packages index said:

Err:1 http://repository.netdata.cloud/repos/edge/ubuntu noble/ netdata-plugin-pythond 2.13.0.145.nightly
  File has unexpected size (174088 != 174074). Mirror sync in progress?
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

The mirror had converged a few hours later, with both files back to the index's sizes, and a re-run of the same step passed with all 21 upgrades. This was the first failure in 30 days of nightly runs, so the cost is low. Still, every occurrence is a false "maintenance failed" alert, and the upgrades stay held until the next night.

Proposal

  • Add -o Acquire::Retries=3 to APT_OPTS, which covers a transient network fault on a single fetch.
  • On a failed full-upgrade (and upgrade --without-new-pkgs), wait a bounded delay (for example 60 to 120 s), re-run apt_get update, and retry the upgrade once. The size or hash mismatch case needs this, since Acquire::Retries re-fetches against the same stale index. If the second attempt fails, exit non-zero as today, so a persistent fault still surfaces.

Not in scope

Changing which channel a host's third-party repository tracks. That is the carrying repository's choice.

Activity

  1. added
    enhancement
    script
    on Nov 28, 2026
  2. added a commit that references this issue on Nov 28, 2026
    b6765e4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementscript

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions