Skip to content

Throw LockFailedException if apt cmd encounters a lock file #81754

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

Open
wants to merge 2 commits into
base: devel
Choose a base branch
from

Conversation

chrispbailey
Copy link

@chrispbailey chrispbailey commented Sep 21, 2023

SUMMARY

Fixes #78658

ISSUE TYPE
  • Bugfix Pull Request
ADDITIONAL INFORMATION

An earlier attempt (#78658) to fix this issue didn't work for me because because DPkg::Lock::Timeout is an apt parameter not a dpkg one.

The code supports the lock_timeout parameter but the problem here is that the when the lock issue is encountered, the code subsequently runs m.fail_json which then calls sys.exit and this bypasses the except apt.cache.LockFailedException handler so the cmd is never re-tried.

I'm sure there are better solutions to this issue but I'm raising this PR here just in case others want to use this solution by overriding apt.py locally.

@ansibot ansibot added bug This issue/PR relates to a bug. needs_triage Needs a first human triage before being processed. module This issue/PR relates to a module. has_issue needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Sep 21, 2023
@ansibot
Copy link
Contributor

ansibot commented Sep 21, 2023

The test ansible-test sanity --test pylint [explain] failed with 2 errors:

lib/ansible/modules/apt.py:823:0: trailing-whitespace: Trailing whitespace
lib/ansible/modules/apt.py:825:0: trailing-whitespace: Trailing whitespace

The test ansible-test sanity --test pep8 [explain] failed with 3 errors:

lib/ansible/modules/apt.py:823:1: W293: blank line contains whitespace
lib/ansible/modules/apt.py:825:1: W293: blank line contains whitespace
lib/ansible/modules/apt.py:1548:1: E305: expected 2 blank lines after class or function definition, found 1

click here for bot help

@ansibot ansibot removed the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. label Sep 21, 2023
@mattclay mattclay removed the needs_triage Needs a first human triage before being processed. label Sep 21, 2023
@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Oct 5, 2023
Copy link
Contributor

@jborean93 jborean93 left a comment

Choose a reason for hiding this comment

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

Thanks for PR, are you able to create a changelog fragment for this bugfix as per https://docs.ansible.com/ansible/latest/community/development_process.html#creating-changelog-fragments. It would also be great to have an integration test for at least some of the scenarios, it could potentially be done by having an async task that locks the file while you then run a normal task that expects the lock to be there and fail after the timeout.

@ansibot ansibot added the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. label May 15, 2024
@ansibot ansibot added the needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI. label Jan 4, 2025
@webknjaz
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@webknjaz
Copy link
Member

@mattclay @sivel this is an example PR that #84375 / #84402 would've helped with.

@ansibot ansibot removed needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. labels Jan 21, 2025
@webknjaz webknjaz added needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html ci_verified Changes made in this PR are causing tests to fail. labels Jan 21, 2025
@ansibot ansibot added stale_pr This PR has not been pushed to for more than one year. and removed needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html labels Jan 21, 2025
@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects_2.17 bug This issue/PR relates to a bug. ci_verified Changes made in this PR are causing tests to fail. has_issue module This issue/PR relates to a module. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. stale_pr This PR has not been pushed to for more than one year.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

apt module with lock_timeout option not working as expected
5 participants