NAICNO / Jobanalyzer

Easy to use resource usage report
MIT License
0 stars 1 forks source link

-data-dir defaults should only apply if they exist (if then) #650

Open lars-t-hansen opened 3 weeks ago

lars-t-hansen commented 3 weeks ago

This is fallout from #579 actually. If no -data-dir is specified when DataDirArgs.Validate is invoked it defaults to $SONAR_ROOT first and $HOME/sonar/data second. It does this regardless of whether those directories exist. We can tweak this code to check that the directory exists, and this is desirable because commands like sonalyze node (without further arguments) will start failing, as they should, when none of the directories are there, as they are likely not to be. But commands like sonalyze parse -fmt help will also start failing because the -data-dir validation errors out before the format parser can be run. So the tweaks are a little too big to piggyback on #579.

Also, in the code for DataDirArgs.Validate there's a comment to the effect that (a) $SONAR_ROOT is a completely inappropriate name and $HOME/sonar/data is the wrong directory regardless since that's neither the jobanalyzer home directory nor the data store for any particular cluster. So the defaults are simply completely off.

I don't think anything bad will come from just removing the defaults - they are very old code - but the -fmt help thing must be fixed.