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/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..3dce274 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) @@ -272,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) 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);