prasmussen / glot-run

API for running code inside docker containers

Home Page:https://run.glot.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Outdated Dockerfile?

ADrejta opened this issue · comments

When building the Dockerfile the build process exits with this message:

===> Verifying dependencies...
===> Analyzing applications...
===> Compiling glot
===> No releases have been specified in the system!

I also had to up the erlang version in the dockerfile from 22 => 23 since it was giving this message when building the dockerfile:

beam/beam_load.c(1876): Error loading module lager_transform:
  This BEAM file was compiled for a later version of the run-time system than 22.
  To fix this, please recompile this module with an 22 compiler.
  (Use of opcode 169; this emulator supports only up to 168.)

Is the dockerfile outdated?
I'd like to help with this but sadly i don't know erlang :(

I went ahead an used the docker image that is up on dockerhub provided by @javierprovecho but this error appears when i try to make a post request with the dummy python code specified in the api

{
   [
      {
         "reason",
         "badarg"
      },
      {
         "mfa",
         {
            "language_run_resource",
            "accept_post",
            2
         }
      },
      {
         "stacktrace",
         [
            {
               "erlang",
               "list_to_integer",
               [
                  [
                     
                  ]
               ],
               [
                  
               ]
            },
            {
               "hackney_url",
               "parse_netloc",
               2,
               [
                  {
                     "file",
                     "/glot-run/_build/default/lib/hackney/src/hackney_url.erl"
                  },
                  {
                     "line",
                     196
                  }
               ]
            },
            {
               "hackney",
               "request",
               5,
               [
                  {
                     "file",
                     "/glot-run/_build/default/lib/hackney/src/hackney.erl"
                  },
                  {
                     "line",
                     341
                  }
               ]
            },
            {
               "docker",
               "container_create",
               1,
               [
                  {
                     "file",
                     "/glot-run/_build/default/lib/glot/src/docker/docker.erl"
                  },
                  {
                     "line",
                     13
                  }
               ]
            },
            {
               "language_run",
               "run",
               3,
               [
                  {
                     "file",
                     "/glot-run/_build/default/lib/glot/src/models/language_run.erl"
                  },
                  {
                     "line",
                     11
                  }
               ]
            },
            {
               "language_run_resource",
               "run_code",
               3,
               [
                  {
                     "file",
                     "/glot-run/_build/default/lib/glot/src/resources/language_run_resource.erl"
                  },
                  {
                     "line",
                     97
                  }
               ]
            },
            {
               "cowboy_rest",
               "call",
               3,
               [
                  {
                     "file",
                     "/glot-run/_build/default/lib/cowboy/src/cowboy_rest.erl"
                  },
                  {
                     "line",
                     976
                  }
               ]
            },
            {
               "cowboy_rest",
               "process_content_type",
               3,
               [
                  {
                     "file",
                     "/glot-run/_build/default/lib/cowboy/src/cowboy_rest.erl"
                  },
                  {
                     "line",
                     777
                  }
               ]
            }
         ]
      },
      {
         "req",
         [
            {
               "socket",
               #Port<0.1039>
            },
            {
               "transport",
               "ranch_tcp"
            },
            {
               "connection",
               "keepalive"
            },
            {
               "pid",
               <0.670.0>
            },
            {
               "method",
               "<<""POST"">>"
            },
            {
               "version",
               "HTTP/1.1"
            },
            {
               "peer",
               {
                  {
                     172,
                     17,
                     0,
                     1
                  },
                  45930
               }
            },
            {
               "host",
               "<<""localhost"">>"
            },
            {
               "host_info",
               "undefined"
            },
            {
               "port",
               8099
            },
            {
               "path",
               "<<""/languages/python/latest"">>"
            },
            {
               "path_info",
               "undefined"
            },
            {
               "qs",
               "<<>>"
            },
            {
               "qs_vals",
               "undefined"
            },
            {
               "bindings",
               [
                  {
                     "version",
                     "<<""latest"">>"
                  },
                  {
                     "name",
                     "<<""python"">>"
                  }
               ]
            },
            {
               "headers",
               [
                  {
                     "<<""host"">>",
                     "<<""localhost:8099"">>"
                  },
                  {
                     "<<""user-agent"">>",
                     "<<""insomnia/2020.3.3"">>"
                  },
                  {
                     "<<""authorization"">>",
                     "<<""Token secret-token"">>"
                  },
                  {
                     "<<""content-type"">>",
                     "<<""application/json"">>"
                  },
                  {
                     "<<""accept"">>",
                     "<<""*/*"">>"
                  },
                  {
                     "<<""content-length"">>",
                     "<<""83"">>"
                  }
               ]
            },
            {
               "p_headers",
               [
                  {
                     "<<""content-type"">>",
                     {
                        "<<""application"">>",
                        "<<""json"">>",
                        [
                           
                        ]
                     }
                  },
                  {
                     "<<""if-modified-since"">>",
                     "undefined"
                  },
                  {
                     "<<""if-none-match"">>",
                     "undefined"
                  },
                  {
                     "<<""if-unmodified-since"">>",
                     "undefined"
                  },
                  {
                     "<<""if-match"">>",
                     "undefined"
                  },
                  {
                     "<<""accept"">>",
                     [
                        {
                           {
                              "<<""*"">>",
                              "<<""*"">>",
                              [
                                 
                              ]
                           },
                           1000,
                           [
                              
                           ]
                        }
                     ]
                  }
               ]
            },
            {
               "cookies",
               "undefined"
            },
            {
               "meta",
               [
                  {
                     "media_type",
                     {
                        "<<""application"">>",
                        "<<""json"">>",
                        [
                           
                        ]
                     }
                  },
                  {
                     "charset",
                     "undefined"
                  }
               ]
            },
            {
               "body_state",
               "waiting"
            },
            {
               "buffer",
               "<<""{\n\t\"language\": \"python\", \n\t\"files\": [{\"name\": \"main.py\", \"content\": \"print(42)\"}]\n}"">>"
            },
            {
               "multipart",
               "undefined"
            },
            {
               "resp_compress",
               false
            },
            {
               "resp_state",
               "waiting"
            },
            {
               "resp_headers",
               [
                  {
                     "<<""content-type"">>",
                     [
                        "<<""application"">>",
                        "<<""/"">>",
                        "<<""json"">>",
                        "<<>>"
                     ]
                  }
               ]
            },
            {
               "resp_body",
               "<<>>"
            },
            {
               "onresponse",
               #Fun<http_util.log_response.4>
            }
         ]
      },
      {
         "state",
         {
            "state",
            "<<""python"">>",
            "<<""latest"">>"
         }
      }
   ],
   [
      {
         "cowboy_rest",
         "process_content_type",
         3,
         [
            {
               "file",
               "/glot-run/_build/default/lib/cowboy/src/cowboy_rest.erl"
            },
            {
               "line",
               777
            }
         ]
      },
      {
         "cowboy_protocol",
         "execute",
         4,
         [
            {
               "file",
               "/glot-run/_build/default/lib/cowboy/src/cowboy_protocol.erl"
            },
            {
               "line",
               442
            }
         ]
      }
   ]
}

I have already added the languages to the api and have made a token in order to make POST request to the /languages/{language}/{version} endpoint.

  1. I'm not maintaining the Dockerfile, but I will accept a PR if someone wants to fix it.
  2. The image by javierprovecho on does not have the newest version of glot-run and does not work with recent versions of docker api.
  3. There is a prebuilt version of glot-run under releases if that is an option for you, I have only tested it on ubuntu 16.04 though.
  4. If you want to build it yourself, the make_release.sh script works on ubuntu 16.04, you need to install erlang via apt-get and download the rebar3 binary (there might be some other dependencies I forgot)
  5. FYI: I started a couple of weeks ago to rewrite glot-run in Rust which will be easier to compile and set-up on newer distros. I'm planning on replacing glot-run on glot.io within the next month or so. Let me know if you want early access to try it out.

Okay thank you.

I'd love to see the rust version of glot-run.

Even when building the file myself i am getting the same error:

Error in process <0.764.0> on node 'glot-run@127.0.0.1' with exit value:
{[{reason,badarg},
  {mfa,{language_run_resource,accept_post,2}},
  {stacktrace,[]},
  {req,[{socket,#Port<0.13>},
        {transport,ranch_tcp},
        {connection,keepalive},
        {pid,<0.764.0>},
        {method,<<"POST">>},
        {version,'HTTP/1.1'},
        {peer,{{127,0,0,1},51738}},
        {host,<<"localhost">>},
        {host_info,undefined},
        {port,8100},
        {path,<<"/languages/python/latest">>},
        {path_info,undefined},
        {qs,<<>>},
        {qs_vals,undefined},
        {bindings,[{version,<<"latest">>},{name,<<"python">>}]},
        {headers,[{<<"host">>,<<"localhost:8100">>},
                  {<<"user-agent">>,<<"insomnia/2020.3.3">>},
                  {<<"authorization">>,<<"Token secret-token">>},
                  {<<"content-type">>,<<"application/json">>},
                  {<<"accept">>,<<"*/*">>},
                  {<<"content-length">>,<<"83">>}]},
        {p_headers,[{<<"content-type">>,{<<"application">>,<<"json">>,[]}},
                    {<<"if-modified-since">>,undefined},
                    {<<"if-none-match">>,undefined},
                    {<<"if-unmodified-since">>,undefined},
                    {<<"if-match">>,undefined},
                    {<<"accept">>,[{{<<"*">>,<<"*">>,[]},1000,[]}]}]},
        {cookies,undefined},
        {meta,[{media_type,{<<"application">>,<<"json">>,[]}},
               {charset,undefined}]},
        {body_state,waiting},
        {buffer,<<"{\n\t\"language\": \"python\", \n\t\"files\": [{\"name\": \"main.py\", \"content\": \"print(42)\"}]\n}">>},
        {multipart,undefined},
        {resp_compress,false},
        {resp_state,waiting},
        {resp_headers,[{<<"content-type">>,
                        [<<"application">>,<<"/">>,<<"json">>,<<>>]}]},
        {resp_body,<<>>},
        {onresponse,fun http_util:log_response/4}]},
  {state,{state,<<"python">>,<<"latest">>}}],
 [{cowboy_rest,error_terminate,5,
               [{file,"/home/aurel/projects/glot-run/_build/default/lib/cowboy/src/cowboy_rest.erl"},
                {line,1009}]},
  {cowboy_rest,process_content_type,3,
               [{file,"/home/aurel/projects/glot-run/_build/default/lib/cowboy/src/cowboy_rest.erl"},
                {line,777}]},
  {cowboy_protocol,execute,4,
                   [{file,"/home/aurel/projects/glot-run/_build/default/lib/cowboy/src/cowboy_protocol.erl"},
                    {line,442}]}]}

Edit: This is when i am trying to run the POST request to run the code. Everything works fine up until this point. I can create a user, i can add the languages, it's when i do the POST request to run code that this error appears

I went and launched a ubuntu 16.04 server to test out the prebuilt version binaries. The same error occurs
This is the request i am sending.

curl --request POST \
     --header 'Authorization: Token secret-token' \
     --header 'Content-type: application/json' \
     --data '{"files": [{"name": "main.py", "content": "print(42)"}]}' \
     --url 'http:localhost:8100/languages/python/latest'

Is there anything wrong with the request maybe?

Edit: when i send this request to https://run.glot.io it works so i think the request is fine in this case.

It's hard to tell. The most common problem is the docker daemon configuration, but the stack trace does not give a clear indication of that. Make sure that the docker daemon is answering on http i.e.

curl http://docker-address/version

I'm running the same pre-built binaries on glot.io

When i send this request:

curl http://localhost:2376/version

This is the response from the request:

  "Platform": {
    "Name": "Docker Engine - Community"
  },
  "Components": [
    {
      "Name": "Engine",
      "Version": "19.03.13",
      "Details": {
        "ApiVersion": "1.40",
        "Arch": "amd64",
        "BuildTime": "2020-09-16T17:01:20.000000000+00:00",
        "Experimental": "false",
        "GitCommit": "4484c46d9d",
        "GoVersion": "go1.13.15",
        "KernelVersion": "5.7.9-050709-generic",
        "MinAPIVersion": "1.12",
        "Os": "linux"
      }
    },
    {
      "Name": "containerd",
      "Version": "1.3.7",
      "Details": {
        "GitCommit": "8fba4e9a7d01810a393d5d25a3621dc101981175"
      }
    },
    {
      "Name": "runc",
      "Version": "1.0.0-rc10",
      "Details": {
        "GitCommit": "dc9208a3303feef5b3839f4323d9beb36df0a9dd"
      }
    },
    {
      "Name": "docker-init",
      "Version": "0.18.0",
      "Details": {
        "GitCommit": "fec3683"
      }
    }
  ],
  "Version": "19.03.13",
  "ApiVersion": "1.40",
  "MinAPIVersion": "1.12",
  "GitCommit": "4484c46d9d",
  "GoVersion": "go1.13.15",
  "Os": "linux",
  "Arch": "amd64",
  "KernelVersion": "5.7.9-050709-generic",
  "BuildTime": "2020-09-16T17:01:20.000000000+00:00"
}

I'll try swithching the docker version to see if maybe that is the culprit.

Looks like the docker version isn't the issue in this case either.

I switched the docker version to 17 like it was in the docker-server-config, but the same error is appearing. I think it is more likely to be a bug in the api itself since i can reach the docker server and switching the docker version did not help.

Based on the stack trace( i don't know erlang so i might be very wrong in this assumption ) it seems to fail in the language_run_resource file in the accept_post method. I don't really know how to go about debugging this either since i have no knowledge of erlang.

The stack trace isn't that good, accept_post is more or less the starting point of the application where it decodes the body, logs the request and starts the container, etc.

glot-run has worked with all the docker versions I've tried over the years, I'm currently running v19.03.x on glot.io.
I think it's a configuration issue, double check that i.e. LOG_PATH is a writable directory by the user that runs the glot-run service, etc.

I can't help you anymore than this. glot-run in it's current state is hard to debug, I will be focusing my time on the new rust version.

Okay, fair enough

May i ask what version of erlang are you running the api?
That's the only thing i haven't tried changing until now. I am currently using Erlang version 23.0

May i ask what version of erlang are you running the api?
That's the only thing i haven't tried changing until now. I am currently using Erlang version 23.0

I'm using Ubuntu 16.04 and install erlang via apt, the version is: Erlang/OTP 18

It seems like the only combination that is working at the moment is Ubuntu 16.04 and Erlang/OTP 18.

I'm having this issue when i reboot servers the api can't start anymore for some reason, but it seems like it's more of a Erlang/Rebar issue than an issue with the api (see this) so I'm closing this issue.