Skip to content

Commit

Permalink
fix(vd): test
Browse files Browse the repository at this point in the history
Signed-off-by: Isteb4k <[email protected]>
  • Loading branch information
Isteb4k committed Nov 1, 2024
1 parent 1002322 commit 9e07e8d
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions images/cdi-artifact/patches/017-foobar.patch
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)

0 comments on commit 9e07e8d

Please sign in to comment.