Bug 1826760

Summary: Anaconda dies when installing using "liveimg" and a mount point is specified with "noauto"
Product: Red Hat Enterprise Linux 8 Reporter: Renaud Métrich <rmetrich>
Component: anacondaAssignee: Vendula Poncova <vponcova>
Status: CLOSED ERRATA QA Contact: Release Test Team <release-test-team-automation>
Severity: high Docs Contact:
Priority: low    
Version: 8.1CC: asanders, jcastran, jikortus, jkonecny, jstodola, pzatko, rvykydal, vponcova
Target Milestone: rcKeywords: TestCaseNeeded, Triaged
Target Release: 8.0   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: anaconda-33.16.7.4-1.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-11-08 09:17:10 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Renaud Métrich 2020-04-22 13:54:13 UTC
Description of problem:

When installing a system using "liveimg" directive and formatting a file system with "noauto" option (here for "/storage" mount point), Anaconda dies with the following backtrace:

-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
===============================================================================
An unknown error has occurred
===============================================================================
anaconda 29.19.1.13 exception report
Traceback (most recent call first):
  File "/usr/lib64/python3.6/site-packages/pyanaconda/payload/livepayload.py", line 115, in progress

    mnt_stat = os.statvfs(util.getSysroot() + mnt)
  File "/usr/lib64/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/lib64/python3.6/site-packages/pyanaconda/threading.py", line 286, in run

    threading.Thread.run(self)
FileNotFoundError: [Errno 2] No such file or directory: '/mnt/sysimage/storage'
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

This is due to the a statfs("/storage") being performed which doesn't exist since "/storage" is not mounted, just created.


Version-Release number of selected component (if applicable):

RHEL 8.1 and RHEL 7.x


How reproducible:

Always


Steps to Reproduce:
1. Boot a kickstart using "liveimg" and not mounting a filesystem

liveimg --url=http://192.168.122.1/7.8/LiveOS/squashfs.img
bootloader --location=mbr
clearpart --all --initlabel
part /boot --fstype="xfs" --size=1024
part pv.342 --fstype="lvmpv" --size=18000
volgroup rhel --pesize=4096 pv.342
logvol swap  --fstype="swap" --size=1024 --name=swap --vgname=rhel
logvol /  --fstype="xfs" --size=16240 --name=root --vgname=rhel
logvol /storage --fstype="xfs" --grow --size=1 --fsoptions="noauto" --name=storage --vgname=rhel


Actual results:

Exception and program stops.


Expected results:

No exception and program continues.


Additional info:

The broken piece of code is shown below:

pyanaconda/packaging/livepayload.py (RHEL 7.7 code, but similar logic on RHEL 8.1):
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
100     def progress(self):
101         """Monitor the amount of disk space used on the target and source and
102            update the hub's progress bar.
103         """
104         mountpoints = self.storage.mountpoints.copy() 
105         last_pct = -1
106         while self.pct < 100:
107             dest_size = 0
108             for mnt in mountpoints:
109                 mnt_stat = iutil.eintr_retry_call(os.statvfs, iutil.getSysroot()+mnt)
110                 dest_size += mnt_stat.f_frsize * (mnt_stat.f_blocks - mnt_stat.f_bfree)
111             if dest_size >= self._adj_size:
112                 dest_size -= self._adj_size
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

On line 109, a statvfs() is made even though "mnt" can refer to a non-mounted mount point:
On line 104, "mountpoints" contains *all* the mount points, including non-mounted ones.

Suggested (lazy) fix is to catch the exception and ignore:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
@@ -106,7 +106,10 @@
         while self.pct < 100:
             dest_size = 0
             for mnt in mountpoints:
-                mnt_stat = iutil.eintr_retry_call(os.statvfs, iutil.getSysroot()+mnt)
+                try:
+                    mnt_stat = iutil.eintr_retry_call(os.statvfs, iutil.getSysroot()+mnt)
+                except OSError:
+                    continue
                 dest_size += mnt_stat.f_frsize * (mnt_stat.f_blocks - mnt_stat.f_bfree)
             if dest_size >= self._adj_size:
                 dest_size -= self._adj_size
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

Probably filtering on "mountpoints" should be performed instead to removed unmounted devices.

Comment 18 Jan Stodola 2022-06-08 13:09:35 UTC
Checked that anaconda-33.16.7.4-1.el8 is in nightly compose RHEL-8.7.0-20220608.0

Moving to VERIFIED

Comment 22 errata-xmlrpc 2022-11-08 09:17:10 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (anaconda bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:7462