From 1a349e3a15cac2646eaa67ad6d49773d5f7a89f8 Mon Sep 17 00:00:00 2001 From: Oliver Walsh Date: Mon, 18 Nov 2024 16:27:28 +0000 Subject: [PATCH] Pass-through empty nodeSelector to podSpecs There is no need drop empty nodeSelector maps, omitempty already does this --- pkg/keystone/bootstrap.go | 2 +- pkg/keystone/cronjob.go | 2 +- pkg/keystone/dbsync.go | 2 +- pkg/keystone/deployment.go | 4 +++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/keystone/bootstrap.go b/pkg/keystone/bootstrap.go index 381bdfde..ae99440d 100644 --- a/pkg/keystone/bootstrap.go +++ b/pkg/keystone/bootstrap.go @@ -117,7 +117,7 @@ func BootstrapJob( } job.Spec.Template.Spec.Containers[0].Env = env.MergeEnvs(job.Spec.Template.Spec.Containers[0].Env, envVars) - if instance.Spec.NodeSelector != nil && len(*instance.Spec.NodeSelector) > 0 { + if instance.Spec.NodeSelector != nil { job.Spec.Template.Spec.NodeSelector = *instance.Spec.NodeSelector } diff --git a/pkg/keystone/cronjob.go b/pkg/keystone/cronjob.go index 778e4a28..7036bac6 100644 --- a/pkg/keystone/cronjob.go +++ b/pkg/keystone/cronjob.go @@ -98,7 +98,7 @@ func CronJob( }, }, } - if instance.Spec.NodeSelector != nil && len(*instance.Spec.NodeSelector) > 0 { + if instance.Spec.NodeSelector != nil { cronjob.Spec.JobTemplate.Spec.Template.Spec.NodeSelector = *instance.Spec.NodeSelector } return cronjob diff --git a/pkg/keystone/dbsync.go b/pkg/keystone/dbsync.go index 0bd562a9..cacfbb79 100644 --- a/pkg/keystone/dbsync.go +++ b/pkg/keystone/dbsync.go @@ -90,7 +90,7 @@ func DbSyncJob( }, } - if instance.Spec.NodeSelector != nil && len(*instance.Spec.NodeSelector) > 0 { + if instance.Spec.NodeSelector != nil { job.Spec.Template.Spec.NodeSelector = *instance.Spec.NodeSelector } diff --git a/pkg/keystone/deployment.go b/pkg/keystone/deployment.go index 37cec1d1..c5fdecfd 100644 --- a/pkg/keystone/deployment.go +++ b/pkg/keystone/deployment.go @@ -158,8 +158,10 @@ func Deployment( }, corev1.LabelHostname, ) - if instance.Spec.NodeSelector != nil && len(*instance.Spec.NodeSelector) > 0 { + + if instance.Spec.NodeSelector != nil { deployment.Spec.Template.Spec.NodeSelector = *instance.Spec.NodeSelector } + return deployment, nil }