From 55329894b74e6bdd89579d3ade035403ef4ab68b Mon Sep 17 00:00:00 2001 From: Firmlyzhu Date: Sun, 6 Jan 2019 19:05:31 +0800 Subject: [PATCH 1/3] Fix some bug on taskcontroller.py --- conf/container.batch.conf | 1 + src/worker/taskcontroller.py | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/conf/container.batch.conf b/conf/container.batch.conf index f91af20..fa8301e 100644 --- a/conf/container.batch.conf +++ b/conf/container.batch.conf @@ -27,6 +27,7 @@ lxc.network.link = lxcbr0 lxc.network.flags = up lxc.network.ipv4 = %IP% lxc.network.ipv4.gateway = %GATEWAY% +lxc.network.mtu = 1420 lxc.cgroup.pids.max = 2048 lxc.cgroup.memory.limit_in_bytes = %CONTAINER_MEMORY%M diff --git a/src/worker/taskcontroller.py b/src/worker/taskcontroller.py index 3fd6daa..32104ed 100755 --- a/src/worker/taskcontroller.py +++ b/src/worker/taskcontroller.py @@ -16,6 +16,7 @@ import grpc #from utils import env import json,lxc,subprocess,threading,os,time,traceback from utils import imagemgr,etcdlib,gputools +from utils.lvmtool import sys_run from worker import ossmounter from protos import rpc_pb2, rpc_pb2_grpc @@ -200,8 +201,8 @@ class TaskController(rpc_pb2_grpc.WorkerServicer): path = env.getenv('DOCKLET_LIB') subprocess.call([path+"/master/userinit.sh", username]) logger.info("user %s directory not found, create it" % username) - sys_run("mkdir -p /var/lib/lxc/%s" % lxcname) - logger.info("generate config file for %s" % lxcname) + sys_run("mkdir -p /var/lib/lxc/%s" % lxcname) + logger.info("generate config file for %s" % lxcname) def config_prepare(content): content = content.replace("%ROOTFS%",rootfs) From 8fc02b21374b81175e6b04fc198dbb841f3899ff Mon Sep 17 00:00:00 2001 From: zhuyj17 Date: Mon, 7 Jan 2019 00:07:24 +0800 Subject: [PATCH 2/3] Use lxc-start cmd instead of lxc api --- src/worker/taskcontroller.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/worker/taskcontroller.py b/src/worker/taskcontroller.py index 32104ed..3dce274 100755 --- a/src/worker/taskcontroller.py +++ b/src/worker/taskcontroller.py @@ -273,8 +273,11 @@ class TaskController(rpc_pb2_grpc.WorkerServicer): conffile.write("\n"+ mount_str % (self.fspath, username, mount.remotePath, rootfs, mount.remotePath)) conffile.close() - container = lxc.Container(lxcname) - if not container.start(): + + logger.info("Start container %s..." % lxcname) + #container = lxc.Container(lxcname) + ret = subprocess.run('lxc-start -n %s'%lxcname,stdout=subprocess.PIPE,stderr=subprocess.STDOUT, shell=True) + if ret.returncode != 0: logger.error('start container %s failed' % lxcname) self.release_ip(ip) self.imgmgr.deleteFS(lxcname) From 6d2c27ceeed06ca1e4a7f8bf0fb38fd47bdbe9af Mon Sep 17 00:00:00 2001 From: zhuyj17 Date: Mon, 7 Jan 2019 00:14:24 +0800 Subject: [PATCH 3/3] fix a bug of output & batch nat --- bin/docklet-master | 3 +++ bin/docklet-supermaster | 3 +++ web/templates/batch/batch_output.html | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/bin/docklet-master b/bin/docklet-master index 807ba83..efe1a92 100755 --- a/bin/docklet-master +++ b/bin/docklet-master @@ -32,6 +32,8 @@ WEB_PORT=8888 USER_PORT=9100 #cluster net, default is 172.16.0.1/16 CLUSTER_NET="172.16.0.1/16" +# ip addresses range of containers for batch job, default is 10.0.3.0/24 +BATCH_NET="10.0.3.0/24" #configurable-http-proxy public port, default is 8000 PROXY_PORT=8000 #configurable-http-proxy api port, default is 8001 @@ -103,6 +105,7 @@ pre_start_master () { # iptables for NAT network for containers to access web iptables -t nat -F iptables -t nat -A POSTROUTING -s $CLUSTER_NET -j MASQUERADE + iptables -t nat -A POSTROUTING -s $BATCH_NET -j MASQUERADE } diff --git a/bin/docklet-supermaster b/bin/docklet-supermaster index ed93ef1..b9ae006 100755 --- a/bin/docklet-supermaster +++ b/bin/docklet-supermaster @@ -36,6 +36,8 @@ WEB_PORT=8888 USER_PORT=9100 #cluster net, default is 172.16.0.1/16 CLUSTER_NET="172.16.0.1/16" +# ip addresses range of containers for batch job, default is 10.0.3.0/24 +BATCH_NET="10.0.3.0/24" . $DOCKLET_CONF/docklet.conf @@ -103,6 +105,7 @@ pre_start_master () { # iptables for NAT network for containers to access web iptables -t nat -F iptables -t nat -A POSTROUTING -s $CLUSTER_NET -j MASQUERADE + iptables -t nat -A POSTROUTING -s $BATCH_NET -j MASQUERADE } diff --git a/web/templates/batch/batch_output.html b/web/templates/batch/batch_output.html index 1dfe318..f22a61e 100644 --- a/web/templates/batch/batch_output.html +++ b/web/templates/batch/batch_output.html @@ -53,7 +53,7 @@ var host = window.location.host; url = "//" + host + "/batch/job/output/" + "{{ masterip }}" + "/" + "{{ jobid }}" + "/" + "{{ taskid }}" + "/" + "{{ instid }}" + "/" + "{{ issue }}" + "/"; $.post(url,{},function(data){ - $("#output").html(data.data); + $("#output").text(String(data.data)); },"json"); } setInterval(updateOutput,2000);