Skip to content

Add --preservefds to podman run#6625

Merged
openshift-merge-robot merged 1 commit intocontainers:masterfrom
QiWang19:fd
Jun 23, 2020
Merged

Add --preservefds to podman run#6625
openshift-merge-robot merged 1 commit intocontainers:masterfrom
QiWang19:fd

Conversation

@QiWang19
Copy link
Copy Markdown
Member

Add --preservefds to podman run. close #6458

Signed-off-by: Qi Wang [email protected]

@rhatdan
Copy link
Copy Markdown
Member

rhatdan commented Jun 16, 2020

LGTM
/approve

@openshift-ci-robot
Copy link
Copy Markdown
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

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

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

The pull request process is described here

Details 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 Jun 16, 2020
@edsantiago
Copy link
Copy Markdown
Member

Please add a system test, possibly in test/system/030-run.bats, using something like what I messaged you earlier today. The e2e test here is not very useful: all it does is confirm that the option does not cause a syntax error. It does not test any actual functionality.

Comment thread cmd/podman/containers/run.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Recommend rewording to "Pass a number of additional file descriptors into the container"

Comment thread libpod/container.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you add a comment that this is not in the JSON because it is not supported for remote connections?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oh, wait, nevermind - this needs to actually have a JSON tag here, not "-" - that should only be in Specgen. This is for the DB, and we do want to save this to the container in the DB.

Comment thread libpod/options.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggest "WithPreserveFDs forwards from the process running Libpod into the container the given number of extra FDs (starting after the standard streams) to the created container"

Comment thread pkg/specgen/specgen.go Outdated
Comment thread docs/source/markdown/podman-run.1.md Outdated
@QiWang19 QiWang19 force-pushed the fd branch 3 times, most recently from dcfb003 to 738c4d6 Compare June 17, 2020 19:08
@QiWang19
Copy link
Copy Markdown
Member Author

Please add a system test, possibly in test/system/030-run.bats, using something like what I messaged you earlier today. The e2e test here is not very useful: all it does is confirm that the option does not cause a syntax error. It does not test any actual functionality.

https://github.com/containers/libpod/pull/6625/files#diff-f1c2f651579cf49df98160fa0e2d50a7 test failed. @edsantiago Can you help me diagnose if it's because the test not correct? Otherwise, my implementation may not as expected.

@edsantiago
Copy link
Copy Markdown
Member

@QiWang19 this is what the test should look like:

@test "podman run --preserve-fds" {
    skip_if_remote

    content=$(random_string 20)
    echo "$content" > $PODMAN_TMPDIR/tempfile

    run_podman run --rm -i --preserve-fds=2 $IMAGE sh -c "cat <&4" 4<$PODMAN_TMPDIR/tempfile
    is "$output" "$content" "container read input from fd 4"
}

Please use that. It still fails, but it does so for a real-problem reason which is being tracked in #6653

 2020/06/17 15:51:44 bolt.Close(): funlock error: bad file descriptor
time="2020-06-17T15:51:44-06:00" level=error msg="failed to close libpod db: \"db file close: close /var/lib/containers/storage/libpod/bolt_state.db: bad file descriptor\""
Error: error saving container 26cd8352b73d3c07b46343c63f3b3b5c00e37f28ed685ace08788745025a0704 state: write /var/lib/containers/storage/libpod/bolt_state.db: bad file descriptor

Please coordinate efforts to resolve that issue.

Explanation of what I changed:

  • use FD 4, not 3: I forgot that BATS uses fd 3 for internal purposes.
  • Remove the NONLOCAL_IMAGE stuff. You copy-pasted that from another test. It is not necessary or desired here (it introduces a point of failure because it relies on remote registry)
  • use random content, not hardcoded strings which could easily appear via other ways
  • use a file in $PODMAN_TMPDIR - otherwise "testfile" will pollute your current working directory
  • use --rm in the run command, to avoid having to clean up

@QiWang19
Copy link
Copy Markdown
Member Author

@edsantiago Thanks!

@QiWang19 QiWang19 force-pushed the fd branch 2 times, most recently from 2bf6ac5 to df221d5 Compare June 18, 2020 17:38
@edsantiago
Copy link
Copy Markdown
Member

@QiWang19 it looks like #6653 might not get attention soon. Since I believe your PR is correct, and the real problem is elsewhere, I'd be OK with you adding skip "enable this once #6653 is fixed" to the BATS test and trying to get your PR committed.

Add --preservefds to podman run. close containers#6458

Signed-off-by: Qi Wang <[email protected]>
@mheon
Copy link
Copy Markdown
Member

mheon commented Jun 19, 2020

Hold this until Monday, 2.0 is feature-frozen

@rhatdan
Copy link
Copy Markdown
Member

rhatdan commented Jun 22, 2020

@mheon Are you ok to merge this now?

Comment thread libpod/container.go
@mheon
Copy link
Copy Markdown
Member

mheon commented Jun 22, 2020

LGTM, but would like final signoff from @giuseppe

@QiWang19
Copy link
Copy Markdown
Member Author

Thanks.
@giuseppe PTAL.

@giuseppe
Copy link
Copy Markdown
Member

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 23, 2020
@openshift-merge-robot openshift-merge-robot merged commit 9e37fd4 into containers:master Jun 23, 2020
@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.

Add support for --preserve-fds to podman run

7 participants