Skip to content

Commit 7469baf

Browse files
kubevirt-botAcedus
andauthored
dataimportcron: add nodeSelector when architecture is specified (#3908)
For pullMethod: node imports, the poller pod that's created lacked an architecture nodeSelector in the event that an architecture specific import was required. Signed-off-by: Adi Aloni <[email protected]> Co-authored-by: Adi Aloni <[email protected]>
1 parent ced8382 commit 7469baf

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

pkg/controller/dataimportcron-controller.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,10 @@ func (r *DataImportCronReconciler) updateContainerImageDesiredDigest(ctx context
657657
if err != nil {
658658
return false, err
659659
}
660+
platform := cron.Spec.Template.Spec.Source.Registry.Platform
661+
if platform != nil && platform.Architecture != "" {
662+
workloadNodePlacement.NodeSelector[corev1.LabelArchStable] = platform.Architecture
663+
}
660664

661665
containerImage := strings.TrimPrefix(*cron.Spec.Template.Spec.Source.Registry.URL, "docker://")
662666

tests/dataimportcron_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,27 @@ var _ = Describe("DataImportCron", Serial, func() {
436436
waitForDigest()
437437
})
438438

439+
It("Should add an appropriate node selector to poller when specfiying architecture with pullMethod node", func() {
440+
By("Create DataImportCron with only initial poller job")
441+
cron = utils.NewDataImportCron(cronName, "1Gi", scheduleOnceAYear, dataSourceName, importsToKeep, *reg)
442+
retentionPolicy := cdiv1.DataImportCronRetainNone
443+
cron.Spec.RetentionPolicy = &retentionPolicy
444+
cron.Spec.Template.Spec.Source.Registry.Platform = &cdiv1.PlatformOptions{Architecture: "test"}
445+
446+
cron, err := f.CdiClient.CdiV1beta1().DataImportCrons(ns).Create(context.TODO(), cron, metav1.CreateOptions{})
447+
Expect(err).ToNot(HaveOccurred())
448+
449+
By("Ensuring that nodeSelector was added")
450+
pollerPodName := fmt.Sprintf("poller-%s-%s", cron.Name, cron.UID[:8])
451+
Eventually(func() bool {
452+
pollerPod, err := f.K8sClient.CoreV1().Pods(cron.Namespace).Get(context.TODO(), pollerPodName, metav1.GetOptions{})
453+
if err != nil {
454+
return false
455+
}
456+
return pollerPod.Spec.NodeSelector[corev1.LabelArchStable] == "test"
457+
}, dataImportCronTimeout, pollInterval).Should(BeTrue())
458+
})
459+
439460
It("[test_id:10360] Should allow an empty schedule to trigger an external update to the source", func() {
440461
configureStorageProfileResultingFormat(cdiv1.DataImportCronSourceFormatPvc)
441462

0 commit comments

Comments
 (0)