Skip to content

Commit

Permalink
fix apiv2 /containers/$name/json return wrong value in `.Config.StopS…
Browse files Browse the repository at this point in the history
…ignal`

Signed-off-by: zhangguanzhang <[email protected]>
  • Loading branch information
zhangguanzhang committed Oct 6, 2020
1 parent ea02d9c commit adde67c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion pkg/api/handlers/compat/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"net/http"
"strconv"
"strings"
"syscall"

Expand Down Expand Up @@ -385,7 +386,7 @@ func LibpodToContainerJSON(l *libpod.Container, sz bool) (*types.ContainerJSON,
MacAddress: "",
OnBuild: nil,
Labels: l.Labels(),
StopSignal: string(l.StopSignal()),
StopSignal: strconv.Itoa(int(l.StopSignal())),
StopTimeout: &stopTimeout,
Shell: nil,
}
Expand Down
8 changes: 5 additions & 3 deletions test/apiv2/20-containers.at
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,14 @@ t GET containers/$cid/json 200 \
.Config.WorkingDir="/data" # default is /data
t DELETE containers/$cid 204

# test the WORKDIR
t POST containers/create '"Image":"'$ENV_WORKDIR_IMG'","WorkingDir":"/dataDir"' 201 \
# test the WORKDIR and StopSignal
t POST containers/create '"Image":"'$ENV_WORKDIR_IMG'","WorkingDir":"/dataDir","StopSignal":"9"' 201 \
.Id~[0-9a-f]\\{64\\}
cid=$(jq -r '.Id' <<<"$output")
t GET containers/$cid/json 200 \
.Config.WorkingDir="/dataDir"
.Config.WorkingDir="/dataDir" \
.Config.StopSignal="9"

t DELETE containers/$cid 204

# vim: filetype=sh

0 comments on commit adde67c

Please sign in to comment.