mount-image-callback fails on qcow image on xenial

Bug #1741300 reported by Scott Moser
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-utils
Fix Released
Undecided
Unassigned
cloud-utils (Ubuntu)
Fix Released
Medium
Unassigned
Xenial
Fix Released
Medium
Unassigned
Artful
Fix Released
Medium
Unassigned
Bionic
Fix Released
Medium
Unassigned

Bug Description

=== Begin SRU Template ===
[Impact]
mount-image-callback fails to mount images that are qcow2 formatted.

This function in mount-image-callback works in other Ubuntu releases
but not on xenial. The function does succeed some times, but is
brittle.

The fix applied is also applied upstream, and consists mainly of adding

 blockdev --rereadpt /dev/nbdX
 udevadm settle

where 'nbdX' is the device that mount-image-callback has set up to
point to the file that is to be mounted.

These above added function should not be harmful in any case.

[Test Case]
In a fresh install:

$ sudo apt-get update -q && sudo apt-get install -qy cloud-image-utils

$ url=http://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64-disk1.img
$ wget "$url" -O xenial-server-cloudimg-amd64-disk1.img
$ cp -a xenial-server-cloudimg-amd64-disk1.img disk.img

$ sudo mount-image-callback -v disk.img true
waiting on pidfile for /dev/nbd0 in /sys/block/nbd0/pid
connected disk.img (qcow2) to /dev/nbd0. waiting for device.

[Regression Potential]
The regression potential stems from additional udev events
caused by calling blockdev --rereadpt.

udev events should not cause unwanted side effects, but could.

[Other Info]

=== End SRU Template ===

On xenial only:

$ wget http://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64-disk1.img
$ cp -a xenial-server-cloudimg-amd64-disk1.img disk.img
$ sudo mount-image-callback -v disk.img true
waiting on pidfile for /dev/nbd0 in /sys/block/nbd0/pid
connected disk.img (qcow2) to /dev/nbd0. waiting for device.
partitioned disk.
waiting for /dev/nbd0p1 part=1 to be ready.
waiting for /dev/nbd0p1 part=1 to be ready.
waiting for /dev/nbd0p1 part=1 to be ready.
waiting for /dev/nbd0p1 part=1 to be ready.
waiting for /dev/nbd0p1 part=1 to be ready.
waiting for /dev/nbd0p1 part=1 to be ready.
waiting for /dev/nbd0p1 part=1 to be ready.
waiting for /dev/nbd0p1 part=1 to be ready.
waiting for /dev/nbd0p1 part=1 to be ready.
gave up on waiting for /dev/nbd0p1
$ echo $?
1

This fix seems to work and should be safe.
=== modified file 'bin/mount-image-callback'
--- bin/mount-image-callback 2018-01-03 15:44:47 +0000
+++ bin/mount-image-callback 2018-01-04 17:21:23 +0000
@@ -316,6 +316,8 @@
        fi

        i=0
+ [ -b "$mdev" ] || blockdev --rereadpt $nbd ||
+ { error "blockdev --rereadpt $nbd failed"; return 1; }
        while :; do
                [ -b "$mdev" ] && break
                i=$(($i+1))

ProblemType: Bug
DistroRelease: Ubuntu 16.04
Package: cloud-image-utils 0.27-0ubuntu24
ProcVersionSignature: User Name 4.4.0-104.127-generic 4.4.98
Uname: Linux 4.4.0-104-generic x86_64
ApportVersion: 2.20.1-0ubuntu2.14
Architecture: amd64
Date: Thu Jan 4 17:23:15 2018
Ec2AMI: ami-00000388
Ec2AMIManifest: FIXME
Ec2AvailabilityZone: nova
Ec2InstanceType: m1.small
Ec2Kernel: unavailable
Ec2Ramdisk: unavailable
PackageArchitecture: all
ProcEnviron:
 TERM=screen
 PATH=(custom, no user)
 XDG_RUNTIME_DIR=<set>
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: cloud-utils
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Scott Moser (smoser) wrote :
Changed in cloud-utils (Ubuntu Xenial):
status: New → Fix Released
Changed in cloud-utils (Ubuntu Artful):
status: New → Fix Released
Revision history for this message
Scott Moser (smoser) wrote :

artful and bionic are 'fix-released' as some magic in udev/systemd makes it work.
It does seem though that maybe running blockdev makes sense there also though.

Scott Moser (smoser)
Changed in cloud-utils (Ubuntu Xenial):
status: Fix Released → Confirmed
Changed in cloud-utils (Ubuntu Bionic):
status: New → Fix Released
Scott Moser (smoser)
Changed in cloud-utils (Ubuntu Bionic):
importance: Undecided → Medium
Changed in cloud-utils (Ubuntu Artful):
importance: Undecided → Medium
Changed in cloud-utils (Ubuntu Xenial):
importance: Undecided → Medium
Scott Moser (smoser)
description: updated
Scott Moser (smoser)
description: updated
Revision history for this message
Chris J Arges (arges) wrote : Please test proposed package

Hello Scott, or anyone else affected,

Accepted cloud-utils into xenial-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/cloud-utils/0.27-0ubuntu25 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed.Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested and change the tag from verification-needed-xenial to verification-done-xenial. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-xenial. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in cloud-utils (Ubuntu Xenial):
status: Confirmed → Fix Committed
tags: added: verification-needed verification-needed-xenial
Revision history for this message
Scott Moser (smoser) wrote :

Verified. on fresh xenial guest in openstack. See below.

$ lsb_release -sc
xenial
$ cat /etc/cloud/build.info
build_name: server
serial: 20180126

$ wget "$url" --progress=dot:giga -O xenial-server-cloudimg-amd64-disk1.img

$ dpkg -S `which mount-image-callback`
cloud-image-utils: /usr/bin/mount-image-callback

$ dpkg-query --show cloud-image-utils
cloud-image-utils 0.27-0ubuntu25

$ sha256sum < xenial-server-cloudimg-amd64-disk1.img
da7a59cbaf43eaaa83ded0b0588bdcee4e722d9355bd6b9bfddd01b2e7e372e2 -

$ cp -a xenial-server-cloudimg-amd64-disk1.img disk.img

$ sudo mount-image-callback -v disk.img -- true
waiting on pidfile for /dev/nbd0 in /sys/block/nbd0/pid
connected disk.img (qcow2) to /dev/nbd0. waiting for device.
partitioned disk.
mounted /dev/nbd0p1 via qemu-nbd /dev/nbd0
invoking: MOUNTPOINT=/tmp/mount-image-callback.XRd6Rk/mp true
cmd returned 0. unmounting /tmp/mount-image-callback.XRd6Rk/mp

$ sudo mount-image-callback --read-only disk.img -- \
     sh -c 'cd $MOUNTPOINT && cat etc/cloud/build.info'
mount: /dev/nbd0p1 is write-protected, mounting read-only
build_name: server
serial: 20180126

tags: added: verification-done verification-done-xenial
removed: verification-needed verification-needed-xenial
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package cloud-utils - 0.27-0ubuntu25

---------------
cloud-utils (0.27-0ubuntu25) xenial; urgency=medium

  * mount-image-callback: update partitions and settle on nbd mounts.
    (LP: #1741300)

 -- Scott Moser <email address hidden> Fri, 26 Jan 2018 13:27:32 -0500

Changed in cloud-utils (Ubuntu Xenial):
status: Fix Committed → Fix Released
Revision history for this message
Łukasz Zemczak (sil2100) wrote : Update Released

The verification of the Stable Release Update for cloud-utils has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

Revision history for this message
Scott Moser (smoser) wrote : Fixed in cloud-utils version 0.31.

This bug is believed to be fixed in cloud-utils in version 0.31. If this is still a problem for you, please make a comment and set the state back to New

Thank you.

Changed in cloud-utils:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.