Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apiv2 /containers/json limit differ from docker-api #7739

Merged

Conversation

zhangguanzhang
Copy link
Collaborator

Fixes: #7722
Signed-off-by: zhangguanzhang [email protected]

@zhangguanzhang zhangguanzhang force-pushed the apiv2-containers-limit branch 6 times, most recently from 7ece211 to 1e9ef7b Compare September 23, 2020 10:22
@zhangguanzhang zhangguanzhang changed the title apiv2 container limit differ from docker-api apiv2 container/json limit differ from docker-api Sep 23, 2020
@zhangguanzhang zhangguanzhang changed the title apiv2 container/json limit differ from docker-api apiv2 /container/json limit differ from docker-api Sep 23, 2020
Copy link
Member

@edsantiago edsantiago left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still need to review and understand the main aspect of this, but ITM you need to fix the test.

t GET containers/json?limit=0 200 \
.[0].Id~[0-9a-f]\\{64\\}

t POST containers/${cid}/stop 204
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing ''

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

@edsantiago
Copy link
Member

Friendly amendment? Defer deletion of the previous container; this way we test a multi-container ps:

diff --git a/test/apiv2/20-containers.at b/test/apiv2/20-containers.at
index d635702e4..60ebe2820 100644
--- a/test/apiv2/20-containers.at
+++ b/test/apiv2/20-containers.at
@@ -176,26 +176,27 @@ t GET containers/$cid/json 200 \
   .Config.Cmd='[]' \
   .Path="echo" \
   .Args[0]="param1"
-t DELETE containers/$cid 204

 # create a running container for after
 t POST containers/create '"Image":"'$IMAGE'","Entrypoint":["top"]' 201 \
   .Id~[0-9a-f]\\{64\\}
-cid=$(jq -r '.Id' <<<"$output")
-t GET containers/$cid/json 200 \
+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}/start '' 204
+t POST  containers/${cid_top}/start '' 204
 # make sure the container is running
-t GET containers/$cid/json 200 \
+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}/stop 204
+t POST containers/${cid_top}/stop '' 204
+t DELETE containers/$cid_top 204
 t DELETE containers/$cid 204

 # vim: filetype=sh

@zhangguanzhang zhangguanzhang force-pushed the apiv2-containers-limit branch 2 times, most recently from 031d4a1 to 7075362 Compare September 23, 2020 13:37
@zhangguanzhang zhangguanzhang changed the title apiv2 /container/json limit differ from docker-api apiv2 /containers/json limit differ from docker-api Sep 23, 2020
@zhangguanzhang
Copy link
Collaborator Author

done

@TomSweeneyRedHat
Copy link
Member

LGTM

// 0 means unlimited, need same with docker
if query.Limit == 0 {
query.Limit = -1
}
if _, found := r.URL.Query()["limit"]; found && query.Limit != -1 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking this over with more time, would it make more sense to change this line instead, to && query.Limit > 0 ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@rhatdan
Copy link
Member

rhatdan commented Sep 24, 2020

/approve
/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 24, 2020
@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rhatdan, zhangguanzhang

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 24, 2020
@openshift-merge-robot openshift-merge-robot merged commit c3d1cef into containers:master Sep 24, 2020
@zhangguanzhang zhangguanzhang deleted the apiv2-containers-limit branch November 18, 2020 09:14
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 24, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

APIv2: container list limit handling seems to differ from docker-API
6 participants