Skip to content

Support for Slurm batchSystem (resolves #682) - #718

Closed
dleehr wants to merge 1 commit into
DataBiosphere:masterfrom
Duke-GCB:slurm-rebased
Closed

dleehr wants to merge 1 commit into
DataBiosphere:masterfrom
Duke-GCB:slurm-rebased

Conversation

@dleehr

@dleehr dleehr commented Mar 17, 2016 •

Copy link
Copy Markdown
Contributor

Implements support for slurm scheduler

  • SlurmBatchSystem class is modeled after GridengineBatchSystem
  • Maps AbstractBatchSystem methods to sbatch, squeue, scancel, sacct, sinfo subprocess calls
  • Includes SlurmBatchSystemTest for testing system

@cgcloud-jenkins

Copy link
Copy Markdown

Can one of the admins verify this patch?

1 similar comment
@cgcloud-jenkins

Copy link
Copy Markdown

Can one of the admins verify this patch?

@hannes-ucsc

Copy link
Copy Markdown
Member

Jenkins, test this please.

@hannes-ucsc

Copy link
Copy Markdown
Member

@dleehr I invited you to our organization. Once you accept the invitation, you should be able to see the Jenkins build results. I'm going to trigger another build, since the last build left the slave in a weird state.

@hannes-ucsc

Copy link
Copy Markdown
Member

Jenkins, test this please.

1 similar comment
@hannes-ucsc

Copy link
Copy Markdown
Member

Jenkins, test this please.

@hannes-ucsc

Copy link
Copy Markdown
Member

@dleehr, previous builds had crashed the slave but the most recent one didn't. I'll try a few more times. In either case, these Slurm tests fail. Let me know if you don't see the

Oh, before I forget you don't need to open a new PR after rebasing. By default, PR branches can be force-pushed. Only, PRs that are labelled multi-author are prohibited from being force pushed to.

@hannes-ucsc

Copy link
Copy Markdown
Member

Jenkins, test this please.

@hannes-ucsc

Copy link
Copy Markdown
Member

@dleehr

dleehr commented Mar 24, 2016

Copy link
Copy Markdown
Contributor Author

I can't tell why this fails without some additional output. The tests pass on my cluster (running slurm 14.11.9):

$ python setup.py test --pytest-args "-vv src/toil/test/batchSystems/batchSystemTest.py::SlurmBatchSystemTest"
running test
running egg_info
writing requirements to src/toil.egg-info/requires.txt
writing src/toil.egg-info/PKG-INFO
writing top-level names to src/toil.egg-info/top_level.txt
writing dependency_links to src/toil.egg-info/dependency_links.txt
writing entry points to src/toil.egg-info/entry_points.txt
reading manifest file 'src/toil.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'src/toil.egg-info/SOURCES.txt'
running build_ext
============================================================================================================== test session starts ==============================================================================================================
platform linux2 -- Python 2.7.3, pytest-2.8.3, py-1.4.31, pluggy-0.3.1 -- /home/dcl9/env-toil/bin/python
cachedir: .cache
rootdir: /home/dcl9/toil, inifile: setup.cfg
collected 5 items 

src/toil/test/batchSystems/batchSystemTest.py::SlurmBatchSystemTest::testAvailableCores PASSED
src/toil/test/batchSystems/batchSystemTest.py::SlurmBatchSystemTest::testCheckResourceRequest PASSED
src/toil/test/batchSystems/batchSystemTest.py::SlurmBatchSystemTest::testGetRescueJobFrequency PASSED
src/toil/test/batchSystems/batchSystemTest.py::SlurmBatchSystemTest::testRunJobs PASSED
src/toil/test/batchSystems/batchSystemTest.py::SlurmBatchSystemTest::testSetEnv PASSED

I suspect it's related to the slurm version. The slurm package available for Trusty 14.04 is 2.6 http://packages.ubuntu.com/trusty/slurm-llnl, but Vivid 15.04 has version 14.03 http://packages.ubuntu.com/vivid/slurm-wlm. In 2013, slurm switched version numbering schemes for yearly releases. I'll bring my instance back up and see what happens there.

@dleehr

dleehr commented Mar 24, 2016

Copy link
Copy Markdown
Contributor Author

The issue was that the slurm config on the jenkins slave did not set the CPU and memory per node. The batchSystemTests do submit jobs with memory and CPU requirements, and slurm was not able to handle these requests. I've fixed the config in BD2KGenomics/cgcloud#137 but we'll need to rebuild the jenkins slave image from that before this can be retried.

@hannes-ucsc

Copy link
Copy Markdown
Member

I merged the cgcloud PR and updated the toil-jenkins-slave image. Now rerunning the tests.

@hannes-ucsc

Copy link
Copy Markdown
Member

Jenkins, test this please.

@ohofmann

Copy link
Copy Markdown

Following this with interest as well. We'd love to start using/testing Toil on a local SLURM system.

@hannes-ucsc

Copy link
Copy Markdown
Member

src/toil/test/batchSystems/batchSystemTest.py::SlurmBatchSystemTest::testRunJobs seems to hang

@dleehr

dleehr commented Mar 31, 2016

Copy link
Copy Markdown
Contributor Author

Yep, I see that. I need to check the subprocess for an exit code and fail if it failed. Then we should see why it's not working.

@hannes-ucsc

Copy link
Copy Markdown
Member

Adding -s to the pytest command line disables output capturing

diff --git a/Makefile b/Makefile
index 8bc81e8..e0b0c2f 100644
--- a/Makefile
+++ b/Makefile
@@ -69,7 +67,7 @@ clean_sdist:


 test: check_venv
-       $(python) setup.py test --pytest-args "-vv $(tests)"
+       $(python) setup.py test --pytest-args "-vv -s $(tests)"

@dleehr

dleehr commented Apr 1, 2016

Copy link
Copy Markdown
Contributor Author

Good tip, thanks

dleehr referenced this pull request in Duke-GCB/toil Apr 4, 2016
@dleehr

dleehr commented Apr 4, 2016

Copy link
Copy Markdown
Contributor Author

That helped. It seems the jobs aren't starting. The slurm partition goes into Down state because of "low memory". And I think I need to correct permissions on the slurm accounting file. More changes for the toil slave config coming, sorry!

@hannes-ucsc

Copy link
Copy Markdown
Member

@brainstorm

Are those CI build logs public?

No. Too risky. Only members of our GH org should have access. Is there a particular reason you would like to see them?

@ohofmann

ohofmann commented Apr 4, 2016

Copy link
Copy Markdown

Mostly we are waiting for this implementation to build successfully (see https://github.com/guillermo-carrasco/toil/blob/slurm/src/toil/batchSystems/slurm.py and #682) and were wondering if there's some way for us to help with the debugging process.

@brainstorm

Copy link
Copy Markdown
Contributor

@hannes-ucsc, I'm perhaps too used to CI/CD systems like TravisCI and CircleCI which have all logs available for every other open source project developer to see by default ;)

@dleehr

dleehr commented Apr 8, 2016

Copy link
Copy Markdown
Contributor Author

@hannes-ucsc This will need another rebuild of the toil-jenkins-slave image, using BD2KGenomics/cgcloud#141. I built a toil-jenkins-slave with that branch and the tests passed.

@hannes-ucsc

Copy link
Copy Markdown
Member

@dleehr, I merged that PR and recreated the AMI.

Jenkins, test this please.

@hannes-ucsc

Copy link
Copy Markdown
Member

Jenkins, test this please.

@dleehr

dleehr commented Apr 11, 2016

Copy link
Copy Markdown
Contributor Author

Thanks for merging/recreating. I don't know why this fails, when I build the image and run the tests myself, it passes. Perhaps someone with more slurm experience can take a look? /cc: @ohofmann @brainstorm @guillermo-carrasco. I can cut out the appropriate parts of the log

@dleehr

dleehr commented Apr 11, 2016

Copy link
Copy Markdown
Contributor Author

slurm-toil-log.txt

@guillermo-carrasco

Copy link
Copy Markdown
Contributor

@dleehr thanks for the log. However I can't find any useful information in there, could you please attach here, if possible, the actual SLURM log?

Thanks!

@dleehr

dleehr commented Apr 11, 2016

Copy link
Copy Markdown
Contributor Author

@guillermo-carrasco: I don't have access to the host or the slurm log. All I have is the console output from the test. @hannes-ucsc - Any ideas?

@guillermo-carrasco

Copy link
Copy Markdown
Contributor

Just to make the point, we've been testing your branch in our cluster and it seems to work as well.

@brainstorm

Copy link
Copy Markdown
Contributor

@dleehr I guess that a quick debug hack would be to run slurmctld log (if slurmd runs on the same test machine and if you are root).

@dleehr

dleehr commented Apr 11, 2016

Copy link
Copy Markdown
Contributor Author

Thanks @brainstorm. I've now built a jenkins cluster with cgcloud (1 master and one toil slave). I'm seeing the same issues here, so I should be able to troubleshoot

@hannes-ucsc

Copy link
Copy Markdown
Member

I've now built a jenkins cluster with cgcloud (1 master and one toil slave). I'm seeing the same issues here, so I should be able to troubleshoot

Glad to hear that you an reproduce this on your own cluster.

Generally speaking, cgcloud prefers to use a special application user as opposed to running applications as root or a user that has password-less sudo. Jenkins builds are run as the jenkins user which has sudo only for specific commands. You might have set up Slurm on the slave in such a way that only root can run certain commands. Ideally, an unprivileged user should be able to run Toil on a Slurm cluster, and the tests running as the unprivileged jenkins user would replicate that mode of operation. As a last resort, though, we could allow jenkins to run those privileged SLURM commands via /etc/sudoers. If you want to go down that route, search for /etc/sudoers in the cgcloud code base and you'll see what I mean.

@dleehr

dleehr commented Apr 11, 2016

Copy link
Copy Markdown
Contributor Author

Ideally, an unprivileged user should be able to run Toil on a Slurm cluster, and the tests running as the unprivileged jenkins user would replicate that mode of operation

Yep, and that's mostly working. The problem is with permissions on the /var/run/slurm-llnl/slurm-acct.txt file. The sacct command (used to check status of completed jobs) reads this file. If the user running sacct can't read the file, it fails. I added some debugging:

DEBUG:toil.batchSystems.slurm:Checking status of internal job id 1
DEBUG:toil.batchSystems.slurm:Getting exit code for slurm job 3
DEBUG:toil.batchSystems.slurm:Checking line for exit codes: /var/run/slurm-llnl/slurm-acct.txt: Permission denied
DEBUG:toil.batchSystems.slurm:Unable to get exit code

Despite setting the permission and ownership to 644 of this file in toil_jenkins_slave.py, permissions are 600 when jenkins runs the tests. Perhaps by virtue of being in /var/run. I didn't catch it when creating the slave from an image (using cgcloud) because cgcloud still runs the setup script every time (which fixes the perms)

I'll either relocate the file or otherwise ensure the permissions.

@hannes-ucsc

Copy link
Copy Markdown
Member

I'll either relocate the file or otherwise ensure the permissions.

Consider using self._register_init_command() for that. There is one usage of it already in JenkinSlave._setup_build_user() which is similar to your use case.

Another alternative would be to modify the Slurm init scripts to do the necessary chmod/chown.

Do the Slurm daemons need to be run as root?

@dleehr

dleehr commented Apr 12, 2016

Copy link
Copy Markdown
Contributor Author

Do the Slurm daemons need to be run as root?

slurmctld runs as slurm, and slurmd runs as root. It wasn't really a root problem, the file in question was owned by `slurm:slurm. That works fine, but the permissions were being set to 0600 on boot. I relocated the file to /var/log and it's happy there (BD2KGenomics/cgcloud#145).

Thanks for your patience. I'm confident this will pass once the toil-jenkins-slave image is rebuilt again - I confirmed it on a cgcloud jenkins cluster.

@hannes-ucsc

Copy link
Copy Markdown
Member

I relocated the file to /var/log

Not exactly LSB, but ok. I may open a separate ticket to move it back to /var/run and fix the permissions explicitly.

@hannes-ucsc

Copy link
Copy Markdown
Member

I created a new slave image with @dleehr's PRed changes.

Jenkins, test this please.

@hannes-ucsc

Copy link
Copy Markdown
Member

All tests pass! But build fails with

You have are untracked files:
slurm-2.out
slurm-3.out
slurm-4.out
slurm-5.out
slurm-6.out

Toil tests have to clean up after themselves.

@hannes-ucsc

Copy link
Copy Markdown
Member

And, looking at the history, I think the commits should be squashed.

@dleehr

dleehr commented Apr 14, 2016

Copy link
Copy Markdown
Contributor Author

Ok I'll clean up the extra files. As for the commit squashing, GitHub can do that on merge now, does that work?

@hannes-ucsc

Copy link
Copy Markdown
Member

As for the commit squashing, GitHub can do that on merge now, does that work?

Doesn't that require you to rebase your branch on top of master? And if that is the case, how hard is it to squash while rebasing? Maybe I'm confused about this option. Another thing about squashing before the merge is that I get a CI build of the exact commit that get's merged. But again, educate me, I'm probably not up-to-date here.

@dleehr

dleehr commented Apr 14, 2016

Copy link
Copy Markdown
Contributor Author

Doesn't that require you to rebase your branch on top of master?

Actually no. I just tested it in a demo repo - It's a new feature on GitHub. Seems to work as long as there are no conflicts.

I'll be pushing changes to clean up the dirty working copy very soon

Comment thread src/toil/batchSystems/slurm.py Outdated
# -N is job name, which should be based on the jobID

sbatch_line = ['sbatch', '-Q', '-J', 'toil_job_{}'.format(jobID)]
sbatch_line = ['sbatch', '-Q', '-J', 'toil_job_{}'.format(jobID), '-o', '/dev/null', '-e', '/dev/null']

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what the GridEngine batch system does and turned out to be a bad idea. If anything goes wrong before worker.py gets a chance to setup its own redirection, any errors that occur will be swallowed, making diagnosing problems much harder.

We have something in the works that will allow us to set a workflow-specific location for files like this. For the time being, could you undo this change and instead add the appropriate clean-up code to the tests?

@hannes-ucsc

Copy link
Copy Markdown
Member

Seems to work as long as there are no conflicts.

I tried this too (on a different project) and it works. I don't like how it leaves the source branch dangling in the history. That and the fact that our CI does not build the exact merge commit will probably mean that we won't be using this feature for now. If you don't have the time to squash the commits, I will go ahead and do that in a separate PR (you'll remain the commit author). You have contributed a great deal and I don't want to test your patience with my pedantry.

@dleehr

dleehr commented Apr 15, 2016

Copy link
Copy Markdown
Contributor Author

Ok I can squash when I update with the cleanup change. Happy to help.

Implements support for slurm scheduler
SlurmBatchSystem class is modeled after GridengineBatchSystem
Maps AbstractBatchSystem methods to sbatch, squeue, scancel, sacct, sinfo subprocess calls
Includes SlurmBatchSystemTest for testing system
Wrap submitted sbatch command in --wrap
@dleehr

dleehr commented Apr 15, 2016

Copy link
Copy Markdown
Contributor Author

Looks like the only failure is src.toil.test.cwl.cwlTest.CWLTest.test_run_conformance, but that's failing in a bunch of other branches now too.

@hannes-ucsc

Copy link
Copy Markdown
Member

Yes, test failure tracked in #783. Fix has been merged. Going to rebase this branch.

@hannes-ucsc

Copy link
Copy Markdown
Member

Continued in #799

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants