Commit Graph

19 Commits

Author SHA1 Message Date
Michael Henriksen
5f4d857789
Don't use nbdkit for xz or gz (#2351)
* Don't use nbdkit for xz or gz

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

* fix detection of VDI and VHD

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

* update docs

Signed-off-by: Michael Henriksen <mhenriks@redhat.com>
2022-07-14 00:27:59 +02:00
Michael Henriksen
e9da6f8d91
use basic auth in nbdkit (#2345)
Signed-off-by: Michael Henriksen <mhenriks@redhat.com>
2022-06-29 17:49:51 +02:00
Matthew Arnold
703e421a8a
Allow user-specified headers in HTTP data source. (#1994)
* Update HTTP data source API to allow custom headers.

Signed-off-by: Matthew Arnold <marnold@redhat.com>

* Implement custom HTTP headers API.

Signed-off-by: Matthew Arnold <marnold@redhat.com>

* Document custom headers in HTTP data source.

Signed-off-by: Matthew Arnold <marnold@redhat.com>

* Correct secretExtraHeader comment to reference Secret.

Signed-off-by: Matthew Arnold <marnold@redhat.com>

* Add volume mounts for secret headers.

Replaces environment variables for headers from secrets.

Signed-off-by: Matthew Arnold <marnold@redhat.com>

* Avoid failing when there are no extra headers.

Signed-off-by: Matthew Arnold <marnold@redhat.com>

* Redact contents of headers that come from secrets.

Also split up getExtraHeaders to reduce Sonar Cloud complexity.

Signed-off-by: Matthew Arnold <marnold@redhat.com>

* Ensure all HTTP client requests use extra headers.

Missed redirect check and content length retrieval, both of which might
need the extra headers.

Signed-off-by: Matthew Arnold <marnold@redhat.com>

* Add some unit tests for extra HTTP headers.

Signed-off-by: Matthew Arnold <marnold@redhat.com>

* Do not quote headers in nbdkit curl arguments.

Signed-off-by: Matthew Arnold <marnold@redhat.com>

* Add functional tests for extra HTTP headers.

Avoids new test server by specifiying basic authorization headers to the
existing file host port that requires it.

Signed-off-by: Matthew Arnold <marnold@redhat.com>

* Use filepath.Walk to read secrets.

Signed-off-by: Matthew Arnold <marnold@redhat.com>

* Minor documentation update for secrets.

Signed-off-by: Matthew Arnold <marnold@redhat.com>

* Re-run 'make generate' for verification failure.

Signed-off-by: Matthew Arnold <marnold@redhat.com>
2021-11-12 21:06:57 +01:00
Michael Henriksen
aedaf513ec
Move apis to staging, push to containerized-data-importer-api (#1997)
* move apis to new staging area

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

* add script to push to staging

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

* fix lint check and api reference

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

* push staging to api repo

Signed-off-by: Michael Henriksen <mhenriks@redhat.com>
2021-10-28 13:40:24 +02:00
Alice Frosi
6a37c15595
nbd: use modern uri for nbd (#1761)
Change the old nbd style nbd:unix to nbd+unix://?socket=socket

Signed-off-by: Alice Frosi <afrosi@redhat.com>
2021-04-21 18:41:04 +02:00
Maya Rashish
1595456fdc
Use nbdkit and not qemu-img in more cases (when scratch space is used) (#1610)
* Use nbdkit for imports using scratch space, too

Avoids QEMU curl bugs like:
https://bugs.launchpad.net/qemu/+bug/1916501

As well as being simpler.

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

* Remove test for a bug in QEMU that doesn't exist in nbdkit.

Nbdkit just handles this correctly, looking like a failure.

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

* Expect the URL to be the nbdkit socket

Signed-off-by: Maya Rashish <mrashish@redhat.com>
2021-04-20 23:43:04 +02:00
Alice Frosi
d2519809a1
Nbdkit refactor to unify usage for vddk and http importers (#1680)
* refactor: unify nbdkit usage

Nbdkit is used in the http and vddk importer and the code is completely
separated. This PR unifies the usages of nbdkit in a single file. For
the http importer, nbdkit was used together with qemu-img. With this
change nbdkit is started a separate process, and qemu-img read from the
local nbdkit socket.

Signed-off-by: Alice Frosi <afrosi@redhat.com>

* test: adjust the tests

Removed nbdkit together with qemu-img. Hence, we need to adjust the
tests to reflect the new behavior.

Signed-off-by: Alice Frosi <afrosi@redhat.com>
2021-03-11 10:09:31 +01:00
Alice Frosi
f33abe6350
Use nbdkit for direct stream for the http importer (#1508)
* Add nbdkit with qemu-img

Nbdkit can be used to stream directly the content of the image together
with qemu-img. It supports different plugins and filters.

Signed-off-by: Alice Frosi <afrosi@redhat.com>

* Use nbdkit to the http importer

Add nbdkit to stream directly the image content avoiding the scratch
space for the http importer.

Signed-off-by: Alice Frosi <afrosi@redhat.com>

* Adjust functional test cases with nbdkit

With the introduction of nbdkit, certain error messages do not match anymore,
and needed to be adjusted to the new behavior.

The scratch space is not needed anymore when the source is http for the majority of the cases.
Certain test cases checked the use of the scratch space, and those are not valid anymore.

Signed-off-by: Alice Frosi <afrosi@redhat.com>
2021-01-15 08:15:02 +01:00
Maya Rashish
c2c6e2ebda
Text-only changes missed in removing the Process phase (#1446) (#1562)
Signed-off-by: Maya Rashish <mrashish@redhat.com>
2021-01-15 05:19:02 +01:00
Maya Rashish
92a1ae073a
Remove the "Process" data processor phase, simplify state machine. (#1446)
This phase can mean three things:
HTTP, imageio, s3, upload: Go directly to Convert
VDDK: unreachable code, points to arbitrary other phase.
registry: do minor processing after transfer.

Only registry makes actual use of this phase.

Point all current users directly to Convert, and fold the
work done in the registry Process phase into the previous
phase.

Signed-off-by: Maya Rashish <mrashish@redhat.com>
2020-11-04 12:45:49 +01:00
Maya Rashish
5fede6938b
Make it possible to import images needing conversion from servers that don't support range requests (#1326)
* Combine tests in bad_webserver.go into a table

No functional change intended.

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

* Use a QCOW2 image for testing badserver.

This has the benefit of going through qemu-img for conversion,
which can introduce more bugs.

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

* Don't pass URLs to qemu-img if Accept-Ranges header isn't bytes.

Adapt unit tests so they don't also test this feature.
Add a handler to bad-webserver to do a very plain HTTP response
using a downloaded file from cdi-file-host. This one doesn't
come with builtin support for range requests.

Use this handler to test that CDI can still import images needing
conversion.

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

* Invert polarity and test for "none".

It's highly unlikely that a value other than bytes becomes a
valid choice, but let's not rule that out.

Signed-off-by: Maya Rashish <mrashish@redhat.com>
2020-08-12 18:11:55 +02:00
Michael Henriksen
9e2c79b1e0
move api groups to v1beta1 (#1232)
* move upload.cdi.kubevirt.io API group to v1beta1

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

* move core api to v1beta1

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

* fix os-3.11 cluster sync and add functional tests for alpha api

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

* change more occurences of v1alpha1

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

* updates after rebase

Signed-off-by: Michael Henriksen <mhenriks@redhat.com>
2020-07-10 15:47:38 +02:00
maya-r
eb45ed532a
Eliminate the need for HEAD requests in the Go HTTP download client. (#1122)
* Tolerate failing to find a Content-Length via HEAD requests.

Some servers don't accept HEAD requests, and Content-Length is
an optional field anyway.
In such cases, qemu-img won't be able to do a streaming
conversion of the URL, so download using our Go download code
to scratch space and convert the resulting file.
Use the field "brokenForQemuImg" to note this scenario.

This fixes creating a DataVolume using one of our examples,
manifests/example/import-kubevirt-datavolume.yaml

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

* Don't bother with basic auth, this test isn't about that

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

* Test for reasonable behaviour if HEAD requests are forbidden

Make sure that we mark it broken for qemu-img, but still succeed
in continuing.

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

* Use %v to print err

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

* Fix linter failure

Signed-off-by: Maya Rashish <mrashish@redhat.com>
2020-04-13 16:23:56 +02: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
Alexander Wels
747bfc5f66
Merge branch 'master' into update_progress_reader 2019-05-16 09:28:51 -04:00
Artyom Lukianov
40325745d0 Copy triple package from client-go repository
This package droped from client-go 1.13.4, so until
we will have find some good alternatives, we can use local copy.
2019-05-16 09:38:37 +03:00
Alexander Wels
49ebfff1b4 Add prometheus progress stats for importing Reader.
Signed-off-by: Alexander Wels <awels@redhat.com>
2019-05-15 14:13:51 -04:00
Alexander Wels
c30f3975d2 Remove tar from the readers
Signed-off-by: Alexander Wels <awels@redhat.com>
2019-05-03 08:37:45 -04:00
Alexander Wels
2d6375b057 data stream refactor.
Signed-off-by: Alexander Wels <awels@redhat.com>
2019-04-10 09:18:55 -04:00