Skip to content

Commit

Permalink
was incorrectly getting available free space on volume
Browse files Browse the repository at this point in the history
  • Loading branch information
mhenriks authored and awels committed Dec 6, 2018
1 parent 31df8cd commit 9acbde4
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmd/cdi-importer/importer.go
Expand Up @@ -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())
Expand Down
2 changes: 2 additions & 0 deletions pkg/system/prlimit.go
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tests/framework/pvc.go
Expand Up @@ -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())
Expand Down
5 changes: 5 additions & 0 deletions tests/import_test.go
Expand Up @@ -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() {
Expand Down Expand Up @@ -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())
})
})

Expand Down
4 changes: 1 addition & 3 deletions tests/upload_test.go
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down
3 changes: 3 additions & 0 deletions tests/utils/pvc.go
Expand Up @@ -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
Expand Down

0 comments on commit 9acbde4

Please sign in to comment.