-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Isteb4k <[email protected]>
- Loading branch information
Showing
1 changed file
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
diff --git a/pkg/uploadserver/uploadserver.go b/pkg/uploadserver/uploadserver.go | ||
index aa9e5ab68..7fe3f079d 100644 | ||
--- a/pkg/uploadserver/uploadserver.go | ||
+++ b/pkg/uploadserver/uploadserver.go | ||
@@ -29,6 +29,7 @@ import ( | ||
"mime/multipart" | ||
"net" | ||
"net/http" | ||
+ "net/url" | ||
"os" | ||
"strings" | ||
"sync" | ||
@@ -40,7 +41,9 @@ import ( | ||
"k8s.io/klog/v2" | ||
|
||
cdiv1 "kubevirt.io/containerized-data-importer-api/pkg/apis/core/v1beta1" | ||
+ | ||
"kubevirt.io/containerized-data-importer/pkg/common" | ||
+ "kubevirt.io/containerized-data-importer/pkg/image" | ||
"kubevirt.io/containerized-data-importer/pkg/importer" | ||
"kubevirt.io/containerized-data-importer/pkg/util" | ||
cryptowatch "kubevirt.io/containerized-data-importer/pkg/util/tls-crypto-watch" | ||
@@ -516,9 +519,33 @@ func cloneProcessor(stream io.ReadCloser, contentType, dest string, preallocate | ||
} | ||
|
||
defer stream.Close() | ||
- bytesRead, bytesWrittenn, err := util.StreamDataToFile(stream, dest, preallocate) | ||
+ | ||
+ klog.Info("111 STREAM") | ||
+ | ||
+ bytesRead, bytesWrittenn, err := util.StreamDataToFile(stream, "/scratch/disk.img", preallocate) | ||
+ if err != nil { | ||
+ return false, fmt.Errorf("failed to stream data to file: %w", err) | ||
+ } | ||
+ | ||
+ klog.Info("222 PARSE") | ||
+ | ||
+ parsedURL, err := url.Parse("/scratch/disk.img") | ||
+ if err != nil { | ||
+ return false, fmt.Errorf("failed to parse url: %w", err) | ||
+ } | ||
+ | ||
+ klog.Info("333 CLEAN") | ||
+ | ||
+ err = importer.CleanAll(dest) | ||
+ if err != nil { | ||
+ return false, fmt.Errorf("failed to clean all: %w", err) | ||
+ } | ||
+ | ||
+ klog.Info("444 CONVERT") | ||
+ | ||
+ err = image.NewQEMUOperations().ConvertToFormatStream(parsedURL, "qcow2", dest, false) | ||
if err != nil { | ||
- return false, err | ||
+ return false, fmt.Errorf("failed to convert: %w", err) | ||
} | ||
|
||
klog.Infof("Read %d bytes, wrote %d bytes to %s", bytesRead, bytesWrittenn, dest) |