1
0
mirror of https://github.com/home-assistant/supervisor.git synced 2025-12-24 20:35:55 +00:00

Use count-based progress for Docker image pulls

Refactor Docker image pull progress to use a simpler count-based approach
where each layer contributes equally (100% / total_layers) regardless of
size. This replaces the previous size-weighted calculation that was
susceptible to progress regression.

The core issue was that Docker rate-limits concurrent downloads (~3 at a
time) and reports layer sizes only when downloading starts. With size-
weighted progress, large layers appearing late would cause progress to
drop dramatically (e.g., 59% -> 29%) as the total size increased.

The new approach:
- Each layer contributes equally to overall progress
- Per-layer progress: 70% download weight, 30% extraction weight
- Progress only starts after first "Downloading" event (when layer
  count is known)
- Always caps at 99% - job completion handles final 100%

This simplifies the code by moving progress tracking to a dedicated
module (pull_progress.py) and removing complex size-based scaling logic
that tried to account for unknown layer sizes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Stefan Agner
2025-12-01 14:07:21 +01:00
parent 9862499751
commit 91f1f548e5
9 changed files with 1172 additions and 276 deletions

View File

@@ -359,6 +359,8 @@ async def test_api_progress_updates_supervisor_update(
and evt.args[0]["data"]["event"] == WSEvent.JOB
and evt.args[0]["data"]["data"]["name"] == "supervisor_update"
]
# Count-based progress: 4 layers (2 cached = 50%, 2 pulling = 25% each)
# Cached layers contribute immediately when downloading starts
assert events[:4] == [
{
"stage": None,
@@ -367,34 +369,34 @@ async def test_api_progress_updates_supervisor_update(
},
{
"stage": None,
"progress": 0.1,
"progress": 50.0,
"done": False,
},
{
"stage": None,
"progress": 1.7,
"progress": 54.6,
"done": False,
},
{
"stage": None,
"progress": 4.0,
"progress": 62.8,
"done": False,
},
]
assert events[-5:] == [
{
"stage": None,
"progress": 98.2,
"progress": 95.7,
"done": False,
},
{
"stage": None,
"progress": 98.3,
"progress": 97.1,
"done": False,
},
{
"stage": None,
"progress": 99.3,
"progress": 98.4,
"done": False,
},
{