make_chroot: Ignore some vgchange/lvchange errors

vgchange and lvchange are called when re-mounting an existing loopback
device on a chroot (e.g. after a reboot).  These attempt to set up LVM
device nodes in a race against similar scans triggered by udev when the
loopback device is created.  We pass --noudevsync because make_chroot
runs inside an IPC namespace where it can't communicate with udev, so
vgchange/lvchange will sometimes get device mapper errors when the
timing works out badly.  The frequency seems to depend on the machine
load and storage speed; they rarely occur on my workstation but
frequently occur on trybots.

Ignore errors in the two commands because if they fail with device
mapper errors, it should mean the udev-triggered scan succeeds instead.
If they fail for some other reason, the LV won't be properly created and
the mount command a couple of lines down should also fail. This should
keep us safe from mounting a corrupted chroot even without checking
vgchange and lvchange.

BUG=chromium:730144
TEST=Created/unmounted/re-created chroots in a loop to trigger the race.

Change-Id: Iecd454318f84f734e7306e7e8162a5a5d8e1193f
Reviewed-on: https://chromium-review.googlesource.com/582154
Commit-Ready: Benjamin Gordon <bmgordon@chromium.org>
Tested-by: Benjamin Gordon <bmgordon@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
diff --git a/sdk_lib/make_chroot.sh b/sdk_lib/make_chroot.sh
index 40d826c..3e841d9 100755
--- a/sdk_lib/make_chroot.sh
+++ b/sdk_lib/make_chroot.sh
@@ -413,7 +413,7 @@
     die_notrace "Unable to find usable VG name for ${mount_path}."
   fi
   if vgs "$chroot_vg" >&/dev/null; then
-    vgchange -q -a y --noudevsync "$chroot_vg" >/dev/null
+    vgchange -q -a y --noudevsync "$chroot_vg" >/dev/null || :
   else
     vgcreate -q "$chroot_vg" "$chroot_dev" >/dev/null
   fi
@@ -422,7 +422,7 @@
   # We need to pass --noudevsync to lvcreate because we're running inside
   # a separate IPC namespace from the udev process.
   if lvs "$chroot_vg/chroot" >&/dev/null; then
-    lvchange -q -ay "$chroot_vg/chroot" --noudevsync >/dev/null
+    lvchange -q -ay "$chroot_vg/chroot" --noudevsync >/dev/null || :
   else
     lvcreate -q -L 499G -T "${chroot_vg}/thinpool" -V500G -n chroot \
         --noudevsync >/dev/null