summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-09-24 09:43:19 +0000
committerGitHub <noreply@github.com>2020-09-24 09:43:19 +0000
commitc3d1cefa02cf631cbca87a47101b0862cdc6832b (patch)
treeb2baa80aa85c649a57b31980ca66fc48fcdac71f
parentc256944d00edbedcfbf02406600987dc8acea644 (diff)
parent873989f7a413ee8acc5e137577dfaa4d38f94fbd (diff)
downloadpodman-c3d1cefa02cf631cbca87a47101b0862cdc6832b.tar.gz
podman-c3d1cefa02cf631cbca87a47101b0862cdc6832b.tar.bz2
podman-c3d1cefa02cf631cbca87a47101b0862cdc6832b.zip
Merge pull request #7739 from zhangguanzhang/apiv2-containers-limit
apiv2 /containers/json limit differ from docker-api
-rw-r--r--pkg/api/handlers/compat/containers.go2
-rw-r--r--test/apiv2/20-containers.at25
2 files changed, 26 insertions, 1 deletions
diff --git a/pkg/api/handlers/compat/containers.go b/pkg/api/handlers/compat/containers.go
index 1c2356b92..63c44eaef 100644
--- a/pkg/api/handlers/compat/containers.go
+++ b/pkg/api/handlers/compat/containers.go
@@ -85,7 +85,7 @@ func ListContainers(w http.ResponseWriter, r *http.Request) {
utils.InternalServerError(w, err)
return
}
- if _, found := r.URL.Query()["limit"]; found && query.Limit != -1 {
+ if _, found := r.URL.Query()["limit"]; found && query.Limit > 0 {
last := query.Limit
if len(containers) > last {
containers = containers[len(containers)-last:]
diff --git a/test/apiv2/20-containers.at b/test/apiv2/20-containers.at
index 9ea3cb7ed..187073fb9 100644
--- a/test/apiv2/20-containers.at
+++ b/test/apiv2/20-containers.at
@@ -176,6 +176,31 @@ t GET containers/$cid/json 200 \
.Config.Cmd='[]' \
.Path="echo" \
.Args[0]="param1"
+
+# create a running container for after
+t POST containers/create '"Image":"'$IMAGE'","Entrypoint":["top"]' 201 \
+ .Id~[0-9a-f]\\{64\\}
+cid_top=$(jq -r '.Id' <<<"$output")
+t GET containers/${cid_top}/json 200 \
+ .Config.Entrypoint[0]="top" \
+ .Config.Cmd='[]' \
+ .Path="top"
+t POST containers/${cid_top}/start '' 204
+# make sure the container is running
+t GET containers/${cid_top}/json 200 \
+ .State.Status="running"
+
+# 0 means unlimited, need same with docker
+t GET containers/json?limit=0 200 \
+ .[0].Id~[0-9a-f]\\{64\\}
+
+t GET 'containers/json?limit=0&all=1' 200 \
+ .[0].Id~[0-9a-f]\\{64\\} \
+ .[1].Id~[0-9a-f]\\{64\\}
+
+t POST containers/${cid_top}/stop "" 204
+
t DELETE containers/$cid 204
+t DELETE containers/$cid_top 204
# vim: filetype=sh