diff --git a/pkg/nova/celldelete.go b/pkg/nova/celldelete.go index 9ee45b727..dd8fbcf52 100644 --- a/pkg/nova/celldelete.go +++ b/pkg/nova/celldelete.go @@ -82,5 +82,9 @@ func CellDeleteJob( }, } + if cell.Spec.NodeSelector != nil && len(*cell.Spec.NodeSelector) > 0 { + job.Spec.Template.Spec.NodeSelector = *cell.Spec.NodeSelector + } + return job } diff --git a/pkg/nova/cellmapping.go b/pkg/nova/cellmapping.go index f7e58e93d..222ef15b8 100644 --- a/pkg/nova/cellmapping.go +++ b/pkg/nova/cellmapping.go @@ -82,5 +82,9 @@ func CellMappingJob( }, } + if cell.Spec.NodeSelector != nil && len(*cell.Spec.NodeSelector) > 0 { + job.Spec.Template.Spec.NodeSelector = *cell.Spec.NodeSelector + } + return job } diff --git a/pkg/nova/host_discover.go b/pkg/nova/host_discover.go index 7b8cd9d7a..05d9247ff 100644 --- a/pkg/nova/host_discover.go +++ b/pkg/nova/host_discover.go @@ -94,5 +94,9 @@ func HostDiscoveryJob( }, } + if instance.Spec.NodeSelector != nil && len(*instance.Spec.NodeSelector) > 0 { + job.Spec.Template.Spec.NodeSelector = *instance.Spec.NodeSelector + } + return job } diff --git a/pkg/novaconductor/dbpurge.go b/pkg/novaconductor/dbpurge.go index 15eb64a3d..c025102d5 100644 --- a/pkg/novaconductor/dbpurge.go +++ b/pkg/novaconductor/dbpurge.go @@ -95,5 +95,9 @@ func DBPurgeCronJob( }, } + if instance.Spec.NodeSelector != nil && len(*instance.Spec.NodeSelector) > 0 { + cron.Spec.JobTemplate.Spec.Template.Spec.NodeSelector = *instance.Spec.NodeSelector + } + return cron } diff --git a/pkg/novaconductor/dbsync.go b/pkg/novaconductor/dbsync.go index 078722c05..5d169aa9e 100644 --- a/pkg/novaconductor/dbsync.go +++ b/pkg/novaconductor/dbsync.go @@ -93,5 +93,10 @@ func CellDBSyncJob( }, }, } + + if instance.Spec.NodeSelector != nil && len(*instance.Spec.NodeSelector) > 0 { + job.Spec.Template.Spec.NodeSelector = *instance.Spec.NodeSelector + } + return job } diff --git a/test/functional/nova_reconfiguration_test.go b/test/functional/nova_reconfiguration_test.go index 60a4a0fda..4ef7c4481 100644 --- a/test/functional/nova_reconfiguration_test.go +++ b/test/functional/nova_reconfiguration_test.go @@ -333,14 +333,17 @@ var _ = Describe("Nova reconfiguration", func() { nova.Spec.NodeSelector = &newSelector g.Expect(k8sClient.Update(ctx, nova)).To(Succeed()) - novaDeploymentName := serviceNameFunc() - th.SimulateStatefulSetReplicaReady(cell0.ConductorStatefulSetName) - th.SimulateStatefulSetReplicaReady(novaDeploymentName) SimulateReadyOfNovaTopServices() + th.SimulateJobSuccess(cell1.DBSyncJobName) + th.SimulateJobSuccess(cell2.DBSyncJobName) - serviceDeployment := th.GetStatefulSet(novaDeploymentName) + serviceDeployment := th.GetStatefulSet(serviceNameFunc()) g.Expect(serviceDeployment.Spec.Template.Spec.NodeSelector).To(Equal(newSelector)) + g.Expect(th.GetJob(cell0.DBSyncJobName).Spec.Template.Spec.NodeSelector).To(Equal(newSelector)) + g.Expect(th.GetJob(cell1.DBSyncJobName).Spec.Template.Spec.NodeSelector).To(Equal(newSelector)) + g.Expect(th.GetJob(cell2.DBSyncJobName).Spec.Template.Spec.NodeSelector).To(Equal(newSelector)) + }, timeout, interval).Should(Succeed()) // Now reset it back to empty and see that it is propagates too @@ -353,10 +356,17 @@ var _ = Describe("Nova reconfiguration", func() { g.Expect(k8sClient.Update(ctx, nova)).To(Succeed()) serviceDeploymentName := serviceNameFunc() + th.SimulateJobSuccess(cell0.DBSyncJobName) + th.SimulateJobSuccess(cell1.DBSyncJobName) + th.SimulateJobSuccess(cell2.DBSyncJobName) th.SimulateStatefulSetReplicaReady(cell0.ConductorStatefulSetName) th.SimulateStatefulSetReplicaReady(serviceDeploymentName) serviceDeployment := th.GetStatefulSet(serviceDeploymentName) g.Expect(serviceDeployment.Spec.Template.Spec.NodeSelector).To(BeNil()) + + g.Expect(th.GetJob(cell0.DBSyncJobName).Spec.Template.Spec.NodeSelector).To(BeNil()) + g.Expect(th.GetJob(cell1.DBSyncJobName).Spec.Template.Spec.NodeSelector).To(BeNil()) + g.Expect(th.GetJob(cell2.DBSyncJobName).Spec.Template.Spec.NodeSelector).To(BeNil()) }, timeout, interval).Should(Succeed()) }, Entry("the nova api pods", @@ -403,8 +413,11 @@ var _ = Describe("Nova reconfiguration", func() { } g.Expect(k8sClient.Update(ctx, nova)).To(Succeed()) + th.SimulateJobSuccess(cell0.DBSyncJobName) th.SimulateStatefulSetReplicaReady(cell0.ConductorStatefulSetName) + th.SimulateJobSuccess(cell1.DBSyncJobName) th.SimulateStatefulSetReplicaReady(cell1.ConductorStatefulSetName) + th.SimulateJobSuccess(cell2.DBSyncJobName) th.SimulateStatefulSetReplicaReady(cell2.ConductorStatefulSetName) apiDeployment := th.GetStatefulSet(novaNames.APIStatefulSetName) @@ -420,6 +433,10 @@ var _ = Describe("Nova reconfiguration", func() { g.Expect(conductorDeployment.Spec.Template.Spec.NodeSelector).To(Equal(conductorSelector)) conductorDeployment = th.GetStatefulSet(cell2.ConductorStatefulSetName) g.Expect(conductorDeployment.Spec.Template.Spec.NodeSelector).To(BeNil()) + + g.Expect(th.GetJob(cell0.DBSyncJobName).Spec.Template.Spec.NodeSelector).To(Equal(conductorSelector)) + g.Expect(th.GetJob(cell1.DBSyncJobName).Spec.Template.Spec.NodeSelector).To(Equal(conductorSelector)) + g.Expect(th.GetJob(cell2.DBSyncJobName).Spec.Template.Spec.NodeSelector).To(BeNil()) }, timeout, interval).Should(Succeed()) SimulateReadyOfNovaTopServices() @@ -446,6 +463,10 @@ var _ = Describe("Nova reconfiguration", func() { g.Expect(conductorDeployment.Spec.Template.Spec.NodeSelector).To(Equal(conductorSelector)) conductorDeployment = th.GetStatefulSet(cell2.ConductorStatefulSetName) g.Expect(conductorDeployment.Spec.Template.Spec.NodeSelector).To(BeNil()) + + g.Expect(th.GetJob(cell0.DBSyncJobName).Spec.Template.Spec.NodeSelector).To(Equal(conductorSelector)) + g.Expect(th.GetJob(cell1.DBSyncJobName).Spec.Template.Spec.NodeSelector).To(Equal(conductorSelector)) + g.Expect(th.GetJob(cell2.DBSyncJobName).Spec.Template.Spec.NodeSelector).To(BeNil()) }, timeout, interval).Should(Succeed()) }) })