diff --git a/images/cdi-artifact/patches/017-foobar.patch b/images/cdi-artifact/patches/017-foobar.patch new file mode 100644 index 000000000..f3775fb30 --- /dev/null +++ b/images/cdi-artifact/patches/017-foobar.patch @@ -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)