The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/2253
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === Closes #2243 Signed-off-by: Tycho Andersen <tycho.ander...@canonical.com>
From dec46251f3c22d59156d4d74d358c1bbeca9e60a Mon Sep 17 00:00:00 2001 From: Tycho Andersen <tycho.ander...@canonical.com> Date: Mon, 1 Aug 2016 12:30:54 -0600 Subject: [PATCH] remember the return code in the non wait-for-websocket case Closes #2243 Signed-off-by: Tycho Andersen <tycho.ander...@canonical.com> --- lxd/container_exec.go | 9 ++++++++- test/suites/basic.sh | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lxd/container_exec.go b/lxd/container_exec.go index 71aee79..57b310b 100644 --- a/lxd/container_exec.go +++ b/lxd/container_exec.go @@ -14,6 +14,8 @@ import ( "github.com/gorilla/websocket" "github.com/lxc/lxd/shared" + + log "gopkg.in/inconshreveable/log15.v2" ) type commandPostContent struct { @@ -329,7 +331,12 @@ func containerExecPost(d *Daemon, r *http.Request) Response { } defer nullDev.Close() - _, cmdErr := c.Exec(post.Command, env, nil, nil, nil) + cmdResult, cmdErr := c.Exec(post.Command, env, nil, nil, nil) + metadata := shared.Jmap{"return": cmdResult} + err = op.UpdateMetadata(metadata) + if err != nil { + shared.Log.Error("error updating metadata for cmd", log.Ctx{"err": err, "cmd": post.Command}) + } return cmdErr } diff --git a/test/suites/basic.sh b/test/suites/basic.sh index b45ef7b..dcbfe21 100644 --- a/test/suites/basic.sh +++ b/test/suites/basic.sh @@ -259,6 +259,10 @@ test_basic_usage() { lxc exec --env BEST_BAND=meshuggah foo env | grep meshuggah lxc exec foo ip link show | grep eth0 + # check that we can get the return code for a non- wait-for-websocket exec + op=$(my_curl -X POST "https://${LXD_ADDR}/1.0/containers/foo/exec" -d '{"command": ["sleep", "1"], "environment": {}, "wait-for-websocket": false, "interactive": false}' | jq -r .operation) + [ "$(my_curl "https://${LXD_ADDR}${op}/wait" | jq -r .metadata.metadata.return)" != "null" ] + # test file transfer echo abc > "${LXD_DIR}/in"
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel