Bug 1757845

Summary: You have to remove that container to be able to reuse that name.: that name is already in use (due to exec user process caused "no such file or directory")
Product: Red Hat Enterprise Linux 8 Reporter: Michele Baldessari <michele>
Component: podmanAssignee: Nalin Dahyabhai <nalin>
Status: CLOSED ERRATA QA Contact: atomic-bugs <atomic-bugs>
Severity: high Docs Contact:
Priority: unspecified    
Version: 8.1CC: bbaude, bdobreli, dciabrin, ddarrah, dmaley, dornelas, dwalsh, elicohen, emacchi, gscrivan, jligon, jnovy, lmiccini, lsm5, mheon, mschuppe, nalin, psahoo, pthomas, toneata, tsweeney, weshen
Target Milestone: rcKeywords: ZStream
Target Release: 8.2   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: podman-1.6.4-2.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1787524 (view as bug list) Environment:
Last Closed: 2020-04-28 15:47:44 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:
Bug Depends On:    
Bug Blocks: 1727325, 1734579, 1787524    

Comment 33 Daniel Walsh 2019-10-23 20:20:45 UTC
Strange

man 2 umount
,,,
       EINVAL target is not a mount point.

       EINVAL umount2()  was  called with MNT_EXPIRE and either MNT_DETACH or
              MNT_FORCE.

       EINVAL (since Linux 2.6.34)
              umount2() was called with an invalid flag value in flags.

man 3 unlink
...
       EBUSY  The file pathname cannot be unlinked because it is  being  used
              by  the  system  or another process; for example, it is a mount
              point or the NFS client software created  it  to  represent  an
              active but otherwise nameless inode ("NFS silly renamed").




This looks like something in stroage is complaining about merged not being mounted and later  an attempt is made to remove the file
and it says that it can't because something is mounte don it.

Comment 34 Alan Bishop 2019-11-05 14:27:00 UTC
*** Bug 1766337 has been marked as a duplicate of this bug. ***

Comment 52 Giuseppe Scrivano 2019-12-19 14:00:56 UTC
I don't think my proposed fix is enough.  I see other potential races with the home directory.

I think we still need to make sure there is no cleanup happening between a home directory mount and the overlay mount created on top of it.  My guess is that we hit the issue when something similar happens:


       Process A                                            Process B                                                            Process C
-----> mount home directory? Yes, it is not there
-----> mount overlay
-----> run container
-----> umount overlay
--------------------------------------------------> mount home directory? No, it is already mounted
-----> umount home directory? Yes, there are no mounts
--------------------------------------------------> mount overlay (directly on the host, no home directory present)
---------------------------------------------------------------------------------------------------------> mount home directory? Yes, it is not there (shadow mount overlay B)
--------------------------------------------------> run container
--------------------------------------------------> umount overlay

Now depending at what time process B is, the mount home directory from process C can cause different sort of issues.  If it is already inside of runc between prepareRoot() and "unix.Mount("", "/", "", uintptr(flag), "")" then it will cause the issue observed above with "exec user process caused "no such file or directory")".  When process B terminates it is unable to cleanup the overlay mount as it is not accessible.

Potential fixes:

- In store.Mount() we already have a lock on rlstore: is it enough to make sure the home directory exists before the mount or are there other cases where the overlay can be created?
- drop the home directory completely.  The performance benefit we have is probably outweighed by the locking.
- never drop the home directory mount.  We leak a mount when there are no containers running, but both performance benefit and no extra locking

Comment 53 Daniel Walsh 2019-12-19 15:41:28 UTC
I think the safest thing would be to just leak.  Then if someone wants to remove it they could manually umount it.

Comment 54 Giuseppe Scrivano 2019-12-19 18:18:26 UTC
while working on it, I saw we are already using the lock as part of the mount operation so we just need to keep it a bit longer.  Given that, I've opted for the first option instead and opened a PR.  Marked as WIP as it needs more testing:

https://github.com/containers/storage/pull/497

Comment 55 Michele Baldessari 2019-12-20 07:46:08 UTC
Thanks a bunch, Giuseppe. I'll take this PR for a long spin and report back (FWIW I left the first patch at c#51 running for 36 straight hours on three vms and it worked without issues. I'll do the same for this one and update here either over the weekend or on Monday)

Comment 56 Giuseppe Scrivano 2019-12-20 07:56:52 UTC
thanks, so the PR I've opened also includes the fix you were testing and in addition to that, we hold the lock also during the mount itself.

I am still looking at it today, I'll let you know when it is ready for testing.

Comment 73 errata-xmlrpc 2020-04-28 15:47:44 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, 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/RHSA-2020:1650