prasmussen / glot-run

API for running code inside docker containers
https://run.glot.io/
MIT License
147 stars 48 forks source link

Code exceeded the maximum allowed running time #19

Closed omartrigui closed 7 years ago

omartrigui commented 7 years ago

The problem occurs when i POST a python sample to my local server

curl -X POST \
  http://127.0.0.1:9999/languages/python/latest \
  -H 'authorization: Token d11088bc-a29d-4d49-a633-b1b1ae807064' \
  -H 'content-type: application/json' \
  -d '{
  "language": "python",
  "files": [
    {
      "name": "main.py",
      "content": "print(42)"
    }
  ]
}'

I receive a 400 Bad request with a message :

{"message": "Code exceeded the maximum allowed running time"}

Additional informations about my environment: Docker API :

$ curl http://127.0.0.1:2375/version
{"Version":"17.05.0-ce","ApiVersion":"1.29", etc ...

glot-run output :

19:59:11.166 [info] Application lager started on node 'glot-run@127.0.0.1'
19:59:11.166 [info] Application cowboy started on node 'glot-run@127.0.0.1'
19:59:11.166 [info] Application uuid started on node 'glot-run@127.0.0.1'
19:59:11.166 [info] Application ssl_verify_fun started on node 'glot-run@127.0.0.1'
19:59:11.166 [info] Application hackney started on node 'glot-run@127.0.0.1'
20:12:56.530 [warning] lager_error_logger_h dropped 64 messages in the last second that exceeded the limit of 50 messages/sec

glot-run script runner :

#!/bin/bash

export API_ENVIRONMENT="development" \
export API_HTTP_LISTEN_IP="0.0.0.0" \
export API_HTTP_LISTEN_PORT="9999" \
export DATA_PATH="/tmp" \
export LOG_PATH="/tmp" \
export BASE_URL="http://127.0.0.1" \
export ADMIN_TOKEN="secret" \
export DOCKER_API_URL="http://127.0.0.1:2375" \
export DOCKER_RUN_TIMEOUT="15" \
export MAX_OUTPUT_SIZE="100000" \

./glot foreground

I appreciate any support.

prasmussen commented 7 years ago

Does the curl request run for ~15 seconds before you get the 400 response?

Are you able to run the docker image manually by running the following command:

echo '{ "language": "python", "files": [{ "name": "main.py", "content": "print(\"Hello World!\")" }] }' | docker run -i --rm glot/python:latest

(Should give the following result: {"stdout":"Hello World!\n","stderr":"","error":""})

omartrigui commented 7 years ago

After executing the provided command, i've received no response ... Freezed. Maybe an issue related to the glot/python container or docker daemon ?

prasmussen commented 7 years ago

I just deleted the image and downloaded a fresh one from docker hub, works fine for me:

$ echo '{ "language": "python", "files": [{ "name": "main.py", "content": "print(\"Hello World!\")" }] }' | docker run -i --rm glot/python:latest
Unable to find image 'glot/python:latest' locally
latest: Pulling from glot/python
6d827a3ef358: Pull complete
2726297beaf1: Pull complete
7d27bd3d7fec: Pull complete
44ae682c18a3: Pull complete
824bd01a76a3: Pull complete
68fe59875298: Pull complete
9ca1d7ae0c4b: Pull complete
530e1718a99e: Pull complete
8d0be0e48b81: Pull complete
fcf42062c9c1: Pull complete
5ebf04eb5aa4: Pull complete
0d831d84095c: Pull complete
Digest: sha256:97c56c6e89c1656402be5d6c8bcef377ddb614af73e331854b9bdf46e04124b1
Status: Downloaded newer image for glot/python:latest
{"stdout":"Hello World!\n","stderr":"","error":""}

I see that you have a newer docker version than i have attempted with though, something might have changed in the newer versions. Or it might just be a configuration issue with your docker setup.

omartrigui commented 7 years ago

I see. In fact your docker daemon is configured with the flag -H fd:// , and my docker is configured with -H tcp://127.0.0.1:2375. An excerpt from my /lib/systemd/system/docker.service

ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375
   CGroup: /system.slice/docker.service
           ├─11453 /usr/bin/dockerd -H tcp://0.0.0.0:2375
           └─11466 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/

If i use the flag -H fd://, glot-run will not be able to establish any connection to docker daemon over tcp.

prasmussen commented 7 years ago

You can give multiple -H flags to the daemon to make it listen on both tcp and unix socket (fd://)

omartrigui commented 7 years ago

mm i see, now the previously provided command, works fine.

echo '{ "language": "python", "files": [{ "name": "main.py", "content": "print(\"Hello World!\")" }] }' | docker run -i --rm glot/python:latest
{"stdout":"Hello World!\n","stderr":"","error":""}

After restarting the local server, the POST is still returning :

{
    "message": "Code exceeded the maximum allowed running time"
}

The query :

curl -X POST \
  http://127.0.0.1:9999/languages/python/latest \
  -H 'authorization: Token d11088bc-a29d-4d49-a633-b1b1ae807064' \
  -H 'content-type: application/json' \
  -d '{
  "language": "python",
  "files": [
    {
      "name": "main.py",
      "content": "print(42)"
    }
  ]
}'
lalitlogical commented 6 years ago

Hey @OmarTrigui, i think you have resolved issue. Can you let us know, how you resolved the issue?