non-deterministic dpkg and apt-get failures on stock ubuntu-1804-lts on startup

234 views
Skip to first unread message

Steve Lorimer

unread,
Apr 8, 2019, 2:30:09 PM4/8/19
to gce-discussion
I am having issues on startup of a new vm which is using the stock "ubuntu-1804-lts" OS image.

I obtain the selfLink for the current ubuntu-1804-lts image by executing the following query:

r = compute.images().getFromFamily(project='ubuntu-os-cloud', family='ubuntu-1804-lts').execute()
os_image = r['selfLink']

I then create my VM using the following config:

        body = {
            'name': self._name,
            'machineType': f'zones/us-east1-b/machineTypes/custom-94-86784', 
            'disks': [{
                'boot': True,
                'autoDelete': True,
                'initializeParams': {
                    'sourceImage': os_image,
                }
            }],
            'networkInterfaces': [{
                'network': 'global/networks/default',
                'accessConfigs': [{
                    'type': 'ONE_TO_ONE_NAT',
                    'name': 'External NAT'
                }]
            }],
        }

Once the VM has started and I can obtain its external ip address, I run the following command over ssh:
dpkg -s binutils || sudo apt-get install -y binutils
Randomly I will get failures for a variety of reasons. It is not deterministic. I'm guessing the image has been configured to run a system update on startup perhaps?

Here are several examples of when it fails, with the stderr output:
----
  dpkg-query: package 'binutils' is not installed and no information is available
  Use dpkg --info (= dpkg-deb --info) to examine archive files,
  and dpkg --contents (= dpkg-deb --contents) to list their contents.
  E: Could not open file /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic-updates_restricted_i18n_Translation-en - open (2: No such file or directory)
  E: Could not open file /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic-updates_restricted_binary-amd64_Packages - open (2: No such file or directory)
  E: Could not open file /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic-updates_main_i18n_Translation-en - open (2: No such file or directory)
  E: Could not open file /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic-updates_main_binary-amd64_Packages - open (2: No such file or directory)
  E: Could not open file /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic_restricted_i18n_Translation-en - open (2: No such file or directory)
  E: Could not open file /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic_restricted_binary-amd64_Packages - open (2: No such file or directory)
  E: Could not open file /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic_main_i18n_Translation-en - open (2: No such file or directory)
  E: Could not open file /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic_main_binary-amd64_Packages - open (2: No such file or directory)
----
  E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable)
  E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?
----
dpkg-query: package 'binutils' is not installed and no information is available Use dpkg --info (= dpkg-deb --info) to examine archive files, and dpkg --contents (= dpkg-deb --contents) to list their contents. E: Can't find a source to download version '2.30-21ubuntu1~18.04' of 'libbinutils:amd64' E: Can't find a source to download version '2.30-21ubuntu1~18.04' of 'binutils-x86-64-linux-gnu:amd64' E: Can't find a source to download version '2.30-21ubuntu1~18.04' of 'binutils:amd64' I am trying to script the creation and initialisation of this VM, but these non-deterministic failures are causing me a lot of trouble.

What is happening here, and how can I mitigate against it?

TIA
Steve

James (Google Cloud Platform Support)

unread,
Apr 23, 2019, 10:07:49 AM4/23/19
to gce-discussion
Hello Steve,

It looks like another process might be using the APT package management tool at the time you experienced the error. 

If you are running scripts during VM creation can you please give us some more context or details as to what you are doing so I can test under the same conditions? 

I just ran some tests on a newly deployed compute engine VM and did not experience the issue after running:
Reply all
Reply to author
Forward
0 new messages