alexellis/jaas

No logs displayed when launched command is in error

sbrouet opened this issue · 4 comments

Hello,

Current Behavior

In current version, no logs are displayed when the launched command exits with an error.

Expected Behavior

I would expect the command output to be displayed in all cases

Steps to Reproduce (for bugs)

From inside the JAAS container:
/root/jaas run -t=120s --remove=true --show-logs=true --verbose=true --image ubuntu:latest --command "dummy"

output :
"
... truncated ...
Exit code: 0
State: rejected

Printing service logs

Removing service...
"

I would expect something like
... truncated ...
Printing service logs
/bin/sh: dummy: not found
"

Possible solution

Maybe this is due to the comand outputing data to stderr instead of standard output ?

Your Environment

  • JAAS version
    ~ # /root/jaas version


    | | __ _ __ / |
    _ | |/ |/ _ _

    | |
    | | (
    | | (
    | |) |
    _
    / _
    ,|_,|___/

Commit: 53ea90c
Version: dev

  • docker --version
    Docker version 18.06.1-ce, build e68fc7a

Thanks for your help / advice

Hi,

I see it says exit code 0 in your example which means the code exited normally.

What does Docker Swarm say about the service if you use docker service ps / logs / inspect?

Alex

Hello Alex,

Thanks for looking at that issue.

You are right about the fact that exit code is 0.

But there are still two issues

1. In some cases I get an exit code 0 & state rejected

This is the case of my previous example

/root/jaas run -t=120s --remove=true --show-logs=true --verbose=true --image ubuntu:latest --command "dummy"

output :
"
... truncated ...
Exit code: 0
State: rejected

I imagine that in this case it is normal there is no logs since service was refused by Swarm ?

2. In other cases I get exit code 127 & state failed

(command to be run does not exist in the run container, this is on purpose to produce an error and check behaviour)
-> In this case the error log is not displayed

Command :
/root/jaas run --verbose --image ubuntu:latest --command "dummy"
ID: mni8ee8cncgqq5mb9v2tkb1nu Update at: 2018-11-09 13:38:40.042015235 +0000 UTC
..

output :
"
... truncated ...
Exit code: 127
State: failed

Printing service logs

Removing service...
"
-> still not getting logs

I could not figure out why sometimes I am getting "exit code = 0 + state rejected" , and other times it is "exit code 127 + state failed", for the same command...
Second case seems to be the correct behaviour (though still no logs)

Could you advise on why same command could produce different exit code / state ?

3. About getting the service logs

As non-existing command immediately fails, I have to time for manually executing the "docker service logs" command

I have tried printing some text followed by a waiting command, but I have issues with the syntax of the "--command" parameter.

I have tried following but all fail with exit code 127 :

Test 1 :
/root/jaas run --verbose --image ubuntu:latest --command 'read -p "Waiting X secs before closing..." -t 60'
-> Exit code: 127
State: failed

Test 2 :
/root/jaas run --verbose --image ubuntu:latest --command "read -p 'Waiting X secs before closing...' -t 60"
-> Exit code: 127
State: failed

Could you advise on how to run such "complex" commands? Maybe updating the documentation with some commands examples would be nice

Sébastien

I'm going to close this issue, but feel free to send a PR.

Derek close