Description of problem: If dataSource creation fails (e.g name is too long), dataImportCron status does not provide any information Version-Release number of selected component (if applicable): CDI v4.10.0-89 How reproducible: 100% Steps to Reproduce: 1. Add custom DataImportCron to HCO with a long name (name+ns > 63 characters) 2. 3. Actual results: DataImportCron is created but dataSource is not created. There's no indication in DataImportCron about the failure Expected results: DataImportCron status should provide information about the failure Additional info: ============== Added DataImportCron to HCO ================ dataImportCronTemplates: - metadata: annotations: cdi.kubevirt.io/storage.bind.immediate.requested: "true" name: data-import-cron-with-non-existing-source spec: managedDataSource: non-existing-url-data-source retentionPolicy: None schedule: '* * * * *' template: spec: source: registry: pullMethod: node url: docker://non-existing-url storage: resources: requests: storage: 10Gi ============== DataImportCron ================ $ oc get dic -n openshift-virtualization-os-images data-import-cron-with-non-existing-source -oyaml apiVersion: cdi.kubevirt.io/v1beta1 kind: DataImportCron metadata: annotations: cdi.kubevirt.io/storage.bind.immediate.requested: "true" operator-sdk/primary-resource: openshift-cnv/ssp-kubevirt-hyperconverged operator-sdk/primary-resource-type: SSP.ssp.kubevirt.io creationTimestamp: "2022-02-15T16:40:44Z" generation: 1 labels: app.kubernetes.io/component: templating app.kubernetes.io/managed-by: ssp-operator app.kubernetes.io/name: data-sources app.kubernetes.io/part-of: hyperconverged-cluster app.kubernetes.io/version: 4.10.0 name: data-import-cron-with-non-existing-source namespace: openshift-virtualization-os-images resourceVersion: "3025492" uid: 2e690d84-3b2a-4c2c-8f53-4754e07d5abd spec: managedDataSource: non-existing-url-data-source retentionPolicy: None schedule: '* * * * *' template: metadata: {} spec: source: registry: pullMethod: node url: docker://non-existing-url storage: resources: requests: storage: 10Gi status: {} status: {} $ ============== cdi-deployment log ================ {"level":"error","ts":1644938729.9672325,"logger":"controller.dataimportcron-controller","msg":"Reconciler error","name":"data-import-cron-with-non-existing-source","namespace":"openshift-virtualization-os-images","error":"CronJob.batch \"data-import-cron-with-non-existing-source-49454b5a\" is invalid: metadata.labels: Invalid value: \"openshift-virtualization-os-images.data-import-cron-with-non-existing-source\": must be no more than 63 characters","stacktrace":"sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\n\t/remote-source/app/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:266\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2\n\t/remote-source/app/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:227"}
There are two aspects for this: 1. we should report dataimportcron conditions of this kind 2. we should use a hashing when naming the datasource, similar to the datavolume controller creates the PVC
(In reply to Yan Du from comment #1) > There are two aspects for this: > 1. we should report dataimportcron conditions of this kind > 2. we should use a hashing when naming the datasource, similar to the > datavolume controller creates the PVC This cannot be done; common templates refer to given dataSource names. This is why dataSources were introduced - a resource with a static name which dynamically points to a PVC (which can be replaced)
The names and labels length issue is already covered by bz 2046686 fix for 4.10.1: https://github.com/kubevirt/containerized-data-importer/pull/2220/commits/715fed8bb82974472603a839abd0cb37008d4512#diff-786a9fcaa47bbf5a42fae757e2e41d06f646e2e8b778e9c17a6ab595ef9a52fbL824-R890
Test on CNV-v4.10.1-62, got below error after set custom dataimportcron: {"level":"error","ts":1649760447.0815444,"logger":"controller.dataimportcron-controller","msg":"Reconciler error","name":"","namespace":"openshift-virtualization-os-images","error":"values[0][cdi.kubevirt.io/dataImportCron]: Invalid value: \"openshift-virtualization-os-images.\": a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue', or 'my_value', or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')","errorCauses":[{"error":"values[0][cdi.kubevirt.io/dataImportCron]: Invalid value: \"openshift-virtualization-os-images.\": a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue', or 'my_value', or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')"}],"stacktrace":"sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\n\t/remote-source/app/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:266\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2\n\t/remote-source/app/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:227"}
Updated fixed in version to a bundle including PR 2239
Test on CNV v4.10.1-78, issue has been fixed.
Need to retest on the build contains PR 2249
Verified on CNV-v4.10.1-101
We can see some recurring Reconciler error in cdi deployment pod after adding custom dataimportcron to hco till the import finished. Talked with Arnon, since it doesn't affect the import function, let's track the issue in #2083039
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory (Moderate: OpenShift Virtualization 4.10.1 Images security and bug fix update), and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHSA-2022:4668