Skip to content

Commit

Permalink
Use scratch space for all non-archive uploads
Browse files Browse the repository at this point in the history
Basically a follow up to 3219 for upload sources,
which suffer from the same issue of losing sparseness.

Signed-off-by: Alex Kalenyuk <[email protected]>
  • Loading branch information
akalenyu committed May 1, 2024
1 parent 50bcbb5 commit 86ef1bf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
4 changes: 0 additions & 4 deletions pkg/importer/upload-datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ func (ud *UploadDataSource) Info() (ProcessingPhase, error) {
if ud.contentType == cdiv1.DataVolumeArchive {
return ProcessingPhaseTransferDataDir, nil
}
if !ud.readers.Convert {
// Uploading a raw file, we can write that directly to the target.
return ProcessingPhaseTransferDataFile, nil
}
return ProcessingPhaseTransferScratch, nil
}

Expand Down
12 changes: 6 additions & 6 deletions pkg/importer/upload-datasource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ var _ = Describe("Upload data source", func() {
ud = NewUploadDataSource(file, dvKubevirt)
result, err := ud.Info()
Expect(err).NotTo(HaveOccurred())
Expect(ProcessingPhaseTransferDataFile).To(Equal(result))
Expect(ProcessingPhaseTransferScratch).To(Equal(result))
})

DescribeTable("calling transfer should", func(fileName string, dvContentType cdiv1.DataVolumeContentType, expectedPhase ProcessingPhase, scratchPath string, want []byte, wantErr bool) {
Expand Down Expand Up @@ -136,7 +136,7 @@ var _ = Describe("Upload data source", func() {
ud = NewUploadDataSource(sourceFile, dvKubevirt)
result, err := ud.Info()
Expect(err).NotTo(HaveOccurred())
Expect(ProcessingPhaseTransferDataFile).To(Equal(result))
Expect(ProcessingPhaseTransferScratch).To(Equal(result))
result, err = ud.TransferFile(filepath.Join(tmpDir, "file"))
Expect(err).ToNot(HaveOccurred())
Expect(ProcessingPhaseResize).To(Equal(result))
Expand All @@ -149,7 +149,7 @@ var _ = Describe("Upload data source", func() {
ud = NewUploadDataSource(sourceFile, dvKubevirt)
result, err := ud.Info()
Expect(err).NotTo(HaveOccurred())
Expect(ProcessingPhaseTransferDataFile).To(Equal(result))
Expect(ProcessingPhaseTransferScratch).To(Equal(result))
result, err = ud.TransferFile("/invalidpath/invalidfile")
Expect(err).To(HaveOccurred())
Expect(ProcessingPhaseError).To(Equal(result))
Expand Down Expand Up @@ -211,7 +211,7 @@ var _ = Describe("Async Upload data source", func() {
aud = NewAsyncUploadDataSource(file)
result, err := aud.Info()
Expect(err).NotTo(HaveOccurred())
Expect(ProcessingPhaseTransferDataFile).To(Equal(result))
Expect(ProcessingPhaseTransferScratch).To(Equal(result))
})

DescribeTable("calling transfer should", func(fileName, scratchPath string, want []byte, wantErr bool) {
Expand Down Expand Up @@ -260,7 +260,7 @@ var _ = Describe("Async Upload data source", func() {
aud = NewAsyncUploadDataSource(sourceFile)
result, err := aud.Info()
Expect(err).NotTo(HaveOccurred())
Expect(ProcessingPhaseTransferDataFile).To(Equal(result))
Expect(ProcessingPhaseTransferScratch).To(Equal(result))
result, err = aud.TransferFile(filepath.Join(tmpDir, "file"))
Expect(err).ToNot(HaveOccurred())
Expect(ProcessingPhaseValidatePause).To(Equal(result))
Expand All @@ -274,7 +274,7 @@ var _ = Describe("Async Upload data source", func() {
aud = NewAsyncUploadDataSource(sourceFile)
result, err := aud.Info()
Expect(err).NotTo(HaveOccurred())
Expect(ProcessingPhaseTransferDataFile).To(Equal(result))
Expect(ProcessingPhaseTransferScratch).To(Equal(result))
result, err = aud.TransferFile("/invalidpath/invalidfile")
Expect(err).To(HaveOccurred())
Expect(ProcessingPhaseError).To(Equal(result))
Expand Down

0 comments on commit 86ef1bf

Please sign in to comment.