mesos / chronos

Fault tolerant job scheduler for Mesos which handles dependencies and ISO8601 based schedules
http://mesos.github.io/chronos/
Apache License 2.0
4.39k stars 528 forks source link

Other resources than disk,memory,cpu #111

Open exnerd opened 11 years ago

exnerd commented 11 years ago

I would like to run jobs on specific nodes. To achieve this it would be nice to add resources (like libraries, db-connection,...) to a node. That would make the job run only on those nodes having the necessary resources.

Benoît

rocker96 commented 10 years ago

Actually Mesos supports specific nodes by add resources "ports:[xxxx-xxxx]". For history reason, we need some jobs to run only one or several slaves, we don't want to add more Chronos Master and Mesos Master. Chronos seems has no way to set up cpu/mem/disk/ports resource for one job. So I find a way to fix a code to implement this quickly for presentation. For example: Step1: Slave1 or other slaves work for jobs of Hadnoop: ./mesos-slave.sh --master=zk://172.16.10.100:2181/mesos --resources=mem:2048;cpus:2;ports:[1000-2000] --ip=172.16.10.1xx

Slave2 or others for some jobs like Shark: ./mesos-slave.sh --master=zk://172.16.10.100:2181/mesos --resources=mem:2048;cpus:2;ports:[2000-3000] --ip=172.16.10.2xx

Step2, fix the code as below (please notice that I'm new for scala and the code is only for test): (/chronos/src/main/scala/com/airbnb/scheduler/mesos/MesosJobFramework.scala) def buildTask(taskId: String, job: BaseJob, offer: Offer) : (Boolean, TaskInfo.Builder, Offer) = { ... case Value.Type.SCALAR => ...... case Value.Type.RANGES => if (job.command.indexOf("ports:[") > -1) { var taskRange = job.command.substring(job.command.indexOf("ports:[") + 7, job.command.length() - 2) var resourceRangeBegin = x.getRanges.getRange(0).getBegin var resourceRangeEnd = x.getRanges.getRange(0).getEnd var resourcePorts = resourceRangeBegin + "-" + resourceRangeEnd if (resourcePorts == taskRange) { sufficient("ports") = true; log.warning("=====>Matched : %s".format(taskRange + ":" + resourcePorts)) } else { log.warning("=====>Not matched : %s".format(taskRange + ":" + resourcePorts)) } } case _ => log.warning("=====>: Ignoring offered resource: %s".format(x.getType.toString)) }) if (job.command.indexOf("ports:[") > -1) { (sufficient("cpus") && sufficient("mem") && sufficient("disk") && sufficient("ports"), taskInfoTemplate, offer) } else { (sufficient("cpus") && sufficient("mem") && sufficient("disk"), taskInfoTemplate, offer) }

Step3, Add a new job in WebUI with command: echo 'Test ports' && echo 'ports:[1000-2000]'. MesosJobFramework will get the ports' range from command to compare with slaves' resources one by one, if matched, then use the slave to run the task. For time limited, I still have no time to fix the WEBUI of Chronos to add "cpu/mem/disk/ports" fields for one job. I think Chronos project team should consider this requirement.

The ports resource seems free to add values based on the format, As my test for only one slave, I directly set the IP inside: ports:[1721610101-1721610101], that's all I learn these days, hope this can help you.

chengweiv5 commented 9 years ago

mesos slave has "--attributes" potion to attach some tags to a slave, and this will send to on-top shceduler, like chronos. So the scheduler can filter slave with it's attribute.

However, chronos doesn't support this feature yet, we have plan to implement this feature and like to see accepted by upstream.

To @exnerd , it's generally not a good idea to have your specific job depends on the slaves which in a computing pool, it's better to integrate with Docker container to do that, build your job into a docker image and free to go.

felixb commented 9 years ago

this is kind of a duplicate of #256