fix: add timeout to apt update to prevent indefinite hang on network issues#5553
Open
Bruce6X wants to merge 1 commit into
Open
fix: add timeout to apt update to prevent indefinite hang on network issues#5553Bruce6X wants to merge 1 commit into
Bruce6X wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
installdependencies.shis executed by the Azure VM Extension on every VMSS reimage. It callsapt update && apt install ...with no timeout. When any apt source is unreachable, apt update hangs indefinitely in CLOSE_WAIT state, blocking apt install from running and preventing agent startup.Observed in production:
In both cases, confirmed via
ss -tnpshowing CLOSE_WAIT connections held by /usr/lib/apt/methods/https subprocess with no timeout.Description
Add a 120-second timeout to apt update and apt-get update calls. Treat failure as non-fatal (print warning and continue) so apt install can still run against the locally cached package index on the VM.
Risk Assessment (Low / Medium / High)
Low. The change only affects behavior when apt update fails or times out — in the normal case (network available) behavior is unchanged. The locally cached package index is sufficient for apt install to satisfy the required dependencies in most cases.
Unit Tests Added or Updated (Yes / No)
No. This is a shell script change with no existing unit test framework.
Additional Testing Performed
Manually verified on Ubuntu 24.04 VMSS VMs:
Change Behind Feature Flag (Yes / No)
No. Feature flags are not applicable to agent installation scripts.
Tech Design / Approach
Replace apt update && apt install ... with two separate commands:
Documentation Changes Required (Yes/No)
No.
Logging Added/Updated (Yes/No)
Yes. A warning message is printed when apt update fails or times out, to aid diagnosis.
Telemetry Added/Updated (Yes/No)
No.
Rollback Scenario and Process (Yes/No)
Low risk — revert the two changed lines to restore original && behavior. No state changes or migrations involved.
Dependency Impact Assessed and Regression Tested (Yes/No)
Yes. Change is limited to the apt/apt-get update step on Debian-based systems. All subsequent apt install calls are unchanged. No impact on Fedora, SUSE, Alpine, or Mariner code paths.