You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dlab.apache.org by lf...@apache.org on 2020/09/10 08:43:07 UTC

[incubator-dlab] 01/01: [DLAB-1527]: change manage_pkg function to fix dpkg frontend locker error

This is an automated email from the ASF dual-hosted git repository.

lfrolov pushed a commit to branch DLAB-1527
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git

commit a67986006907e1c7d421a14970c02503e821c79b
Author: leonidfrolov <fr...@gmail.com>
AuthorDate: Tue Sep 8 17:37:12 2020 +0300

    [DLAB-1527]: change manage_pkg function to fix dpkg frontend locker error
---
 .../src/general/lib/os/debian/common_lib.py                    | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/infrastructure-provisioning/src/general/lib/os/debian/common_lib.py b/infrastructure-provisioning/src/general/lib/os/debian/common_lib.py
index 414516f..a5f3984 100644
--- a/infrastructure-provisioning/src/general/lib/os/debian/common_lib.py
+++ b/infrastructure-provisioning/src/general/lib/os/debian/common_lib.py
@@ -43,8 +43,13 @@ def manage_pkg(command, environment, requisites, warn='False'):
                         counter += 1
                         time.sleep(10)
                     else:
-                        allow = True
-                        sudo('sudo dpkg --configure -a')
+                        try:
+                            sudo('sudo dpkg --configure -a', warn_only=warn)
+                        except:
+                            PID = sudo('lsof /var/lib/dpkg/lock-frontend | grep dpkg | awk \'{print $2}\'')
+                            sudo('kill -9 {}'.format(PID))
+                            sudo('rm -f /var/lib/dpkg/lock-frontend')
+                            sudo('sudo dpkg --configure -a')
                         sudo('sudo apt update')
                         try:
                             sudo('apt-get {0} {1}'.format(command, requisites), warn_only=warn)
@@ -55,6 +60,7 @@ def manage_pkg(command, environment, requisites, warn='False'):
                             sudo('rm -f /var/lib/apt/lists/lock')
                             sudo('rm -f /var/cache/apt/archives/lock')
                             sudo('rm -f /var/lib/dpkg/lock')
+                        allow = True
                 elif environment == 'local':
                     if local('sudo pgrep "^apt" -a && echo "busy" || echo "ready"', capture=True) == 'busy':
                         counter += 1


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@dlab.apache.org
For additional commands, e-mail: commits-help@dlab.apache.org