Commit Graph

42 Commits

Author SHA1 Message Date
alromeros
07661a00f3
Add a webhook for import and upload populator CRs (#2707)
* Add webhooks for volumeimportsource and volumeuploadsource CRs

This commit implements a new webhook to validate the creation and update of volumeimportsources and volumeuploadsources.

It also adds proper testing for the new webhook.

Signed-off-by: Alvaro Romero <alromero@redhat.com>

* Add functional tests for the populator webhook

Signed-off-by: Alvaro Romero <alromero@redhat.com>

---------

Signed-off-by: Alvaro Romero <alromero@redhat.com>
2023-05-10 18:45:11 +02: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
Arnon Gilboa
a222359dc6
Adapt DataImportCron and DataSource to DV GC (#2441)
* Adapt DataImportCron and DataSource to DV GC

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>

* Add DIC test for GC

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>

* CR fixes

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
2022-10-20 20:55:47 +01:00
Maya Rashish
7b7ca5fd17
Simplify test PVC creation & force-binding code (#2399)
* Remove unneeded WaitForPVC

This is redundant after calling ForceBindPvcIfDvIsWaitForFirstConsumer.
Done in cases where the return value of WaitForPVC was not used.

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

* Use the framework CreatePVCFromDefinition

That requires less argument-passing

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

* Use less code to get bound PVCs

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

* Don't return error on CreateBoundPVCFromDefinition

It's always nil as the function expects success.
Allows us to delete some error-checking paths.

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

Signed-off-by: Maya Rashish <mrashish@redhat.com>
2022-08-29 08:27:22 +01:00
Maya Rashish
81deac9fcf
Split up utils.go to logical divisions (#2310)
* Remove unused function PanicOnError

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

* Remove logic for skipping a test on old kubectl

1.14.0 is pretty old, assume a new enough kubectl is used now.
Simplify utils.go which has an elaborate function for detecting
the version used.

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

* Make functions private if they're only used in one file

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

* Move prometheus functions to tests/framework/prometheus.go

Split utils.go into meaningful filenames.
Framework was chosen because it uses framework things, and that
can't be done from utils without circular imports.

Make functions part of the framework struct wherever possible
to avoid needing to pass extra arguments.

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

* Move {Create,Run}KubectlCommand to framework

Allows moving more things away from tests/utils.go towards the goal
of eliminating it.

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

* Move CreateVddkWarmImportDataVolume into own file in framework

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

* Move node placement utils to a separate file in framework package

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

* Move WaitForConditions and associated functions to util

Pass it a ClientsIface instead of pulling in framework.

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

* Move pod log functions to framework/pod.go, delete tests/utils.go

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

* Fix typo

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

* Use CombinedOutput - shows stderr in the output unconditionally

Simplifies the code.

Signed-off-by: Maya Rashish <mrashish@redhat.com>
2022-07-04 10:48:40 +02:00
Arnon Gilboa
0b3900c60c
Garbage Collect Completed DVs (#2233)
* Garbage Collect Completed DVs

See design at:
https://github.com/kubevirt/community/blob/main/design-proposals/garbage-collect-completed-dvs.md

ToDos:
-DataImportCron and DataSource controllers adaptation and func tests
-Add doc for DataVolume, CDIConfig and DataImportCron changes
-Extend unit tests and functional tests
-KubeVirt adaptation

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>

* Controller minor fixes

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>

* Adapt tests to GC

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>

* Add DV mutate unit test for GC

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>

* Improve GC skip per annotation test

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>

* Use DescribeTable for the GC tests

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
2022-05-19 00:09:31 +02:00
Alexander Wels
f3e54f7a13
Catch changed rejection message (#2119)
Every once in a while the rejection message by kubectl is changed and it
causes failures in the test. This commit makes the check less strict so
it looks for the message output by our webhook, not the extra kubernetes
messsage as well.

Signed-off-by: Alexander Wels <awels@redhat.com>
2022-01-25 20:29:10 +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
Arnon Gilboa
f1fb79bba0
Add DataSource as an optional sourceRef for DataVolumes (#1851)
* Add DataSource as an optional sourceRef for DataVolumes

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>

* Add some sourceRef validation unit and functional tests

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>

* Add cloner functional test for SourceRef PVC DataSource

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>

* Add test_ids

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>

* Minor CR fixes

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>

* Add DV mutate utest

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
2021-07-14 16:56:34 +02:00
Arnon Gilboa
13275ce351
OS image poll and update API (#1808)
* Add CRD for DataSource definition

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>

* Add optional sourceRef to DataSource in DataVolumeSpec

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>

* Add CRD for DataImportCron definition

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>

* Add DataSource and DataImportCron generated files

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>

* Code review fixes

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>

* More code review fixes

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>

* Code genrated after rebase

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>

* Fix DV source reference in utests

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>

* Remove api validation tests for missing data volume source

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>

* Add standard fields to condition structs

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
2021-06-14 13:58:42 +02:00
Arnon Gilboa
35613d1cc6
Use semantic DeepEqual check on DV update (#1359)
Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
2020-09-17 15:23:26 +02:00
Matthew Arnold
dc6bad6473
Fill out VDDK data volume source. (#1320)
* Add support for a VDDK datasource to the controllers

This commit does not implement the VDDK datasource. It simply
adds the DataVolumeSourceVDDK type and adds support to the
datavolume and import controllers for it. The datasource itself
will need to be done in a follow-up.

Signed-off-by: Sam Lucidi <slucidi@redhat.com>

* Fix tests and clean up lint

Signed-off-by: Sam Lucidi <slucidi@redhat.com>

* Add DataVolumeSourceVDDK to the v1alpha1 api group

Signed-off-by: Sam Lucidi <slucidi@redhat.com>

* Install nbdkit.

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

* Add govmomi to vendor directory.

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

* Integrate govmomi into build.

Incomplete! This allows 'find' and 'object' imports from govmomi, but
further dependencies may require more bazel tweaks later.

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

* Create a container image just to hold the VDDK.

Mount the VDDK folder to /opt. Also copy the libxcrypt-compat RPM to
/opt for run-time installation as a temporary workaround for my
inability to install it at container creation time. Make VDDK optional
by storing a dummy file in its directory, so an empty VDDK directory
will not break the build.

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

* Fill in VDDK data source.

Add the simplest possible VDDK data source: set up an nbdkit server with
the given VMware parameters, and copy data out using qemu-img.

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

* Add vddk to resource validation schema.

Stops "error validating data" messages.

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

* Move libxcrypt-compat install out of VDDK image.

Requiring users to add this to the VDDK image is kind of onerous, so
move it straight into the importer image instead.

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

* Generate BUILD.bazel for the rest of govmomi.

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

* Get VDDK sidecar image from v2v-vmware ConfigMap.

Convention from https://github.com/kubevirt/web-ui-components/pull/534

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

* Reduce nbdkit startup timeout.

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

* Update govmomi dependencies.

Cleans up 'inconsistent vendoring' errors.

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

* Fix schema verification test.

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

* Change disk.raw to disk.img.

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

* Add vCenter simulator for VDDK datasource tests.

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

* Functional test with vcsim and dummy VDDK plugin.

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

* Clean up lint errors.

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

* Check kubevirt-hyperconverged namespace for VDDK.

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

* Add VDDK unit tests and API functional test.

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

* Read a raw image for VDDK test plugin.

Have the fake VDDK test plugin for nbdkit read a raw image passed in
/opt/updates/nbdtest.img instead of returning fixed data.

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

* Add some documentation about VDDK data sources.

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

* Remove unit test focus and trailing spaces.

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

* Use updated build container image.

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

* Add some extra comments about VDDK fields.

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

* Clarify VDDK ConfigMap a little more.

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

* Clarify namespace for vddk-init sidecar.

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

* Remove NodePort from vCenter simulator manifest.

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

* Re-word explanations on VDDK source types.

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

* Add VDDK to comment with types needing URL check.

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

* Rebuild types.

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

* Move AnnThumbprint to storage.import.vddk.thumbprint.

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

* Remove run-time installation of libxcrypt-compat.

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

* Remove fixed namespaces for vddk-init reference.

The importer now looks for the v2v-vmware ConfigMap in the current CDI
namespace instead of openshift-cnv/kubevirt-hyperconverged.

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

* Find CDI install namespace from data volume test.

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

Co-authored-by: Sam Lucidi <slucidi@redhat.com>
2020-09-11 23:37:22 +02:00
Michael Henriksen
75f4fd6f2f
update k8s deps to 18.6 and controller runtime to 0.6.2 (#1330)
* update k8s deps to 1.18.6 and controller runtime to 0.6.2

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

* remove building code generators from docker image.  This way the k8s ligray version only has to be updated in go.mod

Do more stuff in the bazel container.  Faster and better interop

Fix unit tests

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

* make format

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

* remove unnecessary rsync

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

* redo code generator dep management

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

* builder uses go modules

Signed-off-by: Michael Henriksen <mhenriks@redhat.com>
2020-08-07 14:09:52 +02:00
Alexander Wels
6dce12f090
Move CRDS from apiextensions v1beta1 to v1. (#1307)
* Move CRDS from apiextensions v1beta1 to v1.
Ensure that our code based schema validation matches the types in the api.

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

* Ran go mod tidy and vendor in attempt to see if we could use newer runtime controller, but our go version too old.
Addressed review comments.

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

* Addressed more review comments and fixed k8s-1.18 functional test failing.

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

* Remove categories 'all' from cluster scoped CRDs

Signed-off-by: Alexander Wels <awels@redhat.com>
2020-08-01 01:01:50 +02:00
Alexander Wels
c7a3610769
Update cdi-builder to use go version 1.14.6 (current latest) (#1310)
* Update cdi-builder to use go version 1.14.6 (current latest)
Fix functional test framework to work with go >= 1.13. We were not
using the ginkgo ordering correctly, and our framework would call
flag.Parse() too soon, and mess with the go testing flag parsing.
As a result we had to alter some of the variables that we use to build
urls to be functions so that when called the required information is
available.
Fixed several tests not checking for errors.
Fixed dumping code being initialized several times messing with the
order in which failures were reported.

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

* Fixed failing tests.

Signed-off-by: Alexander Wels <awels@redhat.com>
2020-07-23 23:09:44 +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
Alexander Wels
bdb079f7bf
Make sure all CDI crds have structural schemas (#1171)
* Make sure all CDI crds have structural schemas

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

* Removed unneeded apiVersion, Kind, Metadata from validation

Signed-off-by: Alexander Wels <awels@redhat.com>
2020-04-15 21:54:02 +02:00
Adam Litke
84cf68d926
Add missing test ids (#1161)
Signed-off-by: Adam Litke <alitke@redhat.com>
2020-03-27 22:19:48 +01:00
Piotr Kliczewski
78cee6d166
Imageio - new import data source (#1042)
This PR introduces new import data source to fetch disks from ovirt
and store them in storage available in the cluster. It uses ovirt-sdk
to check whether the this is there, the size of the disk and it obtains
signed ticket which allows to get the disk using ovirt-imageio-proxy.

In order to use it a user needs to create configmap with ovirt api
certificate and secret with ovirt engine user and password. Both are
required and validated by webhook. In order to start import process
we need to post following definition:

---
apiVersion: cdi.kubevirt.io/v1alpha1
kind: DataVolume
metadata:
  name: "imageio-dv"
spec:
  source:
      imageio:
         url: "<engine-api-endpoint>"
         secretRef: "<secret-name-containing-engine-credentials>"
         certConfigMap: "<configmap-name-containing-engine-api-certificate>"
         diskId: "<disk-id-which-we-want-to-import>"
  pvc:
    accessModes:
      - ReadWriteOnce
    resources:
      requests:
        storage: "64Mi"
---

Signed-off-by: Piotr Kliczewski <piotr.kliczewski@gmail.com>
2020-03-19 19:49:44 +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
Alexander Wels
f948406c54 Fix strings to check against in validation for k8s 1.16 (#1045)
Signed-off-by: Alexander Wels <awels@redhat.com>
2019-12-04 21:39:52 +01:00
Alexander Wels
e047b17c95 Update kubevirtci k8s version to 1.15.1
Signed-off-by: Alexander Wels <awels@redhat.com>
2019-08-15 08:24:34 -04:00
Michael Henriksen
e4fa647eea Clone permission refactoring (#906)
* allow user with 'create pod' permission in source namespace to clone PVCs also refactored Kubevirt interface to clone permission check

* make sure DataVolume spec is immutable also don't check perms when clone source namespace = dest namespace
2019-08-05 11:04:03 -04:00
Alexander Wels
6f64e40180 Add test case id to tests.
Signed-off-by: Alexander Wels <awels@redhat.com>
2019-05-22 08:46:17 -04:00
Alexander Wels
540602af96
Merge branch 'master' into fix_scorecard_issues 2019-05-07 10:16:42 -04:00
Alexander Wels
630a23ef23 Fix a bunch of go score card issues.
Signed-off-by: Alexander Wels <awels@redhat.com>
2019-05-06 16:52:03 -04:00
Alexander Wels
35da1c189b DataVolume api validation
Signed-off-by: Alexander Wels <awels@redhat.com>
2019-05-06 16:30:28 -04:00
Irit goihman
07a04b5635 add a better error message if pvc size is missing
Signed-off-by: Irit goihman <igoihman@redhat.com>
2019-04-15 13:47:53 +03:00
Irit goihman
5c799ed972 added pvc accessModes as a required field
Signed-off-by: Irit goihman <igoihman@redhat.com>
2019-04-01 14:57:01 +03:00
Alexander Wels
8667282fea
Merge branch 'master' into src-pvc-validation 2019-03-05 17:06:39 -05:00
Alexander Wels
1b3c07ffbe
Update api_validation_test.go 2019-03-05 13:49:27 -05:00
Kevin Alon Goldblatt
7b20bd3af6 API Validation - Added test attriutes to CNV-1759-1769 2019-03-03 17:50:56 +02:00
kgoldbla
be2221ced7
Update api_validation_test.go 2019-03-03 17:14:03 +02:00
kgoldbla
fc6f56b7b7
Update api_validation_test.go 2019-03-03 16:43:16 +02:00
Irit goihman
55e68502f9 add functional test for DataVolume validation using non existing source PVC
Signed-off-by: Irit goihman <igoihman@redhat.com>
2019-02-28 13:13:02 +02:00
Irit goihman
88ab1f526e DV with dest PVC already exists functional test
Signed-off-by: Irit goihman <igoihman@redhat.com>
2019-02-24 11:21:17 +02:00
Alexander Wels
feba93fa70 Add validation of content type and unit tests.
Signed-off-by: Alexander Wels <awels@redhat.com>
2019-01-24 14:52:22 -05:00
Nelly Credi
0c6e1ff6ae updated to [attr1][attr2][attr3] struct 2019-01-10 17:09:51 +02:00
Nelly Credi
0149a300c7 Add test attributes
Added rfe id, test id, criticality etc

Based on issue
https://github.com/kubevirt/containerized-data-importer/issues/359
2019-01-10 17:05:57 +02:00
Alexander Wels
8b27e695f0 Fix some functional test issues running locally.
Signed-off-by: Alexander Wels <awels@redhat.com>
2019-01-03 10:34:56 -05:00
Irit Goihman
d27e92a2a2 add API validation test
Signed-off-by: Irit Goihman <igoihman@redhat.com>
2018-12-18 14:33:45 +02:00