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

fix API: Create container with an invalid configuration #6835

Merged
merged 1 commit into from
Jul 9, 2020

Conversation

zhangguanzhang
Copy link
Collaborator

Signed-off-by: zhangguanzhang [email protected]
fix #6799
if use API to create containers, this will be null

        "Path": "",
        "Args": null,

@openshift-ci-robot openshift-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jul 1, 2020
@openshift-ci-robot
Copy link
Collaborator

Hi @zhangguanzhang. Thanks for your PR.

I'm waiting for a containers member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@rhatdan
Copy link
Member

rhatdan commented Jul 1, 2020

Tests are not happy.
/ok-to-test

@openshift-ci-robot openshift-ci-robot added ok-to-test and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 1, 2020
@zhangguanzhang
Copy link
Collaborator Author

@TomSweeneyRedHat PTAL

@vrothberg
Copy link
Member

@zhangguanzhang could you rebase and repush? I am under the impression that the CI had a hiccup.

Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

I'd love to see tests for this in test/apiv2

@zhangguanzhang zhangguanzhang force-pushed the master branch 3 times, most recently from 6a5d908 to b69e496 Compare July 7, 2020 13:27
Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

Please squash the two commits into one. The merge commit isn't necessary. I usually do git pull --rebase upstream/master for rebasing.

Would you also add a test or two to test/apiv2? As it's a fix, we missed to test it in the CI and only tests will make sure we that we don't regress on it in the future.

Again thanks a lot for fixing!

@zhangguanzhang
Copy link
Collaborator Author

I'll try to add unit tests, and I'll submit them when I'm done

@zhangguanzhang zhangguanzhang force-pushed the master branch 2 times, most recently from 8a1b7ee to 4c8e640 Compare July 7, 2020 16:07
@zhangguanzhang zhangguanzhang requested a review from vrothberg July 7, 2020 17:12
# Ensure that API does not occur: Create Container creates an invalid and the container fails to start
# https://github.com/containers/libpod/issues/6799
CNAME=testArgs
t POST libpod/containers/create?name=${CNAME} '{"Image":"'"$IMAGE"'"}'}' 200
Copy link
Member

Choose a reason for hiding this comment

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

The tests take care of converting to JSON. The correct syntax here is:

t POST ... Image=$IMAGE

Also, the expected return status is 201, not 200

Also, please don't just check return code: add a check for reasonable status. Something like

.Id~[0-9a-f]\\{64\\}

Also, the /start isn't working, I'll let you figure that out.

See test/apiv2/README.md for instructions on how to run tests in your local environment.

@zhangguanzhang zhangguanzhang force-pushed the master branch 4 times, most recently from 52453e5 to 203f560 Compare July 8, 2020 02:35
@zhangguanzhang
Copy link
Collaborator Author

zhangguanzhang commented Jul 8, 2020

@edsantiago all has done:

[root@sz-test apiv2]# cat 20-zgz.at
podman pull $IMAGE &>/dev/null

# Unimplemented
#t POST libpod/containers/create '' 201 'sdf'


# Ensure that API does not occur: Create Container creates an invalid and the container fails to start
# https://github.com/containers/libpod/issues/6799
CNAME=testArgs
t POST libpod/containers/create?name=${CNAME} Image=${IMAGE} 201 \
  .Id~[0-9a-f]\\{64\\}
t GET libpod/containers/json?limit=1 200 \
  length=1 \
  .[0].Id~[0-9a-f]\\{64\\}
cid=$(jq -r '.[0].Id' <<<"$output")

t POST libpod/containers/${cid}/start '' 204
t DELETE libpod/containers/$cid 204

run the test in my local environment:

[root@sz-test apiv2]# ./test-apiv2 zgz
ok 1 [20-zgz] POST libpod/containers/create?name=testArgs [Image=quay.io/libpod/alpine_labels:latest] : status=201
ok 2 [20-zgz] POST libpod/containers/create?name=testArgs [Image=quay.io/libpod/alpine_labels:latest] : .Id ('26d9beb2f48c187183a721fda9fa2af33b3a3f37b6e2b0646a3817b4da1dd83b') ~ [0-9a-f]\{64\}
ok 3 [20-zgz] GET libpod/containers/json?limit=1 : status=200
ok 4 [20-zgz] GET libpod/containers/json?limit=1 : length=1
ok 5 [20-zgz] GET libpod/containers/json?limit=1 : .[0].Id ('26d9beb2f48c187183a721fda9fa2af33b3a3f37b6e2b0646a3817b4da1dd83b') ~ [0-9a-f]\{64\}
ok 6 [20-zgz] POST libpod/containers/26d9beb2f48c187183a721fda9fa2af33b3a3f37b6e2b0646a3817b4da1dd83b/start [] : status=204
ok 7 [20-zgz] DELETE libpod/containers/26d9beb2f48c187183a721fda9fa2af33b3a3f37b6e2b0646a3817b4da1dd83b : status=204
1..7

@zhangguanzhang
Copy link
Collaborator Author

@vrothberg ci error,but has no reason

@vrothberg
Copy link
Member

Sorry, we had some rough time with our CI, mainly with the infrastructure. Could you rebase and repush?

@zhangguanzhang
Copy link
Collaborator Author

I will try later

@zhangguanzhang
Copy link
Collaborator Author

@vrothberg It still error

@vrothberg
Copy link
Member

We're seeing it too. The infrastructure is sick but we're working on it. Thanks for your patience!

@zhangguanzhang
Copy link
Collaborator Author

Ok, please tell me when it's ready

@zhangguanzhang zhangguanzhang force-pushed the master branch 2 times, most recently from 7b1a859 to d59dfde Compare July 9, 2020 01:32
@zhangguanzhang
Copy link
Collaborator Author

@rhatdan @vrothberg PTAL

Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

LGTM, thanks a lot!

I want @edsantiago's ack on the test before merging.

@zhangguanzhang zhangguanzhang requested a review from edsantiago July 9, 2020 15:08
@skorhone
Copy link

skorhone commented Jul 9, 2020

@zhangguanzhang If you have time, can you take a look why publish all ports and port randomization aren't working properly for v2 api.

If you create a container using api with just exposed port and publish all port flag set, ports won't be published.

@zhangguanzhang
Copy link
Collaborator Author

@skorhone I will take a look when I have time

@edsantiago
Copy link
Member

tests LGTM and address my earlier concerns. Thanks!

@rhatdan
Copy link
Member

rhatdan commented Jul 9, 2020

/approve
/lgtm
Thanks @zhangguanzhang

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 9, 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 Jul 9, 2020
@openshift-merge-robot openshift-merge-robot merged commit 059bd37 into containers:master Jul 9, 2020
edsantiago added a commit to edsantiago/libpod that referenced this pull request Jul 14, 2020
A newly-added test in containers#6835 was flaking in CI with:

   not ok 143 [20-containers] DELETE libpod/containers/SHA
   500 cannot remove container <sha> as it is running - running or paused containers cannot be removed without force: container state improper

Root cause: DELETE being run immediately after container start.
Although the container is short-lived, it does take time to
run and exit.

Solution: wait for container to exit (should be quick) before
deleting. This gives us a new test for the /wait endpoint.

Also: tweaked some comments for readability, removed unnecessary
container ps, added actual container status checks, and added
actual message checks to another test that was merely checking
exit status.

Signed-off-by: Ed Santiago <[email protected]>
@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. ok-to-test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API: Create container creates an invalid container configuration
7 participants