Embedded calls to `find` in cleanUsersData.php do not scale up
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 0
- Forks
- 3
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 4
Description
I have found in the logs emitted by cleanUsersData.php from other openVRE deployments messages like next:
Looking for temporary data (/gpfs/vre/userdata//*/*/.tmp/)
-- find /gpfs/vre/userdata//*/*/.tmp/ -maxdepth 1 -mtime +7 -type f -exec rm -fv {} \;
sh: 1: find: Argument list too long
-- find /gpfs/vre/userdata//*/*/.tmp/ -maxdepth 1 -mtime +7 -type d -name '?*_[0-9]*' -exec rm -Rfv {} \;
sh: 1: find: Argument list too long
-- find /gpfs/vre/userdata//*/*/.tmp/ -maxdepth 1 -size +2G -mtime -7 -type f -name '*tar.gz' -exec rm -fv {} \;
sh: 1: find: Argument list too long
And they are happening when the user data directory from that openVRE deployment contains too many entries (more than the number of parameters which can passed to a program from command line). These are the blamed lines:
This issue can be fixed using something similar to next command line, where find command delegates on xargs calling nested find commands, so no wildcard expansion happens:
if(substr($GLOBALS['tmpUser_dir'], -1) == "/") {
$tmpuser_dir = substr($GLOBALS['tmpUser_dir'], 0, -1);
} else {
$tmpuser_dir = $GLOBALS['tmpUser_dir'];
}
$cmd = "find ".$GLOBALS['dataDir']." -type d -name ".$tmpuser_dir." -print0 | xargs -0 -I{.} find {.} -maxdepth 1 -mtime +".$caduca_strict." -type f ";
if ($dry_run === false) {
$cmd.= " -exec rm -fv {} \\;";
}
print "-- $cmd\n";
system($cmd);
$cmd = "find ".$GLOBALS['dataDir']." -type d -name ".$tmpuser_dir." -print0 | xargs -0 -I{.} find {.} -maxdepth 1 -mtime +".$caduca_strict." -type d -name '?*_[0-9]*' ";
if ($dry_run === false) {
$cmd.= " -exec rm -Rfv {} \\;";
}
print "-- $cmd\n";
system($cmd);
$cmd = "find ".$GLOBALS['dataDir']." -type d -name ".$tmpuser_dir." -print0 | xargs -0 -I{.} find {.} -maxdepth 1 -size +2G -mtime -".$caduca_strict." -type f -name '*tar.gz' ";
if ($dry_run === false) {
$cmd.= " -exec rm -fv {} \\;";
}
print "-- $cmd\n";
system($cmd);
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in front_end/openVRE/scripts/maintainance/cleanUsersData.php at lines 341-363 and inspect the three logged find commands and their dry-run paths. Reproduce the failure with a data directory containing enough entries to exceed command-line limits, then verify the cleanup commands work for files, temporary directories, and tar archives without wildcard expansion.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, shell
- Domain
- devops, infrastructure
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100