Hide Forgot
After running log-delete to remove expired test logs, we're left with empty directories. The deletion process should detect when everything in a directory has been removed and trim the directory as well.
moving to 0.8.2. rmancy, Looking at this bit of code: for job_id in job_ids: job = Job.by_id(job_id) logs = job.get_log_dirs() if logs: logs = cls._remove_descendants(logs) yield (job, logs) Can we simply change _remove_descendants and replace it with the part that is the job id? http://FQDN/beaker-logs/2011/12/1739/173922/364531/ to http://FQDN/beaker-logs/2011/12/1739/173922 This would still leave the intermediate directory "1739". To do anything more would mean making http calls to see if the directory is actually empty. If its local we can do a rmdir command which will only delete empty dirs.
(In reply to comment #1) > moving to 0.8.2. > > rmancy, > Looking at this bit of code: > > for job_id in job_ids: > job = Job.by_id(job_id) > logs = job.get_log_dirs() > if logs: > logs = cls._remove_descendants(logs) > yield (job, logs) > > > Can we simply change _remove_descendants and replace it with the part that is > the job id? > > http://FQDN/beaker-logs/2011/12/1739/173922/364531/ > > to > > http://FQDN/beaker-logs/2011/12/1739/173922 > > This would still leave the intermediate directory "1739". > That example would work on the archive server, but I don't think it would if the logs were still on the lab controller. Moreover, I'm not sure if it's wise to make assumptions about where on the filesystem logs lie when deleting them as it could cause problems if they change. > To do anything more would mean making http calls to see if the directory is > actually empty. If its local we can do a rmdir command which will only delete > empty dirs.
We still don't have a good solution for this. Because of shared top level directories its not simple for us to know if the directory is empty. Can we make calls to determine if a directory is empty over webdav?
dcallagh has been giving me some hints about PROPFIND, so maybe we can use that.
We can use PROPFIND to find empty dirs. But I'm not quite sure the best way to do it. All PROPFIND does is return the properties (type, href, ctime etc) of an entity given by a URL. For folders, you can also pass a depth level. Unfortunately it won't tell us directly whether a folder is empty though. I can think of a couple of ways to achieve this, but none of them simple. I'd suggest that the simplest way to achieve this, is a cron job runinng 'find' or something similar.
I'd suggest running a cron job, perhaps with something like the following: find /var/www/html/beaker-logs -type d -empty -print | xargs rmdir