Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix blocking image observer #7760

Closed
wants to merge 5 commits into from

Conversation

chiting
Copy link

@chiting chiting commented Dec 1, 2024

I'm not very good with python but I figured this should fix some issues happening when running locally with Podman.

I'm also not sure how it behaves with Docker or other alternatives (like Colima).

Which issue(s) does this change fix?

#7298

Why is this change necessary?

Calling the events function from the main thread will block until it receives data as docker-py uses urllib3.openurl under the hood which is blocking (read).

It can be replicated using curl:

# my docker.sock is a symlink to podman API socket
% curl -vv --unix-socket /var/run/docker.sock 'http://localhost/v1.35/events?filters=%7B%22type%22%3A+%5B%22image%22%5D%7D'

The above will block until it receives data.

How does it address the issue?

We don't want to block the main thread, so moving the self.events assignment in a thread (the function that actually watches for changes) seems to be the solution.

What side effects does this change have?

I can't see any side effect this would introduce.

Mandatory Checklist

PRs will only be reviewed after checklist is complete

  • Add input/output type hints to new functions/methods
  • Write design document if needed (Do I need to write a design document?)
  • Write/update unit tests
  • Write/update integration tests
  • Write/update functional tests if needed
  • make pr passes
  • make update-reproducible-reqs if dependencies were changed
  • Write documentation

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Calling the events function from the main thread will block until it receives data as docker-py uses urllib3.openurl under the hood which is blocking (read). Moving the self.events assignment in a thread.
@chiting chiting requested a review from a team as a code owner December 1, 2024 21:27
@chiting chiting requested review from mndeveci and hnnasit December 1, 2024 21:27
@github-actions github-actions bot added pr/external stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels Dec 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr/external stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant