#1333 file locking for koji-gc
Merged by tkopecek. Opened by tkopecek.
tkopecek/koji issue1332  into  master

Download 1333.patch

Fixes: https://pagure.io/koji/issue/1332

:thumbsup:

This adds some more complexity for users who want to enable garbage collection in their Koji instances.

What value do you recommend for the --lock-file option out of the box? I'm thinking like /var/run/user/<uid>/koji-gc.lock

To make this easier for users, can we document the recommended location? Or make it a default?

@ktdreyer I intended to not change original behaviour at all, so --lock-file is only optional and needn't to be used at all. So, that's the reason, why it has no default (so it is disabled) - maybe just creating some documentation (or document all util/*) at all would be more helpful?

Would you please say more about where you intend to store your lock file when you deploy this change?

As gc needs to be run under the root, /var/lock/koji-gc.lock should work.

As gc needs to be run under the root

koji-gc is just a client tool for Koji. It does not need to be run as root, or on any sort of privileged host (it does not access /mnt/koji directly). It can even be run in test mode without admin permissions or authentication.

Ah, thought, that it does some real deletion by itself. So, in such case it is more problematic. I expect people running it via cron/root, where I would use that systemwide location (or /var/lock/koji-gc.lock) or manually. In manual case I wouldn't use lock-file at all (as it can be handled by user) or use /run/user/<uid>/koji-gc.lock

It sounds like we could reduce the complexity of the implementation by always writing to /run/user/<uid>/koji-gc.lock (don't make it optional)

rebased onto caada44c18cb32746085def6aa29fadb6836535b

removed --lock-file option

It sounds like we could reduce the complexity of the implementation by always writing to /run/user//koji-gc.lock (don't make it optional)

I might be too late to this party, but I think the possibility of specifying the location of the lockfile is useful. It allows us to put the file on shared storage and make sure only one machine in the cluster is running koji-gc at any one time.

3 new commits added

  • default value for --lock-file option
  • reorder imports
  • add file-locking to koji-gc

Ok, I've changed it, that option exists and default is /run/user/<uid>/koji-gc.lock.

ping @breilly @julian8628

Metadata Update from @tkopecek:
- Pull-request tagged with: testing-ready

rebased onto 757645564d6753bde768af2795249e9f2a3b259b

rebased onto 771fdd25f3755a835dc28113b203b8c201809913

@jcupova removed testing-ready due to merge conflict.

:thumbsup:

Metadata Update from @jcupova:
- Pull-request tagged with: testing-done

Commit 76caa2ef fixes this pull-request

Pull-Request has been merged by tkopecek

Metadata