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

Provisioning error - apt-get update - lock error #3

Open
MatthiasHertel opened this issue Jan 12, 2020 · 7 comments
Open

Provisioning error - apt-get update - lock error #3

MatthiasHertel opened this issue Jan 12, 2020 · 7 comments

Comments

@MatthiasHertel
Copy link

Hi @rgl

i have a weird issue: i think it only occurs sporadically
pve2: E: Could not get lock /var/lib/apt/lists/lock - open (11: Resource temporarily unavailable)

maybe its a race-condition .. the network is not available yet on the node and he trying to upgrade packages ? or there is an running apt upgrade behind the scene and so he failed ?
i am wondered about this occurs on the second node ...

see screenshot:
image

kind regards
matthias

@rgl
Copy link
Owner

rgl commented Jan 12, 2020

Never seen that happening before, and indeed its somewhat odd.

The network should be available at that point because vagrant is using it to run those commands in a SSH connection.

Maybe the logs inside that 2nd node have the reason?

@MatthiasHertel
Copy link
Author

i guess the nodes are not ready for the apt-get update command, i insert a simple sleep command and now it works .... see diff:

diff --git a/provision.sh b/provision.sh
index 25d6d2b..3a25cc8 100644
--- a/provision.sh
+++ b/provision.sh
@@ -16,6 +16,7 @@ dn=$(hostname)
 export DEBIAN_FRONTEND=noninteractive
 
 # update the package cache.
+sleep 100
 apt-get update
 
 # configure the network.

i am trying to investigate this issue with an up / down loop see:

for i in {1..3}; do vagrant destroy -f; vagrant up --provider=libvirt; done

@rgl
Copy link
Owner

rgl commented Jan 12, 2020

like you said before, it really seems that something else is trying to use apt-get, maybe there's a systemd unit that does automatic updates / checks at boot?

@MatthiasHertel
Copy link
Author

yes I think so too, that another process is blocking apt

the provision.sh should check if apt is running, and wait for it if it is not "free"

something like this:

fuser /var/lib/dpkg/lock 

@MatthiasHertel
Copy link
Author

MatthiasHertel commented Jan 12, 2020

lgtm:

#!/bin/bash

i=0
tput sc
while fuser /var/lib/dpkg/lock >/dev/null 2>&1 ; do
    case $(($i % 4)) in
        0 ) j="-" ;;
        1 ) j="\\" ;;
        2 ) j="|" ;;
        3 ) j="/" ;;
    esac
    tput rc
    echo -en "\r[$j] Waiting for other software managers to finish..." 
    sleep 0.5
    ((i=i+1))
done 

/usr/bin/apt-get "$@"

@rgl
Copy link
Owner

rgl commented Jan 12, 2020

it looks good to be used in the terminal but I'm afraid it might not work when started from vagrant (it does not emulate a terminal).

did you understood what was/is using apt-get?

@pgporada
Copy link

pgporada commented Apr 20, 2021

As a workaround you can run the following. It's slow because it's serial, but it'll get the job done.

vagrant up --provider=libvirt
vagrant provision gateway
vagrant provision pve1
vagrant up pve2 --no-destroy-on-error --provider=libvirt
vagrant provision pve2
vagrant up pve3 --no-destroy-on-error --provider=libvirt
vagrant provision pve3

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

No branches or pull requests

3 participants