mirror of
https://github.com/kubevirt/containerized-data-importer.git
synced 2025-06-03 06:30:22 +00:00
Merge pull request #559 from mhenriks/blank-image
Blank images always being created with size of 0
This commit is contained in:
commit
e4c20d3bc1
@ -67,7 +67,7 @@ func main() {
|
||||
|
||||
if source == controller.SourceNone && contentType == controller.ContentTypeKubevirt {
|
||||
requestImageSizeQuantity := resource.MustParse(imageSize)
|
||||
minSizeQuantity := util.MinQuantity(resource.NewScaledQuantity(util.GetAvailableSpace(common.ImporterWritePath), 0), &requestImageSizeQuantity)
|
||||
minSizeQuantity := util.MinQuantity(resource.NewScaledQuantity(util.GetAvailableSpace(common.ImporterVolumePath), 0), &requestImageSizeQuantity)
|
||||
if minSizeQuantity.Cmp(requestImageSizeQuantity) != 0 {
|
||||
// Available dest space is smaller than the size we want to create
|
||||
glog.Warningf("Available space less than requested size, creating blank image sized to availabe space: %s.\n", minSizeQuantity.String())
|
||||
|
@ -104,6 +104,8 @@ func processScanner(scanner *bufio.Scanner, buf *bytes.Buffer, done chan bool, c
|
||||
|
||||
// ExecWithLimits executes a command with process limits
|
||||
func ExecWithLimits(limits *ProcessLimitValues, callback func(string), command string, args ...string) ([]byte, error) {
|
||||
glog.Infof("ExecWithLimits %s, %+v", command, args)
|
||||
|
||||
var buf bytes.Buffer
|
||||
stdoutDone := make(chan bool)
|
||||
stderrDone := make(chan bool)
|
||||
|
@ -71,7 +71,7 @@ func (f *Framework) VerifyTargetPVCContent(namespace *k8sv1.Namespace, pvc *k8sv
|
||||
|
||||
// VerifyTargetPVCContentMD5 provides a function to check the md5 of data on a PVC and ensure it matches that which is provided
|
||||
func (f *Framework) VerifyTargetPVCContentMD5(namespace *k8sv1.Namespace, pvc *k8sv1.PersistentVolumeClaim, fileName string, expectedHash string) bool {
|
||||
executorPod, err := utils.CreateExecutorPodWithPVC(f.K8sClient, "verify-pvc-content", namespace.Name, pvc)
|
||||
executorPod, err := utils.CreateExecutorPodWithPVC(f.K8sClient, "verify-pvc-md5", namespace.Name, pvc)
|
||||
gomega.Expect(err).ToNot(gomega.HaveOccurred())
|
||||
err = utils.WaitTimeoutForPodReady(f.K8sClient, executorPod.Name, namespace.Name, utils.PodWaitForTime)
|
||||
gomega.Expect(err).ToNot(gomega.HaveOccurred())
|
||||
|
@ -26,6 +26,7 @@ const (
|
||||
controllerSkipPVCCompleteTimeout = 90 * time.Second
|
||||
invalidEndpoint = "http://gopats.com/who-is-the-goat.iso"
|
||||
BlankImageCompleteTimeout = 60 * time.Second
|
||||
BlankImageMD5 = "cd573cfaace07e7949bc0c46028904ff"
|
||||
)
|
||||
|
||||
var _ = Describe(testSuiteName, func() {
|
||||
@ -84,6 +85,10 @@ var _ = Describe(testSuiteName, func() {
|
||||
Expect(phaseAnnotation).To(BeTrue())
|
||||
return status
|
||||
}, BlankImageCompleteTimeout, assertionPollInterval).Should(BeEquivalentTo(v1.PodSucceeded))
|
||||
|
||||
By("Verify the image contents")
|
||||
same := f.VerifyTargetPVCContentMD5(f.Namespace, pvc, utils.DefaultImagePath, BlankImageMD5)
|
||||
Expect(same).To(BeTrue())
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -12,8 +12,6 @@ import (
|
||||
"kubevirt.io/containerized-data-importer/tests/utils"
|
||||
)
|
||||
|
||||
const testFile = utils.DefaultPvcMountPath + "/disk.img"
|
||||
|
||||
var _ = Describe("Upload tests", func() {
|
||||
|
||||
f := framework.NewFrameworkOrDie("upload-func-test")
|
||||
@ -50,7 +48,7 @@ var _ = Describe("Upload tests", func() {
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
By("Verify content")
|
||||
same := f.VerifyTargetPVCContentMD5(f.Namespace, pvc, testFile, utils.UploadFileMD5)
|
||||
same := f.VerifyTargetPVCContentMD5(f.Namespace, pvc, utils.DefaultImagePath, utils.UploadFileMD5)
|
||||
Expect(same).To(BeTrue())
|
||||
|
||||
By("Delete upload PVC")
|
||||
|
@ -22,6 +22,9 @@ const (
|
||||
// DefaultPvcMountPath is the default mount path used
|
||||
DefaultPvcMountPath = "/pvc"
|
||||
|
||||
// DefaultImagePath is the default destination for images created by CDI
|
||||
DefaultImagePath = DefaultPvcMountPath + "/disk.img"
|
||||
|
||||
pvcPollInterval = defaultPollInterval
|
||||
pvcCreateTime = defaultPollPeriod
|
||||
pvcDeleteTime = defaultPollPeriod
|
||||
|
Loading…
Reference in New Issue
Block a user