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 apt-get lock held by another process error by retry #82

Conversation

ukablan-wpc
Copy link
Contributor

Fixes PAUX-6388 Failed Upgrade - Could not get lock /var/cache/apt/archives/lock. It is held by process 37677 (python3)

pleskdistup/common/src/util.py Show resolved Hide resolved
pleskdistup/common/src/util.py Outdated Show resolved Hide resolved
pleskdistup/common/src/util.py Outdated Show resolved Hide resolved
pleskdistup/common/src/dpkg.py Outdated Show resolved Hide resolved
pleskdistup/common/src/dpkg.py Outdated Show resolved Hide resolved
cant_get_lock = True

cmd = ["apt-get", "dist-upgrade", "-y"] + APT_CHOOSE_OLD_FILES_OPTIONS
while True:
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use for interval in locked_sleep_intervals instead? This way, we can at least get rid of i and check for it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it's my first thought as well but locked_sleep_intervals could be empty which means no retry at all - so I needed do ... while() in python

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps we could use a retry decorator instead? We just need to find a way to include sleep 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps we should create our own simple decorator for this, as the default one does not support any delay.

Copy link
Contributor Author

@ukablan-wpc ukablan-wpc Oct 3, 2024

Choose a reason for hiding this comment

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

Yes maybe later. Our need is a bit different though: Feed the ("command") decorator with (possibly many) regexp/strings that the program might emit and designates temporary failure.

@ukablan-wpc ukablan-wpc force-pushed the plesk/ukablan/fix/PAUX-6388/retry_when_apt-get_fails_with_lock_err branch from 0911232 to ec98698 Compare October 3, 2024 13:02
@ukablan-wpc ukablan-wpc requested a review from vizovitin October 3, 2024 13:37
pleskdistup/common/src/dpkg.py Outdated Show resolved Hide resolved
pleskdistup/common/src/dpkg.py Show resolved Hide resolved
pleskdistup/common/src/dpkg.py Outdated Show resolved Hide resolved
pleskdistup/common/src/dpkg.py Show resolved Hide resolved
pleskdistup/common/src/dpkg.py Show resolved Hide resolved
pleskdistup/common/src/dpkg.py Outdated Show resolved Hide resolved
pleskdistup/common/src/dpkg.py Outdated Show resolved Hide resolved
pleskdistup/common/src/util.py Outdated Show resolved Hide resolved
pleskdistup/common/src/util.py Outdated Show resolved Hide resolved
pleskdistup/common/src/util.py Show resolved Hide resolved
pleskdistup/common/src/dpkg.py Show resolved Hide resolved
pleskdistup/common/src/dpkg.py Show resolved Hide resolved
pleskdistup/common/src/util.py Outdated Show resolved Hide resolved
pleskdistup/common/src/dpkg.py Outdated Show resolved Hide resolved
pleskdistup/common/src/dpkg.py Show resolved Hide resolved
pleskdistup/common/src/util.py Show resolved Hide resolved
pleskdistup/common/src/util.py Outdated Show resolved Hide resolved
pleskdistup/common/src/util.py Outdated Show resolved Hide resolved
@ukablan-wpc ukablan-wpc requested a review from vizovitin October 7, 2024 11:13
@ukablan-wpc ukablan-wpc force-pushed the plesk/ukablan/fix/PAUX-6388/retry_when_apt-get_fails_with_lock_err branch from 173dc6b to 27a5864 Compare October 7, 2024 13:11
@ukablan-wpc ukablan-wpc requested a review from SandakovMM October 7, 2024 14:07
pleskdistup/common/src/dpkg.py Outdated Show resolved Hide resolved
pleskdistup/common/src/util.py Outdated Show resolved Hide resolved
pleskdistup/common/src/util.py Show resolved Hide resolved
pleskdistup/common/src/dpkg.py Show resolved Hide resolved
pleskdistup/common/src/util.py Outdated Show resolved Hide resolved
@ukablan-wpc ukablan-wpc requested a review from vizovitin October 8, 2024 11:04
pleskdistup/common/src/dpkg.py Outdated Show resolved Hide resolved
Copy link
Contributor

@vizovitin vizovitin left a comment

Choose a reason for hiding this comment

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

Please rebase before merge.

@ukablan-wpc ukablan-wpc force-pushed the plesk/ukablan/fix/PAUX-6388/retry_when_apt-get_fails_with_lock_err branch from eb39210 to 4360058 Compare October 10, 2024 09:33
@ukablan-wpc ukablan-wpc changed the title Fix lock held by another process error of apt-get by retry Fix apt-get lock held by another process error by retry Oct 10, 2024
@ukablan-wpc ukablan-wpc merged commit c8c1939 into main Oct 10, 2024
3 checks passed
@ukablan-wpc ukablan-wpc deleted the plesk/ukablan/fix/PAUX-6388/retry_when_apt-get_fails_with_lock_err branch October 10, 2024 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants