|
4 | 4 | "context"
|
5 | 5 | "encoding/json"
|
6 | 6 | "fmt"
|
7 |
| - "strconv" |
8 | 7 | "strings"
|
9 | 8 | "time"
|
10 | 9 |
|
@@ -284,22 +283,12 @@ func (f *Framework) VerifyBlankDisk(namespace *k8sv1.Namespace, pvc *k8sv1.Persi
|
284 | 283 | // VerifySparse checks a disk image being sparse after creation/resize.
|
285 | 284 | func (f *Framework) VerifySparse(namespace *k8sv1.Namespace, pvc *k8sv1.PersistentVolumeClaim, imagePath string) (bool, error) {
|
286 | 285 | var info image.ImgInfo
|
287 |
| - var imageContentSize int64 |
288 | 286 | err := f.GetImageInfo(namespace, pvc, imagePath, &info)
|
289 | 287 | if err != nil {
|
290 | 288 | return false, err
|
291 | 289 | }
|
292 |
| - // qemu-img info gives us ActualSize but that is size on disk |
293 |
| - // which isn't important to us in this comparison; we compare content size |
294 |
| - err = f.GetImageContentSize(namespace, pvc, imagePath, &imageContentSize) |
295 |
| - if err != nil { |
296 |
| - return false, err |
297 |
| - } |
298 |
| - if info.ActualSize-imageContentSize >= units.MiB { |
299 |
| - return false, fmt.Errorf("Diff between content size %d and size on disk %d is significant, something's not right", imageContentSize, info.ActualSize) |
300 |
| - } |
301 |
| - fmt.Fprintf(ginkgo.GinkgoWriter, "INFO: VerifySparse comparison: Virtual: %d vs Content: %d\n", info.VirtualSize, imageContentSize) |
302 |
| - return info.VirtualSize >= imageContentSize, nil |
| 290 | + // The content size of a sparse image is significantly lower than the image's virtual size |
| 291 | + return info.VirtualSize-info.ActualSize >= units.MiB, nil |
303 | 292 | }
|
304 | 293 |
|
305 | 294 | // VerifyFSOverhead checks whether virtual size is smaller than actual size. That means FS Overhead has been accounted for.
|
@@ -546,26 +535,6 @@ func (f *Framework) GetImageInfo(namespace *k8sv1.Namespace, pvc *k8sv1.Persiste
|
546 | 535 | return err
|
547 | 536 | }
|
548 | 537 |
|
549 |
| -// GetImageContentSize returns the content size (as opposed to size on disk) of an image |
550 |
| -func (f *Framework) GetImageContentSize(namespace *k8sv1.Namespace, pvc *k8sv1.PersistentVolumeClaim, imagePath string, imageSize *int64) error { |
551 |
| - cmd := fmt.Sprintf("du -s --apparent-size -B 1 %s | cut -f 1", imagePath) |
552 |
| - |
553 |
| - _, err := f.verifyInPod(namespace, pvc, cmd, func(output, stderr string) (bool, error) { |
554 |
| - fmt.Fprintf(ginkgo.GinkgoWriter, "CMD (%s) output %s\n", cmd, output) |
555 |
| - |
556 |
| - size, err := strconv.ParseInt(output, 10, 64) |
557 |
| - if err != nil { |
558 |
| - klog.Errorf("Invalid image content size:\n%s\n", output) |
559 |
| - return false, err |
560 |
| - } |
561 |
| - *imageSize = size |
562 |
| - |
563 |
| - return true, nil |
564 |
| - }) |
565 |
| - |
566 |
| - return err |
567 |
| -} |
568 |
| - |
569 | 538 | func (f *Framework) startVerifierPod(namespace *k8sv1.Namespace, pvc *k8sv1.PersistentVolumeClaim) (*k8sv1.Pod, error) {
|
570 | 539 | var executorPod *k8sv1.Pod
|
571 | 540 | var err error
|
|
0 commit comments