"Resource busy" errors on Ubuntu VM

Yesterday, our CircleCI builds suddenly started failing for the stage where we run sudo apt-get install -y...

#!/bin/bash -eo pipefail
sudo apt-get install -y attr
Reading package lists... Done


Building dependency tree       


Reading state information... Done

Package attr is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'attr' has no installation candidate
Exited with code 100

We have multiple jobs and all of them run a command step that installs one dependency on the ubuntu-1604:201903-01 machine we’ve specified.

commands:
  setup:
    steps:
      - run: sudo apt-get install -y attr
      - checkout
      - run: pyenv global 3.6.5
      - run: pip install --upgrade pip

I tried running apt-get update but I get another error instead:

#!/bin/bash -eo pipefail
sudo apt-get update && sudo apt-get install -y attr
Reading package lists... Done

E: Could not get lock /var/lib/apt/lists/lock - open (11: Resource temporarily unavailable)
E: Unable to lock directory /var/lib/apt/lists/
Exited with code 100

This error doesn’t happen consistently. Some of our jobs using this step go on fine and some of them fail for this error. This leads me to believe that the VM is being shared among the jobs and they’re not each a dedicated VM.

Here is a link to our config.yaml file: https://github.com/vmware/tern/blob/master/.circleci/config.yml

Help appreciated. Thanks!

Update: It seems this sometimes happens when automatic updates on boot is turned on

https://linuxconfig.org/disable-automatic-updates-on-ubuntu-18-04-bionic-beaver-linux

Is there some config option to turn it off?

You can turn it off on your VM:

Hello @nishakm,

Welcome to the forum.
For this issue, could you check out our support article here and try the included steps to resolve the issue?

If you are still receiving issues after this point, please consider opening up a support ticket: https://support.circleci.com/hc/en-us/requests/new

Thanks for getting back to me! I tried option 1 (kill apt-get process and wait for the network to download updates) and I get this error:

#!/bin/bash -eo pipefail
set -e
sudo killall apt-get
sudo apt-get -y update

apt-get: no process found
Exited with code 1

This again happens only on certain jobs. So it’s still intermittent. I will open a support ticket.