Merge pull request #559 from mhenriks/blank-image

Blank images always being created with size of 0
This commit is contained in:
Alexander Wels 2018-12-05 15:28:22 -05:00 committed by GitHub
commit e4c20d3bc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 13 additions and 5 deletions

View File

@ -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())

View File

@ -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)

View File

@ -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())

View File

@ -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())
})
})

View File

@ -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")

View File

@ -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