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

Added the "--out" parameter and fixed an issue with "--noout" which prevented stdout from being written to. #18657

Merged
merged 1 commit into from
Jun 5, 2023

Conversation

arizvisa
Copy link
Contributor

@arizvisa arizvisa commented May 22, 2023

This adds an additional parameter, "--out", which can be used to capture the output of any part of podman. This is similar to the original "--noout", but instead of redirecting stdout to "/dev/null" it allows the user to choose the file that is being written to. Thus using the parameter as in podman --out /dev/null ... corresponds to the same logic. The original "--noout" parameter was left alone as I expect someone is already depending on this functionality. The original "--noout" parameter had a bug in that "/dev/null" was not being opened as writable. This results in an EBADF error being returned everytime the fd being written to gets used.

The PR adds the additional parameter using the same logic as "--noout", fixes the prior-mentioned issue with "--noout", and adds testcases for each of them. To perform the test for the "--noout" error, the only symptom I could identify (without running strace) was that golang would complain to stderr if it couldn't write to stdout when running podman without any parameters. Hence the test is written against this symptom.

This fixes issue #18120.

Does this PR introduce a user-facing change?

All Podman commands now support a new option, `--out`, that allows redirection or suppression of STDOUT.

… by various commands

Commands like podman-create(1), podman-run(1), podman-inspect(1),
podman-ps(1) will emit formatted output upon success. This allows
the output from commands to be emitted directly to a file and
can supersede the --noout parameter by using /dev/null. An issue
with --noout was also remedied.

This closes issue containers#18120.

Signed-off-by: Ali Rizvi-Santiago <[email protected]>
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.

Thank you for your PR! A few quick suggestions and requests from a very quick pass. Also, please collapse your commits.

test/system/200-pod.bats Outdated Show resolved Hide resolved
test/system/200-pod.bats Outdated Show resolved Hide resolved
@arizvisa arizvisa force-pushed the GH-18120 branch 5 times, most recently from 80768b6 to c036081 Compare May 23, 2023 01:41
Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

I am not a huge fan of these kind of options but I won't block over it. Is there a reason to do stdout only but not for stderr, seems inconsistent?

Please squash the commits into one and where say add unit test it should really say system test as these are not unit tests.

cmd/podman/root.go Outdated Show resolved Hide resolved
cmd/podman/root.go Outdated Show resolved Hide resolved
test/system/500-networking.bats Outdated Show resolved Hide resolved
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.

Thanks again. And please remember to squash your commits.

test/system/200-pod.bats Outdated Show resolved Hide resolved
docs/source/markdown/podman.1.md Outdated Show resolved Hide resolved
@arizvisa
Copy link
Contributor Author

arizvisa commented May 23, 2023

Awesome. All the tests passed, re-requesting review. (Do at your leisure).

@arizvisa arizvisa requested a review from edsantiago May 23, 2023 21:12
@edsantiago
Copy link
Member

@arizvisa could you please squash your commits? And please remove unnecessary tests. There is no need for so many tests. (I can't believe I'm saying that!)

@arizvisa arizvisa force-pushed the GH-18120 branch 3 times, most recently from 65ce994 to 55a7d3f Compare May 30, 2023 23:00
arizvisa added a commit to arizvisa/containers-podman that referenced this pull request May 30, 2023
… requires rootless.

Signed-off-by: Ali Rizvi-Santiago <[email protected]>
@arizvisa
Copy link
Contributor Author

squashed and included as many suggestions as you gave input on.

@arizvisa arizvisa requested a review from Luap99 May 31, 2023 02:02
Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

I wonder if we should just hide --noout now that you can use --out=/dev/null and just keep it for backwards compat.
i.e. add lFlags.MatkHidden("noout") and remove the docs for this option.

arizvisa added a commit to arizvisa/containers-podman that referenced this pull request May 31, 2023
@arizvisa arizvisa force-pushed the GH-18120 branch 3 times, most recently from 7587ec9 to bb2deef Compare May 31, 2023 14:07
@arizvisa
Copy link
Contributor Author

I wonder if we should just hide --noout now that you can use --out=/dev/null and just keep it for backwards compat. i.e. add lFlags.MatkHidden("noout") and remove the docs for this option.

I think it makes sense. Added your suggestions until someone suggests otherwise.

Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jun 1, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: arizvisa, Luap99

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 openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 1, 2023
@rhatdan
Copy link
Member

rhatdan commented Jun 5, 2023

/lgtm
Thanks @arizvisa

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jun 5, 2023
@openshift-merge-robot openshift-merge-robot merged commit eec15a1 into containers:main Jun 5, 2023
@vans163
Copy link

vans163 commented Jul 24, 2023

I am not a huge fan of these kind of options but I won't block over it. Is there a reason to do stdout only but not for stderr, seems inconsistent?

Please squash the commits into one and where say add unit test it should really say system test as these are not unit tests.

Where does STDERR go? Anyway to redirect it as well?

@arizvisa
Copy link
Contributor Author

Where does STDERR go? Anyway to redirect it as well?

@vans163, Which podman command are you trying to capture STDERR from specifically? Just all of podman's STDERR in general or container output?

@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 Oct 25, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 25, 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. release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants