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
Allow specifying download format in vmexport #10400
Conversation
Skipping CI for Draft Pull Request. |
33a9770
to
2913913
Compare
pkg/virtctl/vmexport/vmexport.go
Outdated
@@ -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") |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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>
2913913
to
6037b06
Compare
/test pull-kubevirt-e2e-k8s-1.27-ipv6-sig-network |
pkg/virtctl/vmexport/vmexport.go
Outdated
@@ -70,6 +71,8 @@ const ( | |||
SNAPSHOT_FLAG = "--snapshot" | |||
INSECURE_FLAG = "--insecure" | |||
KEEP_FLAG = "--keep-vme" | |||
RAW_FLAG = "--raw" | |||
DECOMPRESS_FLAG = "--decompress" |
There was a problem hiding this comment.
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:
- always fetch the gzip image
- ad "-o" and/or "--output" arg that accepts "gzip" or "raw" (gzip is default to be consistent with current invocation)
- if raw is specified, unzip the image while downloading
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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>
/retest-required |
/test pull-kubevirt-e2e-k8s-1.26-sig-storage |
@alromeros is this still WIP? |
oops, forgot to change the PR name. |
/test pull-kubevirt-e2e-k8s-1.26-sig-storage |
/lgtm |
[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 |
@alromeros: The following test failed, say
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. |
/retest-required |
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: