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

vmexport: Reject volume exports when no output file is specified #10963

Merged

Conversation

alromeros
Copy link
Contributor

@alromeros alromeros commented Jan 3, 2024

What this PR does / why we need it:

When no output is specified, all vmexport downloads are dumped into stdout. This Pull Request improves the error handling to reject volume downloads when no output file is specified to avoid unexpected binary dumps.

Example before fix:

# virtctl vmexport download vm --pvc=test
�����������������������������������������������������������������������������������_/���y��<u�'��&
��
$q��D5�$����{�H�

...

After fix:

# virtctl vmexport download vm --pvc=test
Warning: Binary output can mess up your terminal. Use '--output -' to output into stdout anyway or consider '--output <FILE>' to save to a file.

Manifest downloads are still able to dump into stdout without specifying output.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes # https://issues.redhat.com/browse/CNV-36271

Special notes for your reviewer:

Release note:

Bugfix: Reject volume exports when no output is specified

@kubevirt-bot kubevirt-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. labels Jan 3, 2024
@alicefr
Copy link
Member

alicefr commented Jan 4, 2024

The option sound reasonable to me
/approve

@kubevirt-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alicefr

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

@kubevirt-bot kubevirt-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 4, 2024
@alromeros
Copy link
Contributor Author

/retest-required

@awels
Copy link
Member

awels commented Jan 4, 2024

/hold
So this is on purpose, this allows you to pipe the output into another command. This is actually a feature not a bug.

@kubevirt-bot kubevirt-bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 4, 2024
@ShellyKa13
Copy link
Contributor

@awels @alromeros how about we make the output a must when doing download (as Alvaro did to return an error) but make stdout a valid output for piping purposes and so also change the error msg to "must set output value" and maybe give in the examples the stout option so people will know its possible.

@alicefr
Copy link
Member

alicefr commented Jan 5, 2024

@awels @alromeros how about we make the output a must when doing download (as Alvaro did to return an error) but make stdout a valid output for piping purposes and so also change the error msg to "must set output value" and maybe give in the examples the stout option so people will know its possible.

I agree with Shelly. We should not mess the terminal if somebody is missing the flag by accident.

@alromeros alromeros force-pushed the reject-vmexport-download-stdout branch from 15d908e to abc4b7f Compare January 5, 2024 13:41
When no output is specified, all vmexport downloads are dumped into stdout.

This commit improves the error handling to reject volume downloads when no output file is specified.

Signed-off-by: Alvaro Romero <alromero@redhat.com>
@alromeros alromeros force-pushed the reject-vmexport-download-stdout branch from abc4b7f to cc1db17 Compare January 5, 2024 13:42
@alromeros
Copy link
Contributor Author

Updated this to match curl's behavior:

# virtctl vmexport download vm --pvc=test
Warning: Binary output can mess up your terminal. Use '--output -' to output into stdout anyway or consider '--output <FILE>' to save to a file.

@alromeros
Copy link
Contributor Author

/retest-required

1 similar comment
@alromeros
Copy link
Contributor Author

/retest-required

@awels
Copy link
Member

awels commented Jan 8, 2024

/lgtm

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Jan 8, 2024
@alromeros
Copy link
Contributor Author

/unhold

@kubevirt-bot kubevirt-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 9, 2024
@@ -347,7 +347,7 @@ func (c *command) initVMExportInfo(vmeInfo *VMExportInfo) error {
vmeInfo.ExportSource = getExportSource()
vmeInfo.OutputFile = outputFile
// User wants the output in a file, create
if outputFile != "" {
if outputFile != "" && outputFile != "-" {
Copy link
Contributor

Choose a reason for hiding this comment

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

you don't allow outputFile to be "" so you dont need to check it right?
what about someone explicitly doing --outputFile=stdout? we dont want that to go to stdout? is it not acceptable?

Copy link
Contributor Author

@alromeros alromeros Jan 9, 2024

Choose a reason for hiding this comment

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

Yeah we allow empty output files for manifest downloads. Also, I think it's good to be consistent and allow using whatever file name (even stdout).

@kubevirt-commenter-bot
Copy link

/retest-required
This bot automatically retries required jobs that failed/flaked on approved PRs.
Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@kubevirt-bot
Copy link
Contributor

kubevirt-bot commented Jan 10, 2024

@alromeros: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-kubevirt-e2e-arm64 cc1db17 link false /test pull-kubevirt-e2e-arm64
pull-kubevirt-e2e-k8s-1.28-sig-compute cc1db17 link unknown /test pull-kubevirt-e2e-k8s-1.28-sig-compute

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. I understand the commands that are listed here.

@kubevirt-bot kubevirt-bot merged commit 9348ea4 into kubevirt:main Jan 10, 2024
34 of 36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants