Skip to content

Conversation

@mdegat01
Copy link
Contributor

@mdegat01 mdegat01 commented Aug 16, 2025

Proposed change

When pulling an image during an install or update of something, create a sub job per layer and use that to report progress on that layer. This way Home Assistant receives progress updates for an image pull and would be able to present that in the UI.

This isn't a perfect solution since we're still unable to report on the overall progress of the final image since we don't know how big each layer is until we get there. But it does provide a lot of progress information and could be used to provide users with some sense of progress during these tasks, unlike today.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (which adds functionality to the supervisor)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Ruff (ruff format supervisor tests)
  • Tests have been added to verify that the new code works.

If API endpoints or add-on configuration are added/changed:

@mdegat01 mdegat01 requested a review from agners August 16, 2025 03:51
@mdegat01 mdegat01 added missing-documentation Added to pull requests that needs a docs, but none is linked new-feature A new feature needs-client-library Pull requests needs client library changes but none is linked labels Aug 16, 2025
@home-assistant home-assistant bot marked this pull request as draft August 20, 2025 16:00
@home-assistant
Copy link

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

Comment on lines 260 to 277
# Hopefully these come in order but if they sometimes get out of sync, avoid accidentally going backwards
# If it happens a lot though we may need to reconsider the value of this feature
if job.done:
_LOGGER.debug(
"Received pull image log with status %s for job %s but job was done, skipping",
reference.status,
job.uuid,
)
return

if job.stage and stage < PullImageLayerStage.from_status(job.stage):
_LOGGER.debug(
"Received pull image log with status %s for job %s but job was already on stage %s, skipping",
reference.status,
job.uuid,
job.stage,
)
return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absent from a Docker bug, I can't see how this would happen. We connect through a unix socket which is not packet based but a stream, it guarantee things being in order (just like TCP). So unless Docker sends it in the wrong order, or our bus reorder things, this really should never happen!

I'd not make this a debug log, it is very unlikely we'd ever notice this. I'd raise severity to error here, and maybe even send to Sentry so we can start investigate why that happens.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absent from a Docker bug, I can't see how this would happen.

I agree. This wasn't actually what I was worried about though. We are reading in these logs in the executor. We are then scheduling a task on the normal event loop per log called fire_event. Then that is scheduling another task on the normal event loop per listener listening for that event to process it.

My concern is that all this task scheduling will cause us to process them out of order. Not that docker will actually give them to us out of order.

I'd raise severity to error here, and maybe even send to Sentry

I'd rather only send it to sentry tbh. Given what we're talking about I don't think the impact on the user is enough to raise it to their attention. If they miss a few of the 100 ms progress updates that really doesn't matter much. But we would like to know about it. Maybe time to make use of that capture_event API in Sentry rather then capture_exception

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok added a new type of exception for this called DockerLogOutOfOrder. Raising and capturing it in sentry.

I'm still logging at debug level for now because I don't think users really need to know about this. Let me know if you want me to bump the severity in addition to capturing it in sentry.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is fine by me, with the Sentry capture we'll definitely notice if that happens in practice 👍 .

@mdegat01 mdegat01 force-pushed the image-install-progress-updates branch from 3ba493d to 70ddf1d Compare August 21, 2025 19:02
@mdegat01 mdegat01 marked this pull request as ready for review August 21, 2025 19:05
@home-assistant home-assistant bot requested a review from agners August 21, 2025 19:05
Copy link
Member

@agners agners left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@agners agners merged commit 207b665 into main Aug 22, 2025
22 checks passed
@agners agners deleted the image-install-progress-updates branch August 22, 2025 08:41
@github-actions github-actions bot locked and limited conversation to collaborators Aug 24, 2025
@mdegat01 mdegat01 removed missing-documentation Added to pull requests that needs a docs, but none is linked needs-client-library Pull requests needs client library changes but none is linked labels Sep 4, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants