From 94d0281848655160b9c730dc80eac22eeb4485d9 Mon Sep 17 00:00:00 2001 From: Guillaume Derval Date: Fri, 4 Mar 2016 15:30:54 +0100 Subject: [PATCH] Update to latest version of Docker; update documentation --- doc/install_doc/installation.rst | 12 ++++---- inginious/backend/agent/simple_agent.py | 38 ++++++++++++++----------- setup.py | 3 +- 3 files changed, 29 insertions(+), 24 deletions(-) diff --git a/doc/install_doc/installation.rst b/doc/install_doc/installation.rst index 3a0c73e52..86a6b5e1f 100644 --- a/doc/install_doc/installation.rst +++ b/doc/install_doc/installation.rst @@ -38,12 +38,12 @@ If you already have ``web.py`` on your machine, run: $ pip uninstall web.py $ pip install web.py-INGI -Centos 7.0+ -``````````` +Centos 7.0+, Fedora 22+ +``````````````````````` :: - $ sudo yum install -y epel-release + $ sudo yum install -y epel-release #CentOS only $ sudo yum install -y git mongodb mongodb-server docker python-pip gcc python-devel libtidy .. note:: @@ -139,7 +139,7 @@ recent project, it is better to use dev version, which have a lot more functionn :: - $ pip install --process-dependency-links --upgrade git+https://github.com/UCL-INGI/INGInious.git + $ pip install --upgrade git+https://github.com/UCL-INGI/INGInious.git Run the same command to upgrade. @@ -150,7 +150,7 @@ Run the same command to upgrade. :: - $ pip install --process-dependency-links --upgrade git+https://github.com/UCL-INGI/INGInious.git[cgi,ldap] + $ pip install --upgrade git+https://github.com/UCL-INGI/INGInious.git[cgi,ldap] Pip+Pipy @@ -161,7 +161,7 @@ version from pipy than with the development version. :: - $ pip install --process-dependency-links --upgrade inginious + $ pip install --upgrade inginious Run the same command to upgrade. diff --git a/inginious/backend/agent/simple_agent.py b/inginious/backend/agent/simple_agent.py index 64573c867..4ac8904bc 100644 --- a/inginious/backend/agent/simple_agent.py +++ b/inginious/backend/agent/simple_agent.py @@ -356,7 +356,16 @@ def handle_job(self, job_id, course_id, task_id, inputdata, debug, ssh_callback) environment, stdin_open=True, volumes={'/task': {}, '/sockets': {}}, - network_disabled=not (task.allow_network_access_grading() or debug == "ssh") + network_disabled=not (task.allow_network_access_grading() or debug == "ssh"), + host_config = docker_connection.create_host_config( + mem_limit=str(mem_limit) + "M", + memswap_limit=str(mem_limit) + "M", + mem_swappiness=0, + oom_kill_disable=True, + network_mode=("bridge" if (task.allow_network_access_grading() or debug == "ssh") else 'none'), + binds={os.path.abspath(task_path): {'ro': False, 'bind': '/task'}, + os.path.abspath(sockets_path): {'ro': False, 'bind': '/sockets'}} + ) ) container_id = response["Id"] self._container_for_job[job_id] = container_id @@ -385,13 +394,7 @@ def handle_job(self, job_id, course_id, task_id, inputdata, debug, ssh_callback) student_container_management_thread.start() # Start the container - docker_connection.start(container_id, - binds={os.path.abspath(task_path): {'ro': False, 'bind': '/task'}, - os.path.abspath(sockets_path): {'ro': False, 'bind': '/sockets'}}, - mem_limit=mem_limit * 1024 * 1024, - memswap_limit=mem_limit * 1024 * 1024, # disable swap - oom_kill_disable=True, - network_mode=("bridge" if (task.allow_network_access_grading() or debug == "ssh") else None)) + docker_connection.start(container_id) # Send the input data container_input = {"input": inputdata, "limits": limits} @@ -505,18 +508,21 @@ def _create_new_student_container(self, container_name, working_dir, command, me volumes={'/task/student': {}}, command=command, working_dir=working_dir, - user="4242" + user="4242", + mem_limit=str(mem_limit)+"M", + host_config=docker_connection.create_host_config( + mem_limit=str(mem_limit) + "M", + memswap_limit= str(mem_limit) + "M", + mem_swappiness=0, + oom_kill_disable=True, + network_mode=('none' if not share_network else ('container:' + parent_container_id)), + binds={os.path.abspath(student_path): {'ro': False, 'bind': '/task/student'}} + ) ) container_id = response["Id"] # Start the container - docker_connection.start(container_id, - binds={os.path.abspath(student_path): {'ro': False, 'bind': '/task/student'}}, - mem_limit=mem_limit * 1024 * 1024, # add 10 mo of bonus, as we check the memory in the "cgroup" thread - memswap_limit=mem_limit * 1024 * 1024, # disable swap - oom_kill_disable=True, - network_mode=(None if not share_network else ('container:'+parent_container_id)) - ) + docker_connection.start(container_id) stdout_err = docker_connection.attach_socket(container_id, {'stdin': 0, 'stdout': 1, 'stderr': 1, 'stream': 1, 'logs': 1}) except Exception as e: diff --git a/setup.py b/setup.py index 58ebbf40f..28049eb86 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ on_rtd = os.environ.get('READTHEDOCS', None) == 'True' install_requires = [ - "docker-py==1.3.0.dev0", + "docker-py==1.7.2", "docutils>=0.12", "plumbum>=1.5.0", "pymongo>=3.0.3", @@ -54,7 +54,6 @@ version=inginious.__version__, description="An intelligent grader that allows secured and automated testing of code made by students.", packages=find_packages(), - dependency_links=["git+https://github.com/GuillaumeDerval/docker-py.git#egg=docker-py-1.3.0.dev0"], install_requires=install_requires, tests_require=test_requires, extras_require={