Bug 198515

Summary: mock -r distro clean does not clean /var/lib/mock/distro
Product: [Retired] Fedora Hosted Projects Reporter: Ralf Corsepius <rc040203>
Component: mockAssignee: Clark Williams <williams>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: unspecifiedCC: dcantrell, extras-qa
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-10-24 19:11:45 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Ralf Corsepius 2006-07-11 16:07:22 UTC
Description of problem:

mock -r distro clean
doesn't clean up /var/lib/mock/distro

It leaves directories behind below /var/lib/mock/distro.


Version-Release number of selected component (if applicable):
mock-0.6-4.fc5

How reproducible:
deterministic


Steps to Reproduce:
1. login as user1
2. mock -r <distro> init
=> Creates /var/lib/mock/<distro> directory hierarchy

3. mock -r <distro> clean
=> Largely empties /var/lib/mock/<distro> directory hierarchy
but leave directories and files behind:

/var/lib/mock/distro/
/var/lib/mock/distro/result
/var/lib/mock/distro/result/root.log
/var/lib/mock/distro/result/mockconfig.log
/var/lib/mock/distro/result/build.log
/var/lib/mock/distro/state
/var/lib/mock/distro/state/status
/var/lib/mock/distro/root

4. login as user2
5. mock -r <distro> init
  
Actual results:
Step 5. fails.

# mock -r distro init
Traceback (most recent call last):
  File "/usr/bin/mock", line 985, in ?
    main()
  File "/usr/bin/mock", line 956, in main
    do_clean(config_opts, init=1)
  File "/usr/bin/mock", line 826, in do_clean
    my = Root(config_opts)
  File "/usr/bin/mock", line 129, in __init__
    self.state("init")
  File "/usr/bin/mock", line 202, in state
    sfo = open(sf, 'w')
IOError: [Errno 13] Permission denied: '/var/lib/mock/distro/state/status'


Expected results:
Step 5. to succeed.

Additional info:

A simple "rm -rf /var/lib/mock/<distro>" after "mock -r <distro> clean" resolves
this issue, i.e. an analogous operation at the end of "mock clean" would likely
resolve this issue, too.

Comment 1 Clark Williams 2006-08-11 17:39:02 UTC
The directories and files that you're seeing are created *after* a clean
operation to ensure that the hierarchy is correct.  This is because the internal
cleanup function is called as part of an "init" operation as well as a "clean"
operation. 

Changing this behavior will require some re-architecting in how the Root object
handles init versus clean ops. Either that or changing permission/ownership of
those files so your "user2" can nuke them.

Comment 2 Ralf Corsepius 2006-08-13 03:45:58 UTC
(In reply to comment #1)
> The directories and files that you're seeing are created *after* a clean
> operation to ensure that the hierarchy is correct.  This is because the
> internal
> cleanup function is called as part of an "init" operation as well as a "clean"
> operation. 

Well - what shall I say - your problem ;)

'mock clean' is documented (man mock) as:
...
clean - purge the chroot tree
...

Apparently mock doesn't do this.


Also, I think I need to emphasize the severity of this bug: It classifies mock
as "not multiuser-capabile", i.e. as unusable in a multiuser environment.

Comment 3 Clark Williams 2008-10-24 19:11:45 UTC
This behavior got cleaned up in the Great Re-Write that happened over the last year.

mock -r distro clean

now deletes /var/lib/mock/<distro>