Commit Graph

33 Commits

Author SHA1 Message Date
Maya Rashish
3b36e1cd4f
Validate image fits in filesystem in a lot more cases. take filesystem overhead into account when resizing. (#1466)
* Validate images fit on a filesystem in more cases.

Background:
When the backing store is a filesystem, we store the images
as sparse files. So the file may eventually grow to be bigger
than the available storage. This will cause unfortunate
failures down the line.

Prior to this commit, we validated the size:
- In case the backing store implicitly did it for us (block volumes)
- On async upload
- When resizing (by the operation failing if the image cannot fit
in the available space).

The Resize phase is encountered quite commonly:
Transfer->Convert->Resize
TransferFile->Resize

Adding validation here for the non-resize case covers almost all
the cases.

The only exceptions that aren't validated now are:
- DataVolumeArchive via the HTTP datasource
- VDDK

Signed-off-by: Maya Rashish <mrashish@redhat.com>

* When resizing, take into account filesystem overhead.

Signed-off-by: Maya Rashish <mrashish@redhat.com>

* Add testing for too large upload/import

- Import/sync upload of too large physical size image (raw.xz, qcow2)
- Import/sync upload of too large virtual size image (raw.xz, qcow2)
- Import of a too large raw image file, if filesystem overhead is
taken into account

- Async upload of too large physical size qcow2.
The async upload cases do not mirror the sync upload ones because if
a block device is used as scratch space, it will hit a size limit
before the validation pause, and fail differently.
This scenario is identical to the sync upload case which was added.

Signed-off-by: Maya Rashish <mrashish@redhat.com>

* Refactor code in a way that requires less comments to explain.

We can just validate that the requested image size will fit in the
available space, and not rely on the fact we typically resize the
images to the full size.

Signed-off-by: Maya Rashish <mrashish@redhat.com>

* When calculating usable space, round down to a multiple of 512.

Our validation is indirectly:
image after resize to usable space <= usable space
For this to pass, we need to ensure that qemu-img's rounding
up to 512 doesn't change the size.

Signed-off-by: Maya Rashish <mrashish@redhat.com>

* Adjust qemu-img to the ones emitted by nbdkit:

- In some cases, we clearly don't rely on the qemu-img error,
so don't check for it.
- In one case, switch it to looking for the nbdkit equivalent
error message.

Signed-off-by: Maya Rashish <mrashish@redhat.com>
2021-01-25 19:36:49 +01:00
Maya Rashish
62325947ae
Update to k8s.io/klog/v2, used by kubernetes 1.19 (#1409)
Signed-off-by: Maya Rashish <mrashish@redhat.com>
2020-10-03 00:41:33 +02:00
Tomasz Barański
536af6b1ad
Replace skopeo (#1322)
* Updated dependencies
Signed-off-by: Tomasz Baranski <tbaransk@redhat.com>

* Replace skopeo with containers API.

This commit removes dependence on skopeo (binary) and uses containers
API. By doing that we're able to opimize the use of storage (scratch)
space, storage I/O and download bandwith.

Signed-off-by: Tomasz Baranski <tbaransk@redhat.com>

* Fixing rebase - dependencies kerfuffle.

Signed-off-by: Tomasz Baranski <tbaransk@redhat.com>

* Handling docker-format images as well as OCI.

Signed-off-by: Tomasz Baranski <tbaransk@redhat.com>

* Fix for missing code-generator module.

Signed-off-by: Tomasz Baranski <tbaransk@redhat.com>

* Remove regex, image file in registry images are matched by a path
prefix.

Signed-off-by: Tomasz Baranski <tbaransk@redhat.com>

* Added nginx proxy in front of docker registry for a rate-limited access.

Signed-off-by: Tomasz Baranski <tbaransk@redhat.com>
2020-08-22 05:52:00 +02:00
Alexander Wels
310e5e239f
GetAvailableSpace(block) now returns error (#1244)
Modified function that gets the size of a block device/available to return error as well as -1, so we
can distinguish the path not existing from the binary not existing in case the container doesn't have
the required binaries.

Last lane also passed, but due to slow CI timed out before reporting results.

Signed-off-by: Alexander Wels <awels@redhat.com>
2020-06-19 13:57:37 -04:00
maya-r
a3bb6d6262
Restore sparse images as the default (revert #970) (#1140)
(Leaving in some of the checks introduced in that change)

Having sparse disks works better with external storage being
monitored for low capacity. If we allocate the full size at
start, it shows up as a disk capacity alert immediately.

Another motivation to pre-allocate was that cloning would
sometimes fail for capacity reasons.
We now validate available size before cloning, so we don't
expect that problem to return.

Signed-off-by: Maya Rashish <mrashish@redhat.com>
2020-03-12 04:43:58 +01:00
Michael Henriksen
bd4c4c950b
cert rotation (#1091)
* initial cert rotation controller

Signed-off-by: Michael Henriksen <mhenriks@redhat.com>

* fix typo

Signed-off-by: Michael Henriksen <mhenriks@redhat.com>
2020-02-03 23:36:58 +01:00
Michael Henriksen
99f8af5b86 k8s client upgrade to 1.16 (#1079)
* initial client upgrade to 1.16

Signed-off-by: Michael Henriksen <mhenriks@redhat.com>

* fix Route detection in OpenShift

Signed-off-by: Michael Henriksen <mhenriks@redhat.com>
2020-01-14 13:43:17 +01:00
clarklee
2f107b89f9 Fix GetAvailableSpaceBlock always return -1 in LXC (#1065)
In a normal Linux container, /sys/class/block/ is inherited from the host, and the result presented by lsblk is the metadata of the host, which does not effectively capture the size of the block device transmitted to the container

Signed-off-by: clarklee92 <clarklee1992@hotmail.com>
2020-01-06 18:46:56 +01:00
Alexander Wels
f090ddc2e6 Update Import controller to use runtime controller library. (#1054)
Refactor import related utilities out of util.go into the controller.

Signed-off-by: Alexander Wels <awels@redhat.com>
2019-12-20 19:28:43 +01:00
Alexander Wels
2884854375
falloc on resize and blank disk. (#970)
Signed-off-by: Alexander Wels <awels@redhat.com>
2019-09-25 07:57:30 -04:00
Michael Henriksen
834b85ecbf Network clone (#897)
* network cloning

* fix clone progress
2019-08-01 16:01:25 -04:00
Daniel Erez
c9625162c1 datavolume_test: malicious qcow2 images
Added functional tests to ensure that malicious
qcow2 images are being rejected. I.e. the creation
of import datavolume should fail when converted to raw.

Change-Id: I3372105fdcd28b8e01811d7e6752f04f5dba9e0d
Signed-off-by: Daniel Erez <derez@redhat.com>
Signed-off-by: Fred Rolland <frolland@redhat.com>
Co-authored-by: Fred Rolland <frolland@redhat.com>
2019-06-04 12:53:08 +03:00
Alexander Wels
d3a522051b Send more useful error messages from pods up to the controlling objects.
Signed-off-by: Alexander Wels <awels@redhat.com>
2019-05-29 07:51:15 -04:00
Alexander Wels
05b6a21736 Fix issues with size header in cloning something reading beginning of data.
Signed-off-by: Alexander Wels <awels@redhat.com>
2019-04-26 19:47:03 -04:00
tavni
e6665945bc Adding support to clone disk image from one Block PV to another
Signed-off-by: tavni <tavni@redhat.com>
2019-04-15 15:33:52 +03:00
Alexander Wels
2d6375b057 data stream refactor.
Signed-off-by: Alexander Wels <awels@redhat.com>
2019-04-10 09:18:55 -04:00
tavni
d4c7b0be54 Adding support to import disk image into Block PV
Signed-off-by: tavni <tavni@redhat.com>
2019-03-28 11:43:56 +02:00
Alexander Wels
1e46004ad2 Scratch space retry framework logic.
Signed-off-by: Alexander Wels <awels@redhat.com>
2019-03-07 14:54:08 -05:00
Y.Horie
c9104059fb move to klog from glog 2019-03-05 13:33:20 +09:00
annastopel
3fde120d67 Remove unused code 2019-02-18 08:52:57 +02:00
annastopel
b9edce9ef0 Import VM disk from ContainerDisk image 2019-02-12 21:11:39 +02:00
annastopel
cb80249a7f BugFix: cdi importer fails to import from registry when run in unpriviledged container 2019-02-06 21:17:57 +02:00
Michael Henriksen
27d6a606a8 cleanup resources made by controller when uninstalling and flush out status 2019-01-16 20:22:14 -05:00
Daniel Erez
b21ce94ee7 skopeo: use util UnArchiveTar
Added UnArchiveLocalTar func to util for using in skoepo
(instead of ExtractTar func).

Change-Id: I074400426d3895027a980af79bec0604f97f4c1f
Signed-off-by: Daniel Erez <derez@redhat.com>
2018-12-02 10:40:07 +02:00
Alexander Wels
a76e8fb0c1 Unify untar code.
Signed-off-by: Alexander Wels <awels@redhat.com>
2018-12-01 02:03:14 +02:00
Alexander Wels
260d4fa8e0 Automatically resize image to fit the requested PVC.
Combined code from PR#489 and PR#490 by
@gites and
@danielerez
Added some tests and rebased on current master.

Signed-off-by: Alexander Wels <awels@redhat.com>
2018-11-20 15:40:13 -05:00
Alexander Wels
a189bfeb8f Rolling timeout on streaming transfer.
Signed-off-by: Alexander Wels <awels@redhat.com>
2018-11-08 16:32:04 -05:00
Alexander Wels
a5a82aa970 Report import progress with prometheus
- Added code report progress with prometheus

Signed-off-by: Alexander Wels <awels@redhat.com>
2018-10-31 11:26:38 -04:00
jeff vance
40c1143c66 deprecation of local endpoint support
- Removed file:// end points from code base.
- Updated unit tests to use httptest server instead of file://
- Refactored data stream unit tests to use ginko/gomega
2018-09-27 07:27:49 -04:00
Michael Henriksen
762cf6860d api server create explicit key for signing 2018-09-19 12:30:46 -04:00
John Griffith
dc296effac Fix golint errors in util pkg (#421) 2018-09-05 09:28:52 -07:00
John Griffith
8ca745b700 Run gofmt on our directories (#370)
Just do a simple `gofmt -s -w` on pkg, tests and controller directories
to fix the misc space/tab mixes and some other ez formatting issues.
2018-08-23 15:31:14 -07:00
Jonathan Cope
aa82c9d577 Refactor random string gen to util.go (#258)
* Refactor random string gen to util.go

* unit test

* gofmt
2018-07-13 11:41:41 -07:00