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

Corrected how the --partial_dir_finish flag needs to be used. #96

Merged
merged 7 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/cron.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ func init() {
"from specified directory after merging")
cronCmd.Flags().BoolVarP(&createPartial, "create_partial_dir", "p", false, "perform the walk, "+
"stat, and combine steps only")
cronCmd.Flags().BoolVarP(&finishPartial, "partial_dir_finish", "z", false, "perform the basedir "+
"and tidy step on a partial run")
cronCmd.Flags().StringVarP(&finishPartial, "partial_dir_finish", "z", "", "perform the basedir "+
"and tidy step on a partial run, requires the name of the unique subdirectory the partial run files are in")
cronCmd.Flags().IntVarP(&multiInodes, "inodes_per_stat", "n",
defaultInodesPerJob, "number of inodes per parallel stat job")
cronCmd.Flags().IntVarP(&multiStatJobs, "num_stat_jobs", "j",
Expand Down
20 changes: 14 additions & 6 deletions cmd/multi.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ var (
partialDirMerge string
partialDirClean bool
createPartial bool
finishPartial bool
finishPartial string
multiInodes int
multiStatJobs int
multiCh string
Expand Down Expand Up @@ -163,8 +163,8 @@ func init() {
"from specified directory after merging")
multiCmd.Flags().BoolVarP(&createPartial, "create_partial_dir", "p", false, "perform the walk, "+
"stat, and combine steps only")
multiCmd.Flags().BoolVarP(&finishPartial, "partial_dir_finish", "z", false, "perform the basedir "+
"and tidy step on a partial run")
multiCmd.Flags().StringVarP(&finishPartial, "partial_dir_finish", "z", "", "perform the basedir "+
"and tidy step on a partial run, requires the name of the unique subdirectory the partial run files are in")
multiCmd.Flags().IntVarP(&multiInodes, "inodes_per_stat", "n",
defaultInodesPerJob, "number of inodes per parallel stat job")
multiCmd.Flags().IntVarP(&multiStatJobs, "num_stat_jobs", "j",
Expand All @@ -189,7 +189,7 @@ func checkMultiArgs(args []string) {
checkStandardFlags()
}

if len(args) == 0 {
if len(args) == 0 && finishPartial == "" {
die("at least 1 directory of interest must be supplied")
}
}
Expand All @@ -213,15 +213,15 @@ func doMultiScheduling(args []string, workDir, forcedQueue, queuesToAvoid string
s, d := newScheduler(workDir, forcedQueue, queuesToAvoid, sudo)
defer d()

unique := scheduler.UniqueString()
unique := uniqueOrPartial(finishPartial)
outputRoot := filepath.Join(workDir, unique)

err := os.MkdirAll(outputRoot, userGroupPerm)
if err != nil {
return err
}

if !finishPartial { //nolint:nestif
if finishPartial == "" { //nolint:nestif
scheduleWalkJobs(outputRoot, args, unique, multiStatJobs, multiInodes, multiCh, forcedQueue, queuesToAvoid, s)

if partialDirMerge != "" {
Expand All @@ -242,6 +242,14 @@ func doMultiScheduling(args []string, workDir, forcedQueue, queuesToAvoid string
return nil
}

func uniqueOrPartial(partial string) string {
if partial == "" {
return scheduler.UniqueString()
}

return partial
}

// scheduleWalkJobs adds a 'wrstat walk' job to wr's queue for each desired
// path. The second scheduler is used to add combine jobs, which need a memory
// override.
Expand Down
45 changes: 40 additions & 5 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -537,12 +537,11 @@ func testPartial(t *testing.T, sudo bool, subcommand []string, date string, walk
Convey("…finishing the partial run runs the correct jobs", func() {
workingDir := t.TempDir()
_, _, jobs, err := runWRStat(append(subcommand, "-w", workingDir, "-f", "final_output", "-q", "quota_file",
"-o", "owners_file", "-z", "/some/path", "/some-other/path")...)
"-o", "owners_file", "-z", repGroup, "/some/path", "/some-other/path")...)
So(err, ShouldBeNil)

So(len(jobs), ShouldEqual, 2)

repGroup := jobs[0].RepGroup[len(jobs[0].RepGroup)-20:]
expectation := []*jobqueue.Job{
{
Cmd: fmt.Sprintf("%s basedir -q \"quota_file\" -o \"owners_file\" \"%s/%s\" \"final_output\"",
Expand Down Expand Up @@ -1650,6 +1649,7 @@ waitForJobs() {
mkdir -p /tmp/working/partial/;
mkdir -p /tmp/working/complete/;
mkdir -p /tmp/final/;
mkdir -p /tmp/final/simple/;

yes y | WR_RunnerExecShell=sh wr manager start -s local --max_ram -1 --max_cores -1;

Expand All @@ -1660,6 +1660,10 @@ wrstat multi -m 0 -w /tmp/working/complete/ -f /tmp/final/ -l `+
`/tmp/working/partial -q /tmp/quota -b /tmp/basedirs -o /tmp/owners /objects/*;
waitForJobs;

wrstat multi -m 0 -z "$(basename /tmp/working/partial/*)" -w /tmp/working/partial/ `+
`-f /tmp/final/simple -q /tmp/quota -b /tmp/basedirs -o /tmp/owners;
waitForJobs;

stop;`)
writeFileString(t, filepath.Join(tmpTemp, "owners"), "")
writeFileString(t, filepath.Join(tmpTemp, "quota"), "")
Expand Down Expand Up @@ -1784,7 +1788,7 @@ stop;`)
"U%[2]d\t\t/objects/store2/part0/teams/team2\t%[6]d\t1000\t0\t1\t0\tOK\n"+
"U%[3]d\t\t/objects/store1/data/temp\t%[6]d\t6000\t0\t3\t0\tOK\n"+
"U%[4]d\t\t/objects/store2/part1/other/my\nDir\t%[6]d\t2048\t0\t1\t0\tOK\n"+
"U%[5]d\t\t/objects/store2/part1/other/my\nDir\t19997\t2048\t0\t1\t0\tOK\n"+
"U%[5]d\t\t/objects/store2/part1/other/my\nDir\t%[6]d\t2048\t0\t1\t0\tOK\n"+
"U%[5]d\t\t/simple/E\t%[6]d\t2\t0\t1\t0\tOK",
UserA, UserB, UserC, UserD, UserE,
time.Now().Unix()/86400),
Expand Down Expand Up @@ -1953,6 +1957,37 @@ stop;`)
encode.Base64Encode("/objects/store3/aFile")+"\t512\t%d\t%d\t160\t160\t160\tf\t\x00\t1\t34\n"+
encode.Base64Encode("/objects/store3")+"\t0\t0\t0\t160\t160\t160\td\t\x00\t2\t32",
UserA, GroupA),

"simple/*basedirs.userusage.tsv": fmt.Sprintf(``+
"U%[1]d\t\t/simple/A\t%[3]d\t1\t0\t1\t0\tOK\n"+
"U%[2]d\t\t/simple/E\t%[3]d\t2\t0\t1\t0\tOK",
UserA, UserE,
time.Now().Unix()/86400),
"simple/*basedirs.groupusage.tsv": fmt.Sprintf(``+
"G%[1]d\t\t/simple/A\t%[3]d\t1\t0\t1\t0\tNot OK\n"+
"G%[2]d\t\t/simple/E\t%[3]d\t2\t0\t1\t0\tNot OK",
GroupA, GroupE,
time.Now().Unix()/86400),
"simple/????????_A.*.bygroup": fmt.Sprintf("G%d\tU%d\t1\t1", GroupA, UserA),
"simple/????????_E.*.bygroup": fmt.Sprintf("G%d\tU%d\t1\t2", GroupE, UserE),
"simple/????????_A.*.byusergroup.gz": fmt.Sprintf(``+
"U%[1]d\tG%[2]d\t"+encode.Base64Encode("/")+"\t1\t1\n"+
"U%[1]d\tG%[2]d\t"+encode.Base64Encode("/simple")+"\t1\t1\n"+
"U%[1]d\tG%[2]d\t"+encode.Base64Encode("/simple/A")+"\t1\t1\n", UserA, GroupA),
"simple/????????_E.*.byusergroup.gz": fmt.Sprintf(``+
"U%[1]d\tG%[2]d\t"+encode.Base64Encode("/")+"\t1\t2\n"+
"U%[1]d\tG%[2]d\t"+encode.Base64Encode("/simple")+"\t1\t2\n"+
"U%[1]d\tG%[2]d\t"+encode.Base64Encode("/simple/E")+"\t1\t2\n", UserE, GroupE),
"simple/????????_A.*.logs.gz": "",
"simple/????????_E.*.logs.gz": "",
"simple/????????_A.*.stats.gz": fmt.Sprintf(""+
encode.Base64Encode("/simple/A/a.file")+"\t1\t%[1]d\t%[2]d\t166\t166\t166\tf\t\x00\t1\t34\n"+
encode.Base64Encode("/simple/A")+"\t0\t%[1]d\t%[2]d\t166\t166\t166\td\t\x00\t2\t32",
UserA, GroupA),
"simple/????????_E.*.stats.gz": fmt.Sprintf(""+
encode.Base64Encode("/simple/E/b.tmp")+"\t2\t%[1]d\t%[2]d\t171\t171\t171\tf\t\x00\t2\t34\n"+
encode.Base64Encode("/simple/E")+"\t0\t%[1]d\t%[2]d\t171\t171\t171\td\t\x00\t3\t32",
UserE, GroupE),
} {
files, errr := fs.Glob(os.DirFS(tmpTemp), filepath.Join("final", file))
So(errr, ShouldBeNil)
Expand All @@ -1977,7 +2012,7 @@ stop;`)
"%[2]d\t\t/objects/store2/part0/teams/team2\t%[6]d\t1000\t0\t1\t0\tOK\n"+
"%[3]d\t\t/objects/store1/data/temp\t%[6]d\t6000\t0\t3\t0\tOK\n"+
"%[4]d\t\t/objects/store2/part1/other/my\nDir\t%[6]d\t2048\t0\t1\t0\tOK\n"+
"%[5]d\t\t/objects/store2/part1/other/my\nDir\t19997\t2048\t0\t1\t0\tOK\n"+
"%[5]d\t\t/objects/store2/part1/other/my\nDir\t%[6]d\t2048\t0\t1\t0\tOK\n"+
"%[5]d\t\t/simple/E\t%[6]d\t2\t0\t1\t0\tOK\n",
UserA, UserB, UserC, UserD, UserE,
time.Now().Unix()/86400)
Expand All @@ -1991,7 +2026,7 @@ stop;`)
"%[1]d\t\t/simple/A\t%[5]d\t1\t0\t1\t0\tNot OK\n"+
"%[2]d\t\t/objects/store2/part0/teams/team1\t%[5]d\t200\t0\t1\t0\tNot OK\n"+
"%[2]d\t\t/objects/store2/part0/teams/team2\t%[5]d\t1000\t0\t1\t0\tNot OK\n"+
"%[2]d\t\t/objects/store2/part1/other/my\nDir\t19997\t2048\t0\t1\t0\tNot OK\n"+
"%[2]d\t\t/objects/store2/part1/other/my\nDir\t%[5]d\t2048\t0\t1\t0\tNot OK\n"+
"%[3]d\t\t/objects/store2/important/docs\t\t%[5]d\t1200\t0\t1\t0\tNot OK\n"+
"%[4]d\t\t/simple/E\t%[5]d\t2\t0\t1\t0\tNot OK\n",
GroupA, GroupB, GroupD, GroupE,
Expand Down
Loading