Skip to content

Commit

Permalink
Merge pull request #45 from autolab/docker_vmms
Browse files Browse the repository at this point in the history
Implementation of Docker vmms
  • Loading branch information
Ilter committed Apr 7, 2015
2 parents 3baadca + ca035fe commit 833f699
Show file tree
Hide file tree
Showing 14 changed files with 296 additions and 13 deletions.
2 changes: 1 addition & 1 deletion clients/job1/autograde-Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
autograde:
./hello.sh
bash hello.sh


2 changes: 1 addition & 1 deletion clients/job2/autograde-Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
autograde:
./hello.sh
bash hello.sh


2 changes: 1 addition & 1 deletion clients/job4/autograde-Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
autograde:
(./hello.sh; exit 2)
(bash hello.sh; exit 2)



4 changes: 1 addition & 3 deletions clients/job5/autograde-Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
autograde:
./hello.sh


bash hello.sh
2 changes: 1 addition & 1 deletion clients/job6/autograde-Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
autograde:
./hello.sh
bash hello.sh


2 changes: 1 addition & 1 deletion clients/job7/autograde-Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
autograde:
./bug
bash bug



18 changes: 15 additions & 3 deletions config.template.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Config:
LOGLEVEL = logging.DEBUG

# Courselabs directory. Must be created before starting Tango
COURSELABS = "<INSERT_PATH_HERE>"
COURSELABS = "courselabs"

# VMMS to use. Must be set to a VMMS implemented in vmms/ before
# starting Tango. Options are: "localSSH", "tashiSSH", "ec2SSH"
Expand Down Expand Up @@ -62,6 +62,16 @@ class Config:
RUNJOB_TIMEOUT = 60
COPYOUT_TIMEOUT = 30

# Docker constants
BOOT2DOCKER_INIT_TIMEOUT = 5
BOOT2DOCKER_START_TIMEOUT = 30
BOOT2DOCKER_ENV_TIMEOUT = 5
DOCKER_IMAGE_BUILD_TIMEOUT = 300
DOCKER_RM_TIMEOUT = 5
# Must be absolute path with trailing slash
# Default value of '*'' points this path to /path/to/Tango/volumes/
DOCKER_VOLUME_PATH = '*'

# Maximum size for output file in bytes
MAX_OUTPUT_FILE_SIZE = 1000 * 1024

Expand All @@ -88,10 +98,12 @@ class Config:
POOL_SIZE = 2

# Path for tashi images
TASHI_IMAGE_PATH = "/raid/tashi/images/"
TASHI_IMAGE_PATH = ''


# Optionally log finer-grained timing information
LOG_TIMING = True
LOG_TIMING = False


# Largest job ID
MAX_JOBID = 500
Expand Down
3 changes: 3 additions & 0 deletions jobManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ def __manage(self):
elif Config.VMMS_NAME == "ec2SSH":
from vmms.ec2SSH import Ec2SSH
vmms = Ec2SSH()
elif Config.VMMS_NAME == "localDocker":
from vmms.localDocker import LocalDocker
vmms = LocalDocker()

vmms = {Config.VMMS_NAME: vmms}
preallocator = Preallocator(vmms)
Expand Down
12 changes: 12 additions & 0 deletions restful-tango/tangoREST.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ class TangoREST:

def __init__(self):

logging.basicConfig(
filename = self.LOGFILE,
format = "%(levelname)s|%(asctime)s|%(name)s|%(message)s",
level = Config.LOGLEVEL
)

vmms = None

if Config.VMMS_NAME == "localSSH":
Expand All @@ -78,6 +84,10 @@ def __init__(self):
elif Config.VMMS_NAME == "ec2SSH":
from vmms.ec2SSH import Ec2SSH
vmms = Ec2SSH()
elif Config.VMMS_NAME == "localDocker":
from vmms.localDocker import LocalDocker
vmms = LocalDocker()


self.vmms = {Config.VMMS_NAME: vmms}
self.preallocator = Preallocator(self.vmms)
Expand All @@ -90,11 +100,13 @@ def __init__(self):
JobManager(self.queue, self.vmms, self.preallocator)

self.tango = TangoServer(self.queue, self.preallocator, self.vmms)

logging.basicConfig(
filename=self.LOGFILE,
format="%(levelname)s|%(asctime)s|%(name)s|%(message)s",
level=Config.LOGLEVEL
)

logging.getLogger('boto').setLevel(logging.INFO)
self.log = logging.getLogger("TangoREST")
self.log.info("Starting RESTful Tango server")
Expand Down
4 changes: 2 additions & 2 deletions tangod.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def getJobs(self, item):
return self.jobQueue.deadJobs.values()

elif item == 0: # return the list of live jobs
return self.jobQueue.jobQueue.values()
return self.jobQueue.liveJobs.values()

else: # invalid parameter
return []
Expand Down Expand Up @@ -207,7 +207,7 @@ def resetTango(self, vmms):
log.warning("Killed these %s VMs on restart: %s" %
(vmms_name, namelist))

for job in self.jobQueue.jobQueue.values():
for job in self.jobQueue.liveJobs.values():
self.log.debug("job: %s, assigned: %s" %
(str(job.name), str(job.assigned)))

Expand Down
34 changes: 34 additions & 0 deletions vmms/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Autolab - autograding docker image

FROM ubuntu:14.04
MAINTAINER Mihir Pandya <mihir.m.pandya@gmail.com>

RUN apt-get update
RUN apt-get install -y gcc
RUN apt-get install -y make
RUN apt-get install -y build-essential

# Install autodriver
WORKDIR /home
RUN useradd autolab
RUN useradd autograde
RUN mkdir autolab autograde output
RUN chown autolab:autolab autolab
RUN chown autolab:autolab output
RUN chown autograde:autograde autograde
RUN apt-get install -y git
RUN git clone https://github.com/autolab/Tango.git
WORKDIR Tango/autodriver
RUN make clean && make
RUN cp autodriver /usr/bin/autodriver
RUN chmod +s /usr/bin/autodriver

# Clean up
WORKDIR /home
RUN apt-get remove -y git
RUN apt-get -y autoremove
RUN rm -rf Tango/

# Check installation
RUN ls -l /home
RUN which autodriver
Loading

0 comments on commit 833f699

Please sign in to comment.