-
Notifications
You must be signed in to change notification settings - Fork 254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Propagate CDI workload NodePlacement to DIC CronJob and initial Job #2712
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -312,6 +312,72 @@ var _ = Describe("All DataImportCron Tests", func() { | |
verifyCronJobContainerImage("new-image") | ||
}) | ||
|
||
It("Should update CronJob Pod workload NodePlacement on reconcile", func() { | ||
cron = newDataImportCron(cronName) | ||
reconciler = createDataImportCronReconciler(cron) | ||
|
||
_, err := reconciler.Reconcile(context.TODO(), cronReq) | ||
Expect(err).ToNot(HaveOccurred()) | ||
|
||
cronjob := &batchv1.CronJob{} | ||
err = reconciler.client.Get(context.TODO(), cronJobKey(cron), cronjob) | ||
Expect(err).ToNot(HaveOccurred()) | ||
spec := &cronjob.Spec.JobTemplate.Spec.Template.Spec | ||
spec.NodeSelector = map[string]string{"some": "thing"} | ||
spec.Tolerations = []corev1.Toleration{{Key: "another", Value: "value"}} | ||
err = reconciler.client.Update(context.TODO(), cronjob) | ||
Expect(err).ToNot(HaveOccurred()) | ||
|
||
workloads := updateCdiWithTestNodePlacement(reconciler.client) | ||
|
||
_, err = reconciler.Reconcile(context.TODO(), cronReq) | ||
Expect(err).ToNot(HaveOccurred()) | ||
|
||
err = reconciler.client.Get(context.TODO(), cronJobKey(cron), cronjob) | ||
Expect(err).ToNot(HaveOccurred()) | ||
podSpec := cronjob.Spec.JobTemplate.Spec.Template.Spec | ||
Expect(podSpec.Affinity).To(Equal(workloads.Affinity)) | ||
Expect(podSpec.NodeSelector).To(Equal(workloads.NodeSelector)) | ||
Expect(podSpec.Tolerations).To(Equal(workloads.Tolerations)) | ||
}) | ||
|
||
It("Should set initial Job Pod workload NodePlacement on reconcile", func() { | ||
cron = newDataImportCron(cronName) | ||
reconciler = createDataImportCronReconciler(cron) | ||
|
||
workloads := updateCdiWithTestNodePlacement(reconciler.client) | ||
|
||
_, err := reconciler.Reconcile(context.TODO(), cronReq) | ||
Expect(err).ToNot(HaveOccurred()) | ||
|
||
job := &batchv1.Job{} | ||
jobKey := types.NamespacedName{Name: GetInitialJobName(cron), Namespace: reconciler.cdiNamespace} | ||
err = reconciler.client.Get(context.TODO(), jobKey, job) | ||
Expect(err).ToNot(HaveOccurred()) | ||
podSpec := job.Spec.Template.Spec | ||
Expect(podSpec.Affinity).To(Equal(workloads.Affinity)) | ||
Expect(podSpec.NodeSelector).To(Equal(workloads.NodeSelector)) | ||
Expect(podSpec.Tolerations).To(Equal(workloads.Tolerations)) | ||
}) | ||
|
||
It("Should not modify new CronJob on initCronJob", func() { | ||
cron = newDataImportCron(cronName) | ||
reconciler = createDataImportCronReconciler(cron) | ||
|
||
_, err := reconciler.Reconcile(context.TODO(), cronReq) | ||
Expect(err).ToNot(HaveOccurred()) | ||
|
||
cronJob := &batchv1.CronJob{} | ||
err = reconciler.client.Get(context.TODO(), cronJobKey(cron), cronJob) | ||
Expect(err).ToNot(HaveOccurred()) | ||
|
||
cronJobCopy := cronJob.DeepCopy() | ||
err = reconciler.initCronJob(cron, cronJobCopy) | ||
Expect(err).ToNot(HaveOccurred()) | ||
|
||
Expect(cronJob).To(Equal(cronJobCopy)) | ||
}) | ||
|
||
It("Should create DataVolume on AnnSourceDesiredDigest annotation update, and update DataImportCron and DataSource on DataVolume Succeeded", func() { | ||
cron = newDataImportCron(cronName) | ||
dataSource = nil | ||
|
@@ -690,7 +756,7 @@ func createDataImportCronReconciler(objects ...runtime.Object) *DataImportCronRe | |
|
||
func createDataImportCronReconcilerWithoutConfig(objects ...runtime.Object) *DataImportCronReconciler { | ||
crd := &extv1.CustomResourceDefinition{ObjectMeta: metav1.ObjectMeta{Name: "dataimportcrons.cdi.kubevirt.io"}} | ||
objs := []runtime.Object{crd} | ||
objs := []runtime.Object{crd, cc.MakeEmptyCDICR()} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe unit test that existing cronjob (carry over from upgrade etc) gets reconciled with placement values? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added |
||
objs = append(objs, objects...) | ||
|
||
s := scheme.Scheme | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see you got rid of all the SDK merging utils - are we ok with that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the concern is that the deepequal will be false most of the time due to status changes/omitted spec fields
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for the SDK merging utils. Regarding the
DeepEqual
you were right. Fixed that.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to DeepEqual the spec instead of the entire object? Or are the annotations/labels we are interested in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We DeepEqual the whole object as we are intersted also in annotations/labels which may update on new version. Our CronJobs are not reconciled that often, so it won't cost too much to be on the safe side.