Skip to content
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

[release-v1.58] Extract regular files as well during clone from filesystem volume #3046

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pkg/uploadserver/uploadserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,11 @@ func untarToBlockdev(stream io.Reader, dest string) error {
case header == nil:
continue
}
if header.Typeflag == tar.TypeGNUSparse && strings.Contains(header.Name, common.DiskImageName) {
if !strings.Contains(header.Name, common.DiskImageName) {
continue
}
switch header.Typeflag {
case tar.TypeReg, tar.TypeGNUSparse:
klog.Infof("Untaring %d bytes to %s", header.Size, dest)
f, err := os.OpenFile(dest, os.O_APPEND|os.O_WRONLY, os.ModeDevice|os.ModePerm)
if err != nil {
Expand Down
12 changes: 9 additions & 3 deletions tests/cloner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ var _ = Describe("all clone tests", func() {
completeClone(f, f.Namespace, targetPvc, filepath.Join(testBaseDir, testFile), fillDataFSMD5sum, "")
})

It("[test_id:cnv-5569]Should clone data from filesystem to block", func() {
DescribeTable("Should clone data from filesystem to block", func(preallocate bool) {
if !f.IsBlockVolumeStorageClassAvailable() {
Skip("Storage Class for block volume is not available")
}
Expand All @@ -445,6 +445,9 @@ var _ = Describe("all clone tests", func() {
Expect(err).ToNot(HaveOccurred())

targetDV := utils.NewDataVolumeCloneToBlockPV("target-dv", "1Gi", sourcePvc.Namespace, sourcePvc.Name, f.BlockSCName)
if preallocate {
targetDV.Spec.Preallocation = pointer.Bool(true)
}
targetDataVolume, err := utils.CreateDataVolumeFromDefinition(f.CdiClient, f.Namespace.Name, targetDV)
Expect(err).ToNot(HaveOccurred())
targetPvc, err := utils.WaitForPVC(f.K8sClient, targetDataVolume.Namespace, targetDataVolume.Name)
Expand Down Expand Up @@ -474,9 +477,12 @@ var _ = Describe("all clone tests", func() {
By("Deleting verifier pod")
err = utils.DeleteVerifierPod(f.K8sClient, f.Namespace.Name)
Expect(err).ToNot(HaveOccurred())
})
},
Entry("[test_id:5569]regular target", false),
Entry("[test_id:XXXX]preallocated target", true),
)

It("[test_id:cnv-5570]Should clone data from block to filesystem", func() {
It("[test_id:5570]Should clone data from block to filesystem", func() {
if !f.IsBlockVolumeStorageClassAvailable() {
Skip("Storage Class for block volume is not available")
}
Expand Down