#619 iso-wrapper: Capture debug information for mounting
Merged 6 years ago by lsedlar. Opened 6 years ago by lsedlar.
lsedlar/pungi mount-debug  into  master

file modified
+9 -1
@@ -411,7 +411,15 @@ 

      # use guestmount to mount the image, which doesn't require root privileges

      # LIBGUESTFS_BACKEND=direct: running qemu directly without libvirt

      with util.temp_dir(prefix='iso-mount-') as mount_dir:

-         run(["LIBGUESTFS_BACKEND=direct", "guestmount", "-a", image, "-m", "/dev/sda", mount_dir])

+         env = {'LIBGUESTFS_BACKEND': 'direct', 'LIBGUESTFS_DEBUG': '1', 'LIBGUESTFS_TRACE': '1'}

+         cmd = ["guestmount", "-a", image, "-m", "/dev/sda", mount_dir]

+         ret, out = run(cmd, env=env, can_fail=True)

+         if ret != 0:

+             # The mount command failed, something is wrong. Log the output and raise an exception.

+             if logger:

+                 logger.log_error('Command %s exited with %s and output:\n%s'

+                                  % (cmd, ret, out))

+             raise RuntimeError('Failed to mount %s' % image)

          try:

              yield mount_dir

          finally:

file modified
+14
@@ -41,6 +41,7 @@ 

      @mock.patch('pungi.util.run_unmount_cmd')

      @mock.patch('pungi.wrappers.iso.run')

      def test_mount_iso(self, mock_run, mock_unmount):

+         mock_run.return_value = (0, '')

          with iso.mount('dummy') as temp_dir:

              self.assertTrue(os.path.isdir(temp_dir))

          self.assertEqual(len(mock_run.call_args_list), 1)
@@ -50,6 +51,7 @@ 

      @mock.patch('pungi.util.run_unmount_cmd')

      @mock.patch('pungi.wrappers.iso.run')

      def test_mount_iso_always_unmounts(self, mock_run, mock_unmount):

+         mock_run.return_value = (0, '')

          try:

              with iso.mount('dummy') as temp_dir:

                  self.assertTrue(os.path.isdir(temp_dir))
@@ -59,3 +61,15 @@ 

          self.assertEqual(len(mock_run.call_args_list), 1)

          self.assertEqual(len(mock_unmount.call_args_list), 1)

          self.assertFalse(os.path.isdir(temp_dir))

+ 

+     @mock.patch('pungi.util.run_unmount_cmd')

+     @mock.patch('pungi.wrappers.iso.run')

+     def test_mount_iso_raises_on_error(self, mock_run, mock_unmount):

+         log = mock.Mock()

+         mock_run.return_value = (1, 'Boom')

+         with self.assertRaises(RuntimeError):

+             with iso.mount('dummy', logger=log) as temp_dir:

+                 self.assertTrue(os.path.isdir(temp_dir))

+         self.assertEqual(len(mock_run.call_args_list), 1)

+         self.assertEqual(len(mock_unmount.call_args_list), 0)

+         self.assertEqual(len(log.mock_calls), 1)

Occasionally we have seen the mount command fail. The default error message says to set some environment variables and try again. We can just always set the environment and only print the output on failure.

Both Fedora-Atomic-25-20170516.0 and Fedora-Atomic-25-20170515.0 failed because buildinstall phase failed to mount the created image. There are pretty much no logs to help figure out what the problem is.

rebased

6 years ago

rebased

6 years ago

rebased

6 years ago

rebased

6 years ago

Pull-Request has been merged by lsedlar

6 years ago