Commit Graph

27 Commits

Author SHA1 Message Date
Alexander Wels
1f14ac7545
Always use scratchspace when importing and converting (#2832)
* Remove older nbdkit

Signed-off-by: Alexander Wels <awels@redhat.com>

* When converting always use scratch space importing instead
of ndbkit. Once we are able to get nbdkit 1.35.8 or newer
we can revert this change since that will include improvements
to the downloading speed.

Signed-off-by: Alexander Wels <awels@redhat.com>

* Disable metrics test for import because straight import doesn't
return total, and this means the metrics are disabled.

Signed-off-by: Alexander Wels <awels@redhat.com>

* Fix broken functional tests

Signed-off-by: Alexander Wels <awels@redhat.com>

* Address review comments

Signed-off-by: Alexander Wels <awels@redhat.com>

* Additional review comments.
Fixed functional test that was not doing the right
thing while running the test.

Signed-off-by: Alexander Wels <awels@redhat.com>

* Always set preallocation on block devices when directly
writing to the device

Signed-off-by: Alexander Wels <awels@redhat.com>

---------

Signed-off-by: Alexander Wels <awels@redhat.com>
2023-08-11 22:31:28 +02:00
Maya Rashish
5e4cb68044
Update to ginkgo v2 (#2788)
* Run `make deps-update`

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

* Update to ginkgo v2

Avoid using table extension to avoid compilation errors
Switch to v2 everywhere
Update qe-tools as well (required)

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

* Fix/avoid deprecation warnings

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

* Do not use v1 reporter

For unit tests: stop using custom reporter, unnecessary
For functional tests: borrow code from kubevirt to keep reporting

Avoid deprecated warnings by golangci for using deprecated reporter

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

* Increase ginkgo timeout to 24h (default in ginkgo v1)

this may seem excessive, but we have a lower timeout in Prow, let's save
ourselves the future trouble of bumping timeouts in two places.

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

* use the ginkgo built-in junit reporter

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

* Avoid using deprecated --ginkgo.noColor, use --ginkgo.no-color instead

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

---------

Signed-off-by: Maya Rashish <mrashish@redhat.com>
2023-07-26 02:35:55 +02:00
Nahshon Unna Tsameret
4d14028d5b
enable ginkgolinter and fix findings (#2703)
Signed-off-by: Nahshon Unna-Tsameret <nunnatsa@redhat.com>
2023-05-04 13:07:36 +02:00
Nahshon Unna Tsameret
e6d2286dfb
golangci-lint: Enable errcheck (#2696)
* golangci-lint: enable errcheck and fix findings

Signed-off-by: Nahshon Unna-Tsameret <nunnatsa@redhat.com>

* golangci=lint: exit if find something

Signed-off-by: Nahshon Unna-Tsameret <nunnatsa@redhat.com>

---------

Signed-off-by: Nahshon Unna-Tsameret <nunnatsa@redhat.com>
2023-04-25 20:40:16 +02:00
Nahshon Unna Tsameret
48166bdc8d
Enable additional linters to golangci-lint configuration (#2691)
* enable the typecheck linter in golangci-lint

Signed-off-by: Nahshon Unna-Tsameret <nunnatsa@redhat.com>

* enable the staticcheck linter and fix findings

Signed-off-by: Nahshon Unna-Tsameret <nunnatsa@redhat.com>

* golangci-lint: enable ineffassign and fix finding

Signed-off-by: Nahshon Unna-Tsameret <nunnatsa@redhat.com>

---------

Signed-off-by: Nahshon Unna-Tsameret <nunnatsa@redhat.com>
2023-04-17 13:30:28 +01:00
Nahshon Unna Tsameret
34a98256a2
Start integrate golangci lint into CI (#2675)
* Start adding the golangci-lint to CI

golangci-lint is a collection of many linters. This PR adds
golangci-lint to the CI. For strat, it enables the govet linter, and fix
its single finding.

The PR adds this linter to the `test-lint` Makefile target.

The new .golangci.yml file is the configuration for the linter.

golangci-lint version was set to the latest one - v1.52.2.
It is defined in hack/build/run-linters.sh

Signed-off-by: Nahshon Unna-Tsameret <nunnatsa@redhat.com>

* golangci-lint: enable gosimple and fix findings

Signed-off-by: Nahshon Unna-Tsameret <nunnatsa@redhat.com>

* golangci-lint: enable unused and fix findings

Signed-off-by: Nahshon Unna-Tsameret <nunnatsa@redhat.com>

---------

Signed-off-by: Nahshon Unna-Tsameret <nunnatsa@redhat.com>
2023-04-11 13:59:33 +01:00
Eng Zer Jun
aaacbae797
refactor: move from io/ioutil to io and os packages (#2484)
The io/ioutil package has been deprecated as of Go 1.16 [1]. This commit
replaces the existing io/ioutil functions with their new definitions in
io and os packages.

[1]: https://golang.org/doc/go1.16#ioutil
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-12-05 19:19:13 +00:00
Michael Henriksen
46c6aa994a
Support restricted PSA for worker pods (#2410)
* remove root worker pods

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

* remove selinux requirement for worker pods

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

* run tests in restricted namespace and required changes

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

* handle empty tar

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

* add PSA label when running functional tests in OpenShift

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

* cannot use restricted PSA with istio (for now)

refactor scc management

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

* fix clean script

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

Signed-off-by: Michael Henriksen <mhenriks@redhat.com>
2022-09-14 21:16:23 +01:00
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