Save tmp files into /tmpdir/$username
ClosedPublic

Authored by mkrizek on Oct 29 2015, 8:48 PM.

Details

Summary

This is mainly for multiple buildslaves which are on the
same host running in --local not touching each others tmp files.

Test Plan

Ran rpmlint, worked. Tests pass as well.

Diff Detail

Repository
rLTRN libtaskotron
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
mkrizek retitled this revision from to Save tmp files into /tmpdir/$username.Oct 29 2015, 8:48 PM
mkrizek updated this object.
mkrizek edited the test plan for this revision. (Show Details)
mkrizek added reviewers: tflink, kparal, jskladan, lbrabec.
tflink accepted this revision.Oct 29 2015, 8:52 PM

LGTM

This revision is now accepted and ready to land.Oct 29 2015, 8:52 PM

Sorry, why is this needed? We use tempfile.mkdtemp() so every directory should be unique and we should have no issues running several processes in parallel. It should be thread-safe.

If we want to have temporary files separated by user name, i.e. /var/tmp/taskotron/user1/ and /var/tmp/taskotron/user2/, I don't really object (I'm not sure whether there's a big benefit, though), but why does not the same approach apply for cachedir and logdir as well? (probably not for artifactsdir, that could be confusing).

In D632#12150, @kparal wrote:

Sorry, why is this needed? We use tempfile.mkdtemp() so every directory should be unique and we should have no issues running several processes in parallel. It should be thread-safe.

If we want to have temporary files separated by user name, i.e. /var/tmp/taskotron/user1/ and /var/tmp/taskotron/user2/, I don't really object (I'm not sure whether there's a big benefit, though), but why does not the same approach apply for cachedir and logdir as well? (probably not for artifactsdir, that could be confusing).

Because we delete tmpdir before running every task. Without separating tmpdir for each user (buildslave) we could (and will) delete tmp files of a task that is running via different buildslave. Log files are now also separated for each user (/var/log/taskotron/taskotron-buildslave1.log).

Ah, that makes sense :) Please put that into the commit message, or a comment in code, thanks.

So, instead of performing os.path.join(config.tmpdir, getpass.getuser()) at every single place where we want to use tmpdir (I bet you that we will forget it sooner or later), wouldn't be easier and more reliable to introduce a method like _customize_values() in config.py and overwrite config.tmpdir with that personalized value? Then you can easily use config.tmpdir anywhere and you'll be sure you're still in your personal namespace.

The same can be done for cachedir, even though we might not be using it much yet.

mkrizek updated this revision to Diff 1644.Oct 30 2015, 4:40 PM

Customize tmpdir right after being loaded and merged.

kparal accepted this revision.Nov 2 2015, 4:40 PM
kparal added inline comments.
libtaskotron/config.py
254

A comment here explaining why we're doing this would be great.

This revision was automatically updated to reflect the committed changes.