Commit Graph

14 Commits

Author SHA1 Message Date
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
Arnon Gilboa
a7e6c7036d
Enable DataImportCron garbageCollect by default (#2034)
Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
2021-12-01 04:30:31 +01:00
Arnon Gilboa
4c38190f53
Add initial import before cron schedule (#2040)
Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
2021-11-30 13:55:33 +01:00
Arnon Gilboa
7087b57cd2
Add DataImportCron controller (#1949)
* Add DataImportCron controller

-The new controller polls for updates to a registry source container
image, based on a given schedule. When updates to a container image are
detected, the controller imports the content into a new uniquely named
PVC in a golden image namespace.
-For each DataImportCron, the controller manages a corresponding
DataSource to always point to the latest most up-to-date golden
image PVC.
-DataImportCron takes ownership of an existing DataSource (with
controller: false), allowing an admin to opt-in to using auto
delivery/updates later on.
-The controller has PVC garbage collector removing old PVCs.

ToDo:
-status conditions updates
-verify full image streams support
-utests and func tests
-fixmes and commented out code
-doc

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

* Fix CR comments and fixmes

- isolate imagestream and registry specific code
- fix namespace of CronJob, and its job and pod to CDI namespace
- manage CronJob-DataImportCron ownership relationship with a finalizer,
  handle DataImportCron deletion (CronJob etc.)
- remove CronJob and job pod for ImageStreams, use RequeueAfter and
  cronexpr instead
- add k8s app cdi-source-update-poller executed by CronJob to poll source
  image digest via skopeo inspect for url registry source, and annotate
  the DataImportCron when the image was updated and pending for import based
  on the cron schedule
- add cdi-source-update-poller and skopeo binary to the cdi-importer container
- complete dataimportcron-validate and its tests
- reconcile - use context.Context instead of context.TODO
- remove uncached client
- doc

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

* Fix ImageStreams watch

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

* Add DataImportCron DV template instead of source

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

* Fix CR comments

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

* Split updateSucceeded func

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

* Improve cdi-source-update-poller cmd logs

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

* Remove ImageStream reconcile

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

* Remove ImageStream watch

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

* Remove unnecessary AnnSourceUpdatePending

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

* More CR fixes

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

* Idempotentify initCron

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

* Recreate DV in case is't not found

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

* Add DataImportCron spec.importsToKeep and status.currentImports

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

* Add DataImportCron controller functional test

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

* Add insecure TLS support

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

* Remove finalizers in cluster clean script

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

* Bound each import to its sha256 digest instead of latest

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

* Add DataImportCron controller utests

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

* Tests CR fixes

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

* Minor tests CR fixes

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
2021-11-11 20:09:48 +01:00