Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken handling of lockfile during cleanup #18

Open
rohanpm opened this issue Feb 4, 2020 · 0 comments
Open

Broken handling of lockfile during cleanup #18

rohanpm opened this issue Feb 4, 2020 · 0 comments
Assignees

Comments

@rohanpm
Copy link
Member

rohanpm commented Feb 4, 2020

alt-src does not manage its lockfile correctly with respect to cleaning up an incomplete working directory.

See for example this log:

2020-02-04 18:37:55,304 [INFO] Lock acquired
2020-02-04 18:37:55,305 [WARNING] Incomplete staging dir /mnt/redhat/altsrc/staging/stage/c8-stream-rhel8/rpms/c/conmon/conmon-2.0.6-1.module+el8.1.1+5259+bcdd613a (state=None), will overwrite.
2020-02-04 18:37:55,318 [ERROR] Staging failed
Traceback (most recent call last):
  File "/usr/bin/alt-src", line 2065, in main
    task.run()
  File "/usr/bin/alt-src", line 646, in run
    if self.make_workdir() in ['STAGED', 'PUSHED']:
  File "/usr/bin/alt-src", line 691, in make_workdir
    koji.util.rmtree(dirname)
  File "/usr/lib/python2.4/site-packages/koji/util.py", line 297, in rmtree
    os.rmdir(path)
OSError: [Errno 39] Directory not empty: '/mnt/redhat/altsrc/staging/stage/c8-stream-rhel8/rpms/c/conmon/conmon-2.0.6-1.module+el8.1.1+5259+bcdd613a'
  1. alt-src acquires a lock on a file to ensure no other run on the same package is in progress.
  2. alt-src determines that the working directory is incomplete and decides to remove it before continuing.

Problem: the lock file is contained within the directory we're deleting.

I'm not certain, but what happens next might depend on the filesystem in use. In the above example, where NFS is used, we can see that it causes the rmtree operation to fail. In other cases, perhaps it wouldn't cause a failure, but would still be wrong as it would cause the lock to become ineffective (as nothing would prevent another process from creating another lock file at the target path).

This needs to be fixed so that alt-src does not attempt to delete its own lock file when cleaning an incomplete working directory.

@JayZ12138 JayZ12138 self-assigned this Mar 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants