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

Allow specifying download format in vmexport #10400

Merged
merged 3 commits into from Sep 21, 2023

Conversation

alromeros
Copy link
Contributor

@alromeros alromeros commented Sep 7, 2023

What this PR does / why we need it:

This PR aims to add a new --raw flag in virtctl vmexport, so users can request downloading the raw image instead of the compressed one. It also adds a --decompress flag to download and decompress gzipped files.
Usage example:

  # Download and extract a volume from an already existing VirtualMachineExport
  {{ProgramName}} vmexport download vm1-export --volume=volume1 --output=disk.img --format=raw

Special notes for your reviewer:

Planning to add a flag to decompress the image if needed too.

Release note:

Add new vmexport flags to download raw images, either directly (--raw) or by decompressing (--decompress) them

@kubevirt-bot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@kubevirt-bot kubevirt-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. labels Sep 7, 2023
@alromeros alromeros marked this pull request as ready for review September 7, 2023 16:51
@@ -261,6 +264,7 @@ func NewVirtualMachineExportCommand(clientConfig clientcmd.ClientConfig) *cobra.
cmd.Flags().StringVar(&localPort, "local-port", "0", "Defines the specific port to be used in port-forward.")
cmd.Flags().BoolVar(&includeSecret, "include-secret", false, "When used with manifest and set to true include a secret that contains proper headers for CDI to import using the manifest")
cmd.Flags().BoolVar(&exportManifest, "manifest", false, "Instead of downloading a volume, retrieve the VM manifest")
cmd.Flags().BoolVar(&rawImg, "raw", false, "Used to download the raw image. By default, we always attempt to download the compressed one")
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be better to always download the compressed file but have virtctl unzip while downloading/writing to the target

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just added a --decompress flag so we allow both downloading raw and decompressing the gzipped file. wdyt?

This commit adds a new "--raw" flag in virtctl vmexport, so users can request downloading the raw image instead of the compressed one.

Signed-off-by: Alvaro Romero <alromero@redhat.com>
This commit adds a new virtctl vmexport flag so gzipped images can be downloaded and decompressed in the same step.

Signed-off-by: Alvaro Romero <alromero@redhat.com>
@alromeros
Copy link
Contributor Author

/test pull-kubevirt-e2e-k8s-1.27-ipv6-sig-network
/test pull-kubevirt-e2e-k8s-1.27-sig-compute

@@ -70,6 +71,8 @@ const (
SNAPSHOT_FLAG = "--snapshot"
INSECURE_FLAG = "--insecure"
KEEP_FLAG = "--keep-vme"
RAW_FLAG = "--raw"
DECOMPRESS_FLAG = "--decompress"
Copy link
Member

Choose a reason for hiding this comment

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

I'm a little confused here. Why two options? Don't they ultimately bean the same thing?

What do you think of this, forget about these to flags for a sec. What if we:

  1. always fetch the gzip image
  2. ad "-o" and/or "--output" arg that accepts "gzip" or "raw" (gzip is default to be consistent with current invocation)
  3. if raw is specified, unzip the image while downloading

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So I initially wanted to allow both downloading the raw file (--raw) and downloading and decompressing the gzipped one (--decompress). I know they produce the same output but thought it was nice to allow both ways (some users might care about downloading bigger files, others won't). I also prefer boolean flags since they are more immediate and less confusing. But if you prefer to have a single flag to specify the output I can change it, just wanted to share the rationale behind this design.

Copy link
Member

Choose a reason for hiding this comment

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

I think this is a case of too many knobs leading to user confusion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay so I added a --format flag to specify either raw or gzip. --output is already a flag so couldn't use that one.

bar.Start()

if decompress {
// Create a new gzip reader
gzipReader, err := gzip.NewReader(barRd)

Choose a reason for hiding this comment

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

Optional nice to have: Is this code able to create a sparse file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess we can decompress the file and then rewrite it to be sparse but that sounds out of scope for the PR imo. gzip can't directly decompress it to be sparse, maybe there's some other package that does it. I can take a better look.

Signed-off-by: Alvaro Romero <alromero@redhat.com>
@alromeros
Copy link
Contributor Author

/retest-required

@alromeros
Copy link
Contributor Author

/test pull-kubevirt-e2e-k8s-1.26-sig-storage

@mhenriks
Copy link
Member

@alromeros is this still WIP?

@alromeros alromeros changed the title [WIP] Allow specifying download format in vmexport Allow specifying download format in vmexport Sep 19, 2023
@kubevirt-bot kubevirt-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 19, 2023
@alromeros
Copy link
Contributor Author

@alromeros is this still WIP?

oops, forgot to change the PR name.

@alromeros
Copy link
Contributor Author

/test pull-kubevirt-e2e-k8s-1.26-sig-storage

@mhenriks
Copy link
Member

/lgtm
/approve

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Sep 20, 2023
@kubevirt-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mhenriks

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 Sep 20, 2023
@kubevirt-bot
Copy link
Contributor

@alromeros: The following test 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-k8s-1.28-sig-storage 7dfa5ba link unknown /test pull-kubevirt-e2e-k8s-1.28-sig-storage

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-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 kubevirt-bot merged commit eb743d9 into kubevirt:main Sep 21, 2023
35 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/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants