jobeinabox - runs_get: no such run or run result discarded

jobeinabox - runs_get: no such run or run result discarded

by Lukasz Terlecki -
Number of replies: 4

Hi folks.
I have installed jobe server in a docker container, jobe teorically runs fine:

docker exec -t jobe /usr/bin/python3 /var/www/html/jobe/testsubmit.py
Supported languages:
    c: 9.4.0
    cpp: 9.4.0
    java: 16.0.1
    nodejs: 10.19.0
    octave: 5.2.0
    pascal: 3.0.4
    php: 7.4.3
    python3: 3.8.10

Valid Python3 OK
Python3 with stdin OK
Syntactically invalid Python3 OK
Python3 runtime error OK
Python3 file I/O OK
Testing use of interpreter args with Python3 OK
Testing use of runargs args with Python3 OK
Python3 program with customised timeout OK
Python3 program with support files OK
Valid Python3/pylint program OK
Invalid Python3/pylint program OK
UTF-8 output from Python3 (will fail unless Jobe set up for UTF-8) OK
Test good C hello world OK
Test compile error C hello world OK
Test use of compileargs with C OK
Test runtime error C hello world OK
Test timelimit on C OK
Test outputlimit on C OK
Memory limit exceeded in C (seg faults) OK
Infinite recursion (stack error) on C OK
C program controlled forking OK
A C program with ASCII non-UTF-8-compatible output OK
Valid Octave OK
octave with stdin OK
Syntactically invalid Octave (treated as runtime error) OK
Syntactically valid Nodejs hello world OK
Syntactically invalid Nodejs OK
Correct Php program  OK
Syntactically incorrect Php program  OK
Syntactically incorrect Php program  OK
Correct Java program  OK
Correct Java program without supplied sourcefilename  OK
Syntactically incorrect Java program  OK
Java program with a support class (.java) OK
Java program with Unicode output (will fail unless Jobe set up for UTF-8)  OK
Test good C++ hello world OK
Test compile error C++ hello world OK
Good Hello world Pascal test OK
Fail Hello world Pascal test OK

39 tests, 39 passed, 0 failed, 0 exceptions

Checking parallel submissions
Doing child 0
Doing child 1
Doing child 2
Doing child 3
Doing child 4
Doing child 5
Doing child 6
Doing child 7
Doing child 8
Doing child 9
C program to check parallel submissions OK
C program to check parallel submissions OK
C program to check parallel submissions OK
C program to check parallel submissions OK
C program to check parallel submissions OK
C program to check parallel submissions OK
C program to check parallel submissions OK
C program to check parallel submissions OK
C program to check parallel submissions OK
C program to check parallel submissions OK
All done

Testing a submission with an excessive cputime parameter
OK


but request to restapi returns: 200 runs_get: no such run or run result discarded

curl -v  http://127.0.0.1:3001/jobe/index.php/restapi/runs/
* Expire in 0 ms for 6 (transfer 0x55e43e4c00f0)
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Expire in 200 ms for 4 (transfer 0x55e43e4c00f0)
* Connected to 127.0.0.1 (127.0.0.1) port 3001 (#0)
> GET /jobe/index.php/restapi/runs/ HTTP/1.1
> Host: 127.0.0.1:3001
> User-Agent: curl/7.64.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< Date: Sun, 21 Aug 2022 19:42:17 GMT
< Server: Apache
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Headers: X-API-KEY, Origin, X-Requested-With, Content-Type, Accept, Access-Control-Request-Method
< Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, HEAD, DELETE
< Content-Length: 47
< Content-Type: application/json; charset=utf-8
< 
* Connection #0 to host 127.0.0.1 left intact
"runs_get: no such run or run result discarded"

In effect if I try to run code on moodle quiz I see: the sandbox seems to be disabled.
There is no error in logs. Any ideas?

In reply to Lukasz Terlecki

Re: jobeinabox - runs_get: no such run or run result discarded

by Richard Lobb -

You can't do an HTTP GET from restapi/runs. You POST a run request there and the HTTP response is the result of the run. See the protocol spec here

Try the following

curl http://127.0.0.1:3001/jobe/index.php/restapi/languages

The result should be a JSON-encoded list of the languages supported.

If that works you can be pretty confident that Jobe is working fine. If Moodle can't connect then double-check the CodeRunner admin settings and if it still doesn't work you likely have a networking issue (e.g. a firewall in the way). 

You can also run the above curl command on your Moodle server (adjusting the URL as necessary) to check the network connect.

If you have your heart set on submitting to Jobe with a curl request, here's a Python Hello world:

curl http://127.0.0.1:3001/jobe/index.php/restapi/runs -d "{\"run_spec\":{\"language_id\": \"python3\", \"sourcecode\": \"print('Hello world')\"}}" -H "Content-type: application/json; charset=utf-8"

But using the program simpletest.py (adjusting line 14 to reference your Jobe server) is a lot easier!

In reply to Richard Lobb

Re: jobeinabox - runs_get: no such run or run result discarded

by Lukasz Terlecki -
Yes, you are right about the GET request, my fail ;(
The jobe is answer properly via localhost and via exposed and proxied 80 port with domain:
curl -v http://jobe.mydomain.pl/jobe/index.php/restapi/runs -d "{\"run_spec\":{\"language_id\": \"python3\", \"sourcecode\": \"print('Hello world')\"}}" -H "Content-type: application/json; charset=utf-8"
* Expire in 0 ms for 6 (transfer 0x5574fa8510f0)
*   Trying xxx.xxx.xxx.xxx...
* TCP_NODELAY set
* Expire in 200 ms for 4 (transfer 0x5574fa8510f0)
* Connected to jobe.mydomain.pl (xxx.xxx.xxx.xxx) port 80 (#0)
> POST /jobe/index.php/restapi/runs HTTP/1.1
> Host: jobe.mydomain.pl
> User-Agent: curl/7.64.0
> Accept: */*
> Content-type: application/json; charset=utf-8
> Content-Length: 77
> 
* upload completely sent off: 77 out of 77 bytes
 < HTTP/1.1 200 OK
 < Date: Mon, 22 Aug 2022 11:16:01 GMT
 < Server: Apache
 < Access-Control-Allow-Origin: *
 < Access-Control-Allow-Headers: X-API-KEY, Origin, X-Requested-With, Content-Type, Accept, Access-Control-Request-Method
 < Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, HEAD, DELETE
 < Content-Length: 78
 < Content-Type: application/json; charset=utf-8
 < 
* Connection #0 to host jobe.mydomain.pl left intact
{"run_id":null,"outcome":15,"cmpinfo":"","stdout":"Hello world\n","stderr":""}

But from moodle application which is on the same host any request was sended to localhost or to the exposed domain with jobe. Im setting it in "qtype_coderunner | jobe_host" field in Administration Panel ()
Requests from moodle host work's.
There is no firewall on port 80.
In reply to Lukasz Terlecki

Re: jobeinabox - runs_get: no such run or run result discarded

by Richard Lobb -
What is your jobe_host field set to in the CodeRunner Admin panel? If the above curl command works from a terminal on your Moodle server, it should be just

jobe.mydomain.pl
No http:// and no port number if using port 80 (as in the curl command).

However, you say the container is on the same host as the Moodle server, which makes me wonder how port 80 is being managed - it can't be being used by both Jobe and Moodle. It would seem easier to start the container mapping port 80 in the container to a different local port, say 4000 as described here. The CodeRunner admin setting would then be just

localhost:4000
If neither of those works, please describe what command you're using to start the container, what your CodeRunner admin setting for Jobe Host is, what test you're doing with Moodle + CodeRunner and what error message you're getting (with screen dump).
In reply to Richard Lobb

Re: jobeinabox - runs_get: no such run or run result discarded

by Lukasz Terlecki -
Ok, so in turn:
Yes, I'm trying from the same host where is running jobe docker. Jobe docker is running with port mapping: 127.0.0.1:3001->80/tcp
On host is configured apache with mod_proxy:

ProxyPass http://127.0.0.1:3001/
ProxyPassReverse http://127.0.0.1:3001/

And now I have a http and https access to jobe.
Here was supposed to be settings of jobe_host, but during writing I found a bug between the chair and the keyboard...
It looks like the person who made and import the quiz doesn't chose the question type - is set to undefined.
Thanks for spended time.