Commit Graph

53 Commits

Author SHA1 Message Date
Ido Aharon
5b687196d8
Delete old version DV's with DIC GC (#2749)
Signed-off-by: Ido Aharon <iaharon@redhat.com>
2023-09-11 14:53:04 +02:00
akalenyu
b67c6639e8
Avoid creating snapshot of old storage class DataImportCron PVCs (#2837)
* Play nice with storage class changes; don't attempt to create snapshot from old sc

Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>

* Make the DataImportCron format more visible via printed column on get

Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>

---------

Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>
2023-09-01 00:54:04 +02:00
Michael Henriksen
cc8dbc3bae
increase controller cuncurrency and cpu requests (#2862)
This commit ups the cpu request for for all our installed compopents
(cdi-deployment, cdi-apiserver, cdi-uploadproxy, cdi-operator)
for 10m (1% of a core) to 100m (10% of a core).
The main driver of this is BZ: 2216038.
Without this change, it is pretty easy to create a large number of
concurrent clone operations and get token timeout errors.
Upping resource requests and concurrency addresses the issue
in a very direct way.

Signed-off-by: Michael Henriksen <mhenriks@redhat.com>
2023-08-24 02:48:34 +02:00
Lee Yarwood
33358569bb
dataVolume: Add default instance type labels from source (#2787)
* dataVolume: Add default instance type labels from source

f229aeb started to pass default instance type labels from
DataImportCrons to DataVolumes and DataVolumes to any associated
destination DataSources or PVCs. As documented in issue #2782 this does
not however pass these labels from the initial source of a DataVolume to
either the DataVolume or the destination DataSources or PVCs

This change corrects this by updating DataVolumes when reconciled,
adding any labels found on PVC or DataSource sources. These labels will
then be passed on to the destination PVC or DataSources by the existing
functionality highlighted above.

Note that if any default instance type labels already exist on the
DataVolume then the process is skipped as it is assumed these are
provided either directly by the user or via a DataImportCron.

Signed-off-by: Lee Yarwood <lyarwood@redhat.com>

* refactor: Use DefaultInstanceTypeLabels more often

Signed-off-by: Lee Yarwood <lyarwood@redhat.com>

---------

Signed-off-by: Lee Yarwood <lyarwood@redhat.com>
2023-08-11 22:31:21 +02:00
Arnon Gilboa
96de8651b9
Fix DIC returned reconcile.Result for ImageStream (#2823)
regression introduced in #2700

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
2023-07-28 22:23:24 +02:00
akalenyu
6fd040a20a
[WIP] Handle nil ptr in dataimportcron controller (#2769)
Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>
2023-06-27 02:45:30 +02:00
Andrej Krejcir
b4c58d4a96
dataimportcron: Pass dynamic credential support label (#2760)
* dataimportcron: code change: Use better matchers in tests

Signed-off-by: Andrej Krejcir <akrejcir@redhat.com>

* dataimportcron: Pass dynamic credential support label

The label is passed from DataImportCron to DataVolume
and DataSource.

Signed-off-by: Andrej Krejcir <akrejcir@redhat.com>

---------

Signed-off-by: Andrej Krejcir <akrejcir@redhat.com>
2023-06-22 01:51:24 +02:00
Arnon Gilboa
0bc6a8aeca
Disable DV GC by default (#2754)
* Disable DV GC by default

DataVolume garbage collection is a nice feature, but unfortunately it
violates fundamental principle of Kubernetes. CR should not be
auto-deleted when it completes its role (Job with TTLSecondsAfter-
Finished is an exception), and once CR was created we can assume it is
there until explicitly deleted. In addition, CR should keep idempotency,
so the same CR manifest can be applied multiple times, as long as it is
a valid update (e.g. DataVolume validation webhook does not allow
updating the spec).

When GC is enabled, some systems (e.g GitOps / ArgoCD) may require a
workaround (DV annotation deleteAfterCompletion = "false") to prevent
GC and function correctly.

On the next kubevirt-bot Bump kubevirtci PR (with bump-cdi), it will
fail on all kubevirtci lanes with tests referring DVs, as the tests
IsDataVolumeGC() looks at CDIConfig Spec.DataVolumeTTLSeconds and
assumes default is enabled. This should be fixed there.

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

* Fix test waiting for PVC deletion with UID

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

* Fix clone test assuming DV was GCed

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

* Fix DIC controller DV/PVC deletion when snapshot is ready

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

---------

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
2023-06-20 21:09:19 +02:00
akalenyu
33c55a5560
Allow snapshots as format for DataImportCron created sources (#2700)
* StorageProfile API for declaring format of resulting cron disk images

Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>

* Integrate recommended format in dataimportcron controller

Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>

* Take snapclass existence into consideration when populating cloneStrategy and sourceFormat

Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>

---------

Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>
2023-06-08 17:29:01 +02:00
Ido Aharon
6205bbae0b
Enable empty schedule in DataImportCron (#2711)
Allow disabling DataImportCron schedule and support external trigger

Signed-off-by: Ido Aharon <iaharon@redhat.com>
2023-05-30 20:36:25 +02:00
Arnon Gilboa
41ba02d03c
DataImportCron dusty stuff cleanups (#2723)
-Remove obsoleted insecure registries ConfigMap
-Cleanup functests and add external poller test
-Remove irrelevant poller digest update check

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
2023-05-24 10:04:15 +02:00
Michael Henriksen
f88fab69dc
PVC Clone Populator (#2709)
* touch up zero restoresize snapshot

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

* clone populator

only supports PVC source now

snapshot coming soon

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

* more unit tests

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

* unit test for clone populator

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

* func tests for clone populator

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

* move clone populator cleanup function to planner

other review comments

verifier pod should bount readonly

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

* add readonly flag to test executor pods

synchronize get hash calls

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

* increase linter timeout

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

* better/explicit readonly support for test pods

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

* check pv for driver info before looking up storageclass as it may not exist

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

* addressed review comments

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

* chooseStrategy shoud generate more events

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

---------

Signed-off-by: Michael Henriksen <mhenriks@redhat.com>
2023-05-24 05:11:52 +02:00
Arnon Gilboa
813632f604
Propagate CDI workload NodePlacement to DIC CronJob and initial Job (#2712)
Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
2023-05-18 21:52:42 +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
Arnon Gilboa
fc7f855ec9
Annotate DIC-created DV for immediate binding (#2650)
If the storage class binding mode is WaitForFirstConsumer, and the
annotation was not explicitly added to the DIC DV template, the created DV
will get stuck in WFFC phase.

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
2023-03-22 03:25:02 +00:00
garonsky
4e3ee4c44d
Add support for imagePullSecrets (#2589)
* Add support for imagePullSecrets in the CDI CR, to support pulling
images from repositories that require secrets.

The imagePullSecrets is propagated to the following components: cdi-apiserver,
cdi-deployment, and cdi-uploadproxy. The definition of imagePullSecrets in
cdi-operator must be done manually.

Signed-off-by: Gleb Aronsky <gleb.aronsky@windriver.com>

* Modifying code to incorporate review comments.

Signed-off-by: Gleb Aronsky <gleb.aronsky@windriver.com>

---------

Signed-off-by: Gleb Aronsky <gleb.aronsky@windriver.com>
Co-authored-by: Gleb Aronsky <gleb.aronsky@windriver.com>
2023-03-18 01:41:35 +00:00
akalenyu
4c31a26603
Respect bind.immediate annotation by not attempting fancy clones (#2604)
* Fix hostpath CSI being skipped as "Not HPP"

Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>

* Fall back to host assisted if immediate bind requested

Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>

---------

Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>
2023-03-01 04:44:52 +01:00
Arnon Gilboa
d5b67e0ca4
Fix DataImportCron PVC timestamping (#2566)
DataImportCron PVC garbage collection is LRU-based, so it's broken when
PVCs are not timestamped.

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
2023-02-01 10:26:06 +01:00
Arnon Gilboa
fa691809bc
Update succeeded DIC PVC labels also when no DV GC (#2539)
Signed-off-by: Arnon Gilboa <agilboa@redhat.com>

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
2023-01-12 00:21:10 +00:00
Arnon Gilboa
3bf0223927
Set ttl for completed cron jobs (#2538)
Keeping the last completed or failed job and pod for a while is needed
for both functional tests and debugging. Since the ttl was not set, the
jobs were not automatically deleted.

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

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
2023-01-12 00:21:03 +00:00
Lee Yarwood
f229aeb5ff
dataimportcron: Pass KubeVirt instance type labels to DataVolume and DataSource (#2534)
* dataimportcron: Pass KubeVirt instance type labels to DataVolume and DataSource

Following on from 4fbcb2d509 a requirement
has arisen to expose the default instance type metadata previously
exposed as annotations also as labels to allow callers such as the UI to
have simple server side filtering of these resources.

The unreleased feature implementation in KubeVirt has now
switched to labels and so CDI should now do the same and pass through
the appropriate labels to the underlying resources.

Signed-off-by: Lee Yarwood <lyarwood@redhat.com>

* instancetype: Pass instance type labels from DataVolume to PVC

Unlike annotations not all labels are copied from a given DataVolume to
a PVC during an import. This change corrects this for instance type
labels ensuring they are passed down to the underlying PVC.

The associated constants are also moved into pkg/controller/common/util
to allow access from the DataImportCron and DataVolume controllers.

Signed-off-by: Lee Yarwood <lyarwood@redhat.com>

Signed-off-by: Lee Yarwood <lyarwood@redhat.com>
2023-01-10 17:54:53 +00:00
Lee Yarwood
4fbcb2d509
dataimportcron: Pass KubeVirt instance type annotations to DV and DS (#2490)
A recent design proposal within the KubeVirt community introduced the
idea of inferring the details of default instance type and preferences
from a given volume associated with a VirtualMachine [1]. The idea being
to further reduce the number of choices a user has to make to get a
bootable VirtualMachine to a single choice of a PVC.

This change aims to support this effort by allowing operators to
annotate the underlying DataVolumes, DataSources and PVCs at import time
through CDI by first annotating the initial DataImportCrons.

This is useful to users of CDI such as the KubeVirt SSP operator that
currently defines a number of DataImportCrons to pull in various boot
sources required by the KubeVirt common-templates project.

Both the DataVolume and DataSource associated with the DataImportCron
are annotated to allow KubeVirt to potentially avoid a deeper lookup of
the associated PVC when attempting to infer these defaults.

[1] https://github.com/kubevirt/community/blob/main/design-proposals/default-instancetypes-from-volumes.md

Signed-off-by: Lee Yarwood <lyarwood@redhat.com>

Signed-off-by: Lee Yarwood <lyarwood@redhat.com>
2023-01-04 15:00:47 +00:00
Arnon Gilboa
bfe30a8964
Split and refactor DV controller (#2483)
- Split the huge DV controller into smaller op-specific DV controllers -
  import, clone, upload
- Add common watch-adding function so each controller watches only its
  relevant DVs
- Refactor the common Reconcile() to use interface DataVolumeReconciler
  implemented by each controller
- Move all functions, structs, consts to the relevant controller
- Split the utests per controller

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

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
2022-12-22 01:03:15 +00:00
Arnon Gilboa
eef03584fb
Add DataImportCron CronJobs Proxy support (#2455)
* Add DataImportCron CronJobs Proxy support

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

* CR fixes

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

* Add cronjob env utest

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

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
2022-11-03 19:43:23 +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
Alexander Wels
89dee769c6
Add cron-job sa to scc (#2439)
* Add cron-job sa to scc

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

* Make sure user is added on upgrade

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

Signed-off-by: Alexander Wels <awels@redhat.com>
2022-09-29 22:56:44 +01: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
akalenyu
4d4ad12df5
Only list Ingresses/Routes in CDI namespace instead of cluster level (#2371)
* Only list Ingresses/Routes in CDI namespace instead of cluster level

Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>

* Change the way we initialize cache for cdi controller

This gives us flexibility to cache only exactly what we need.
The error that led me to this was that we were attempting to Watch()
Routes/Ingresses which is basically caching all namespaces. We only want to cache the CDI namespace for those.
Source/feature from https://github.com/kubernetes-sigs/controller-runtime/issues/1708

Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>
2022-08-01 22:12:47 +02:00
Alexander Wels
5554567cbb
Comply with restricted security context (#2331)
* Comply with restricted security context in kubernetes

Ensure CDI pods comply with the restricted security context as much as
possible (have to be root for nbdkit and block devices). Also cannot set
SeccompProfile since SCC won't allow us to set it.

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

* Changed path /var/local/all_certs to stay in /var

Signed-off-by: Alexander Wels <awels@redhat.com>
2022-07-08 18:47:50 +02:00
Arnon Gilboa
ea86148af0
Update DataImportCron CronJob when needed (#2316)
* Update DIC CronJob container image if needed

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

* CR fixes

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
2022-06-11 01:38:19 +03:00
Arnon Gilboa
ed4c5bf2e5
Reconcile DIC only if DataSource is not managed by another DIC (#2295)
* Reconcile DIC only if DataSource is not managed by another DIC

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

* CR fixes

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
2022-06-02 20:23:25 +03:00
Arnon Gilboa
50467a68be
Get rid of unnecessary DIC reconcile updates (#2294)
* Get rid of unnecessary DIC reconcile updates

Also fixed status.lastExecutionTimestamp to be the last polling time
as intended in the design, and not the last reconcile update time.

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

* Pass DIC last execution time by annotation

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
2022-05-27 15:19:38 +03: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
Arnon Gilboa
2ce82f441c
Fix DataImportCron watch race (#2238)
Watch UpdateFunc predicate is checking if ObjectNew has DataImportCron
label with value, while the request enqueue mapping function may refer
the old object before the label value was set, resulting it to pass a
reconcile.Request where Name is an empty string.

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
2022-04-15 00:18:28 +02:00
João Vilaça
1ad70c2ec2
Gather all metrics info in a single location (#2231)
* Gather all metrics info in a single location

Signed-off-by: João Vilaça <jvilaca@redhat.com>

* Add comments to exported monitoring vars

Signed-off-by: João Vilaça <jvilaca@redhat.com>
2022-04-13 01:46:19 +02:00
Arnon Gilboa
cebf78b7d9
Log UID of DataImportCron, DataSource & DataVolume (#2203)
* Log UID of DataImportCron, DataSource & DataVolume

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

* CR fixes

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
2022-03-25 11:33:20 +01:00
Arnon Gilboa
d4a850468b
Delete erroneous DataVolume on DataImportCron desired digest update (#2169)
* Delete erroneous DV on DIC desired digest update

When a DataImportCron import DV is condition Running=False with
Reason=Error it indicates this DIC might get stuck with this DV forever,
so no new import DVs will be created even if the source sha256 is
updated. With this change, when digest is updated, before creating the
new DV, we simply delete the erroneous DV if necessary.

Also includes some DataImportCron tests improvements and cleanup.

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

* CR fixes

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

* Fix flaky tests

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

* More CR fixes

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
2022-03-01 23:04:12 +01:00
Arnon Gilboa
0ee4a61987
Get rid of DataImportCron finalizer (#2144)
* Get rid of DataImportCron finalizer

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

* Remove CRDs deletion in operator deletion

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

* CR fixes

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

* Cleanups

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
2022-02-12 05:56:08 +01:00
Arnon Gilboa
307b07532e
Reconcile DataSource PVC if managed by DIC (#2142)
Update DataSource only if it has a DataImportCron label

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
2022-02-09 17:13:50 +01:00
akalenyu
eb9fafe4ab
Replace batch/v1beta with v1 (#2131)
As CronJob v1beta is being deprecated in 1.25, we'd like to replace usages of it with v1:
https://kubernetes.io/docs/reference/using-api/deprecation-guide/#cronjob-v125

Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>
2022-02-01 14:22:04 +01:00
Arnon Gilboa
472c38e657
Fix CRDs deletion in operator deletion (#2129)
* Fix CRDs deletion in operator deletion

Also check DataImportCron CRD has no DeletionTimestamp before adding a
finalizer

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

* CR fixes

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
2022-01-28 16:13:09 +01:00
Arnon Gilboa
81fa12ed38
Add DataImportCron ImageStream tag support (#2117)
* Add DataImportCron ImageStream tag support

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

* Fix storageClass possible nil deref

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

* Change DataSource indexer key separator

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

* Add DataImportCron ImageStream tag utest

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

* CR fixes

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
2022-01-25 13:05:05 +01:00
Arnon Gilboa
2efe105178
Remove DataImportCron CDI labeling (#2099)
The following labels should be set by the operator that creates the
resource, and not by the DataImportCron controller, otherwise it may
result an unnecessary reconciliation and a race-condition.

app.kubernetes.io/component
app.kubernetes.io/managed-by

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
2022-01-17 21:33:16 +01:00
Arnon Gilboa
97288e3c5c
Cleanup DataImportCron jobs on deletion (#2088)
* Cleanup DataImportCron jobs on deletion

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

* CR fixes

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

* Func test fixes

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
2022-01-12 21:10:05 +01:00
Arnon Gilboa
39803bc33b
Remove tag from DataImportCron registry source URL (#2086)
* Remove tag from DataImportCron registry source URL

There are cases when DataImportCron registry source URL contains tag
referring a specific version. We use this tagged URL when polling for
source updates, but on import we would like to remove the tag as we use
a specific sha256. E.g. for docker://quay.io/containerdisks/centos:8.4
the :8.4 tag will be removed.

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

* Use Docker reference parsing

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
2022-01-11 17:58:50 +01:00
Arnon Gilboa
d77abc3fa9
Add DataSource controller to update the Ready condition (#2085)
even when there is no DataImportCron associated

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
2022-01-06 21:06:23 +01:00
Arnon Gilboa
abb0c7f508
Use existing DataVolume on DataImportCron source digest match (#2075)
* Use existing DV on DataImportCron source digest match

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

* Add short names for DataImportCron and DataSource

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
2022-01-03 17:27:13 +01:00
akalenyu
3bff27dd43
Add alert for DataImportCron not being up to date (#2063)
* Add alert for DataImportCron failing

DataImportCrons now have conditions (particularly UpToDate) that tell us if
things are going as planned. We can utilize those to alert whenever were not UpToDate for a while.

Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>

* Address CR review; don't List, increment when needed via corresponding instance

Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>

* Address review & bugfix: don't update metric if err occurs

Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>

* upToDateCondition => prevUpToDateCondition so it's clear we're deciding if we should inc/dec based on that

Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>

* Don't store state in controller; change metric type to GaugeVec (bool metric per DIC)

Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>
2021-12-24 01:10:52 +01:00
Arnon Gilboa
4ef4b20cbf
On CDI delete validation ignore DVs labeled with DataImportCron (#2066)
Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
2021-12-21 21:18:43 +01:00
Arnon Gilboa
fe018f1dc5
Add DataImportCron status conditions (#2045)
* Add DataImportCron status conditions

The `DataImportCron` controller updates the status conditions in a
controlled `DataImportCron` and its managed `DataSource`.

DataImportCron:
- UpToDate - indicates if the the most recent import is successful and
    `DataSource` is up-to-date. Updated to False whenever the source
     digest (latest sha256) is updated.
- Progressing - indicates whether the cron is currently in the process
    of importing. Updated to True if there is a current import and its
    `DataVolume` is `ImportInProgress`, otherwise False.

DataSource:
- Ready - indicates that the corresponding pvc exists and is populated.
    Update according to `DataImportCron.Status.LastImportedPVC`
    `DataVolume`'s `DataVolumeReady` condition, if the `DataVolume`
    exists. Otherwise False. Unlike `DataImportCron` `UpToDate`
    condition, this one does not care about newer source digest.

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

* CR fixes

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

* Add DataImportCron RetentionPolicy and remove OwnerReferences

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

* More CR fixes

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

* Add tests for retention policies and datasource/datavolume recreation if deleted

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

* Add status condition tests

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

* SetRecommendedLabels for all created CRs

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
2021-12-16 02:21:01 +01:00