From afeaf29c2d9e380feb7b4bc263817dcb10210846 Mon Sep 17 00:00:00 2001 From: Oliver Walsh Date: Thu, 21 Nov 2024 10:38:13 +0000 Subject: [PATCH 01/14] Inherit top-level nodeSelector in dnsmasq, memcache, redis template --- apis/bases/core.openstack.org_openstackcontrolplanes.yaml | 4 ++++ apis/go.mod | 2 +- apis/go.sum | 4 ++-- .../bases/core.openstack.org_openstackcontrolplanes.yaml | 4 ++++ go.mod | 2 +- go.sum | 4 ++-- pkg/openstack/dnsmasq.go | 7 ++++--- pkg/openstack/memcached.go | 4 ++++ pkg/openstack/redis.go | 4 ++++ 9 files changed, 26 insertions(+), 9 deletions(-) diff --git a/apis/bases/core.openstack.org_openstackcontrolplanes.yaml b/apis/bases/core.openstack.org_openstackcontrolplanes.yaml index 2e422fae9..9a0cc4db8 100644 --- a/apis/bases/core.openstack.org_openstackcontrolplanes.yaml +++ b/apis/bases/core.openstack.org_openstackcontrolplanes.yaml @@ -14703,6 +14703,10 @@ spec: templates: additionalProperties: properties: + nodeSelector: + additionalProperties: + type: string + type: object replicas: default: 1 format: int32 diff --git a/apis/go.mod b/apis/go.mod index ea3c1c380..886ec52a8 100644 --- a/apis/go.mod +++ b/apis/go.mod @@ -13,7 +13,7 @@ require ( github.com/openstack-k8s-operators/glance-operator/api v0.5.1-0.20241120062804-89e9fe93e886 github.com/openstack-k8s-operators/heat-operator/api v0.5.1-0.20241120140156-1c476cfe7c63 github.com/openstack-k8s-operators/horizon-operator/api v0.5.1-0.20241119161147-c38568cb3fb0 - github.com/openstack-k8s-operators/infra-operator/apis v0.5.1-0.20241118112815-d52a058b34a8 + github.com/openstack-k8s-operators/infra-operator/apis v0.5.1-0.20241120235143-b225194fd0fd github.com/openstack-k8s-operators/ironic-operator/api v0.5.1-0.20241114211630-5b4dcbed9b37 github.com/openstack-k8s-operators/keystone-operator/api v0.5.1-0.20241119162247-18b741090348 github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20241114091812-6dc9fd0961dc diff --git a/apis/go.sum b/apis/go.sum index 12db59525..d35a5eef6 100644 --- a/apis/go.sum +++ b/apis/go.sum @@ -106,8 +106,8 @@ github.com/openstack-k8s-operators/heat-operator/api v0.5.1-0.20241120140156-1c4 github.com/openstack-k8s-operators/heat-operator/api v0.5.1-0.20241120140156-1c476cfe7c63/go.mod h1:PuXjq4bV3/mYo4OAD/4tTon0N7E9YYXZHWiZLeZFVek= github.com/openstack-k8s-operators/horizon-operator/api v0.5.1-0.20241119161147-c38568cb3fb0 h1:YtC+hqGKx9M8B6fHgA1eFlq1yjEiOWwp1zZqyFtjSbA= github.com/openstack-k8s-operators/horizon-operator/api v0.5.1-0.20241119161147-c38568cb3fb0/go.mod h1:ezxV+6xd12IRKespGaDlJCUQ301yxrBlQUCEbeYQgSA= -github.com/openstack-k8s-operators/infra-operator/apis v0.5.1-0.20241118112815-d52a058b34a8 h1:mmnunGX3tnIT4ErxFjYcKb38VLjnfe9JcIcU9LaW9rE= -github.com/openstack-k8s-operators/infra-operator/apis v0.5.1-0.20241118112815-d52a058b34a8/go.mod h1:6x5zgJJBjrOhsTtNALYrM2ecUH92kIoZbZ6w1fKHPfs= +github.com/openstack-k8s-operators/infra-operator/apis v0.5.1-0.20241120235143-b225194fd0fd h1:6LmBamNQRwX76TiR+qo7Ejkb5bT2IPFhstkTWtVh7m4= +github.com/openstack-k8s-operators/infra-operator/apis v0.5.1-0.20241120235143-b225194fd0fd/go.mod h1:6x5zgJJBjrOhsTtNALYrM2ecUH92kIoZbZ6w1fKHPfs= github.com/openstack-k8s-operators/ironic-operator/api v0.5.1-0.20241114211630-5b4dcbed9b37 h1:k++YKQetyZqG6t+kWLhVUclgwLRKspCEyxeEWCeDgjM= github.com/openstack-k8s-operators/ironic-operator/api v0.5.1-0.20241114211630-5b4dcbed9b37/go.mod h1:nKeZBXFCwbYxTpIW9mPs/SK+4cODkEZgs+yOytvafBo= github.com/openstack-k8s-operators/keystone-operator/api v0.5.1-0.20241119162247-18b741090348 h1:mJeXL6JpNWe7d8wA8UZ1EI5T70f8HIgE2ecNjfPFIq4= diff --git a/config/crd/bases/core.openstack.org_openstackcontrolplanes.yaml b/config/crd/bases/core.openstack.org_openstackcontrolplanes.yaml index 2e422fae9..9a0cc4db8 100644 --- a/config/crd/bases/core.openstack.org_openstackcontrolplanes.yaml +++ b/config/crd/bases/core.openstack.org_openstackcontrolplanes.yaml @@ -14703,6 +14703,10 @@ spec: templates: additionalProperties: properties: + nodeSelector: + additionalProperties: + type: string + type: object replicas: default: 1 format: int32 diff --git a/go.mod b/go.mod index f76eeba6a..0bc0f867e 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/openstack-k8s-operators/glance-operator/api v0.5.1-0.20241120062804-89e9fe93e886 github.com/openstack-k8s-operators/heat-operator/api v0.5.1-0.20241120140156-1c476cfe7c63 github.com/openstack-k8s-operators/horizon-operator/api v0.5.1-0.20241119161147-c38568cb3fb0 - github.com/openstack-k8s-operators/infra-operator/apis v0.5.1-0.20241118112815-d52a058b34a8 + github.com/openstack-k8s-operators/infra-operator/apis v0.5.1-0.20241120235143-b225194fd0fd github.com/openstack-k8s-operators/ironic-operator/api v0.5.1-0.20241114211630-5b4dcbed9b37 github.com/openstack-k8s-operators/keystone-operator/api v0.5.1-0.20241119162247-18b741090348 github.com/openstack-k8s-operators/lib-common/modules/ansible v0.5.0 diff --git a/go.sum b/go.sum index 6c0922920..048c9310f 100644 --- a/go.sum +++ b/go.sum @@ -112,8 +112,8 @@ github.com/openstack-k8s-operators/heat-operator/api v0.5.1-0.20241120140156-1c4 github.com/openstack-k8s-operators/heat-operator/api v0.5.1-0.20241120140156-1c476cfe7c63/go.mod h1:PuXjq4bV3/mYo4OAD/4tTon0N7E9YYXZHWiZLeZFVek= github.com/openstack-k8s-operators/horizon-operator/api v0.5.1-0.20241119161147-c38568cb3fb0 h1:YtC+hqGKx9M8B6fHgA1eFlq1yjEiOWwp1zZqyFtjSbA= github.com/openstack-k8s-operators/horizon-operator/api v0.5.1-0.20241119161147-c38568cb3fb0/go.mod h1:ezxV+6xd12IRKespGaDlJCUQ301yxrBlQUCEbeYQgSA= -github.com/openstack-k8s-operators/infra-operator/apis v0.5.1-0.20241118112815-d52a058b34a8 h1:mmnunGX3tnIT4ErxFjYcKb38VLjnfe9JcIcU9LaW9rE= -github.com/openstack-k8s-operators/infra-operator/apis v0.5.1-0.20241118112815-d52a058b34a8/go.mod h1:6x5zgJJBjrOhsTtNALYrM2ecUH92kIoZbZ6w1fKHPfs= +github.com/openstack-k8s-operators/infra-operator/apis v0.5.1-0.20241120235143-b225194fd0fd h1:6LmBamNQRwX76TiR+qo7Ejkb5bT2IPFhstkTWtVh7m4= +github.com/openstack-k8s-operators/infra-operator/apis v0.5.1-0.20241120235143-b225194fd0fd/go.mod h1:6x5zgJJBjrOhsTtNALYrM2ecUH92kIoZbZ6w1fKHPfs= github.com/openstack-k8s-operators/ironic-operator/api v0.5.1-0.20241114211630-5b4dcbed9b37 h1:k++YKQetyZqG6t+kWLhVUclgwLRKspCEyxeEWCeDgjM= github.com/openstack-k8s-operators/ironic-operator/api v0.5.1-0.20241114211630-5b4dcbed9b37/go.mod h1:nKeZBXFCwbYxTpIW9mPs/SK+4cODkEZgs+yOytvafBo= github.com/openstack-k8s-operators/keystone-operator/api v0.5.1-0.20241119162247-18b741090348 h1:mJeXL6JpNWe7d8wA8UZ1EI5T70f8HIgE2ecNjfPFIq4= diff --git a/pkg/openstack/dnsmasq.go b/pkg/openstack/dnsmasq.go index cae7a8a06..7dc5e16d7 100644 --- a/pkg/openstack/dnsmasq.go +++ b/pkg/openstack/dnsmasq.go @@ -40,13 +40,14 @@ func ReconcileDNSMasqs(ctx context.Context, instance *corev1beta1.OpenStackContr instance.Spec.DNS.Template = &networkv1.DNSMasqSpec{} } + if instance.Spec.DNS.Template.NodeSelector == nil { + instance.Spec.DNS.Template.NodeSelector = &instance.Spec.NodeSelector + } + Log.Info("Reconciling DNSMasq", "DNSMasq.Namespace", instance.Namespace, "DNSMasq.Name", "dnsmasq") op, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), dnsmasq, func() error { instance.Spec.DNS.Template.DeepCopyInto(&dnsmasq.Spec) dnsmasq.Spec.ContainerImage = *version.Status.ContainerImages.InfraDnsmasqImage - if dnsmasq.Spec.NodeSelector == nil && instance.Spec.NodeSelector != nil { - dnsmasq.Spec.NodeSelector = instance.Spec.NodeSelector - } err := controllerutil.SetControllerReference(helper.GetBeforeObject(), dnsmasq, helper.GetScheme()) if err != nil { return err diff --git a/pkg/openstack/memcached.go b/pkg/openstack/memcached.go index 92cf63b50..8bd701566 100644 --- a/pkg/openstack/memcached.go +++ b/pkg/openstack/memcached.go @@ -199,6 +199,10 @@ func reconcileMemcached( tlsCert = certSecret.Name } + if spec.NodeSelector == nil { + spec.NodeSelector = &instance.Spec.NodeSelector + } + op, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), memcached, func() error { spec.DeepCopyInto(&memcached.Spec.MemcachedSpecCore) diff --git a/pkg/openstack/redis.go b/pkg/openstack/redis.go index 28b2881e7..33b161572 100644 --- a/pkg/openstack/redis.go +++ b/pkg/openstack/redis.go @@ -219,6 +219,10 @@ func reconcileRedis( tlsCert = certSecret.Name } + if spec.NodeSelector == nil { + spec.NodeSelector = &instance.Spec.NodeSelector + } + op, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), redis, func() error { spec.DeepCopyInto(&redis.Spec.RedisSpecCore) if tlsCert != "" { From e1886702c1617d417e9c3f8de51ed2f7d1d14d2a Mon Sep 17 00:00:00 2001 From: Oliver Walsh Date: Thu, 21 Nov 2024 10:41:30 +0000 Subject: [PATCH 02/14] Inherit top-level nodeSelector in ironic template --- apis/go.mod | 2 +- apis/go.sum | 4 ++-- go.mod | 2 +- go.sum | 4 ++-- pkg/openstack/ironic.go | 4 ++++ 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/apis/go.mod b/apis/go.mod index 886ec52a8..8a5e9d30f 100644 --- a/apis/go.mod +++ b/apis/go.mod @@ -14,7 +14,7 @@ require ( github.com/openstack-k8s-operators/heat-operator/api v0.5.1-0.20241120140156-1c476cfe7c63 github.com/openstack-k8s-operators/horizon-operator/api v0.5.1-0.20241119161147-c38568cb3fb0 github.com/openstack-k8s-operators/infra-operator/apis v0.5.1-0.20241120235143-b225194fd0fd - github.com/openstack-k8s-operators/ironic-operator/api v0.5.1-0.20241114211630-5b4dcbed9b37 + github.com/openstack-k8s-operators/ironic-operator/api v0.5.1-0.20241120225637-63d25e2bf291 github.com/openstack-k8s-operators/keystone-operator/api v0.5.1-0.20241119162247-18b741090348 github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20241114091812-6dc9fd0961dc github.com/openstack-k8s-operators/lib-common/modules/storage v0.5.1-0.20241114091812-6dc9fd0961dc diff --git a/apis/go.sum b/apis/go.sum index d35a5eef6..daaa9d22c 100644 --- a/apis/go.sum +++ b/apis/go.sum @@ -108,8 +108,8 @@ github.com/openstack-k8s-operators/horizon-operator/api v0.5.1-0.20241119161147- github.com/openstack-k8s-operators/horizon-operator/api v0.5.1-0.20241119161147-c38568cb3fb0/go.mod h1:ezxV+6xd12IRKespGaDlJCUQ301yxrBlQUCEbeYQgSA= github.com/openstack-k8s-operators/infra-operator/apis v0.5.1-0.20241120235143-b225194fd0fd h1:6LmBamNQRwX76TiR+qo7Ejkb5bT2IPFhstkTWtVh7m4= github.com/openstack-k8s-operators/infra-operator/apis v0.5.1-0.20241120235143-b225194fd0fd/go.mod h1:6x5zgJJBjrOhsTtNALYrM2ecUH92kIoZbZ6w1fKHPfs= -github.com/openstack-k8s-operators/ironic-operator/api v0.5.1-0.20241114211630-5b4dcbed9b37 h1:k++YKQetyZqG6t+kWLhVUclgwLRKspCEyxeEWCeDgjM= -github.com/openstack-k8s-operators/ironic-operator/api v0.5.1-0.20241114211630-5b4dcbed9b37/go.mod h1:nKeZBXFCwbYxTpIW9mPs/SK+4cODkEZgs+yOytvafBo= +github.com/openstack-k8s-operators/ironic-operator/api v0.5.1-0.20241120225637-63d25e2bf291 h1:wK/7eRfMI4bJxqC4NFRdNJKPL9CPf5gSQHNsn2EfqIc= +github.com/openstack-k8s-operators/ironic-operator/api v0.5.1-0.20241120225637-63d25e2bf291/go.mod h1:nKeZBXFCwbYxTpIW9mPs/SK+4cODkEZgs+yOytvafBo= github.com/openstack-k8s-operators/keystone-operator/api v0.5.1-0.20241119162247-18b741090348 h1:mJeXL6JpNWe7d8wA8UZ1EI5T70f8HIgE2ecNjfPFIq4= github.com/openstack-k8s-operators/keystone-operator/api v0.5.1-0.20241119162247-18b741090348/go.mod h1:AZhHY6dZzGyG9iVOf1poD7pTS9c7ZG/f99Fg+GdFVEk= github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20241114091812-6dc9fd0961dc h1:Ufa/q/nC9wmKblvsc0kJppsXHOJoY4fbUamb3ItWCOk= diff --git a/go.mod b/go.mod index 0bc0f867e..73f1233c8 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/openstack-k8s-operators/heat-operator/api v0.5.1-0.20241120140156-1c476cfe7c63 github.com/openstack-k8s-operators/horizon-operator/api v0.5.1-0.20241119161147-c38568cb3fb0 github.com/openstack-k8s-operators/infra-operator/apis v0.5.1-0.20241120235143-b225194fd0fd - github.com/openstack-k8s-operators/ironic-operator/api v0.5.1-0.20241114211630-5b4dcbed9b37 + github.com/openstack-k8s-operators/ironic-operator/api v0.5.1-0.20241120225637-63d25e2bf291 github.com/openstack-k8s-operators/keystone-operator/api v0.5.1-0.20241119162247-18b741090348 github.com/openstack-k8s-operators/lib-common/modules/ansible v0.5.0 github.com/openstack-k8s-operators/lib-common/modules/certmanager v0.5.1-0.20241114091812-6dc9fd0961dc diff --git a/go.sum b/go.sum index 048c9310f..8bfb4175b 100644 --- a/go.sum +++ b/go.sum @@ -114,8 +114,8 @@ github.com/openstack-k8s-operators/horizon-operator/api v0.5.1-0.20241119161147- github.com/openstack-k8s-operators/horizon-operator/api v0.5.1-0.20241119161147-c38568cb3fb0/go.mod h1:ezxV+6xd12IRKespGaDlJCUQ301yxrBlQUCEbeYQgSA= github.com/openstack-k8s-operators/infra-operator/apis v0.5.1-0.20241120235143-b225194fd0fd h1:6LmBamNQRwX76TiR+qo7Ejkb5bT2IPFhstkTWtVh7m4= github.com/openstack-k8s-operators/infra-operator/apis v0.5.1-0.20241120235143-b225194fd0fd/go.mod h1:6x5zgJJBjrOhsTtNALYrM2ecUH92kIoZbZ6w1fKHPfs= -github.com/openstack-k8s-operators/ironic-operator/api v0.5.1-0.20241114211630-5b4dcbed9b37 h1:k++YKQetyZqG6t+kWLhVUclgwLRKspCEyxeEWCeDgjM= -github.com/openstack-k8s-operators/ironic-operator/api v0.5.1-0.20241114211630-5b4dcbed9b37/go.mod h1:nKeZBXFCwbYxTpIW9mPs/SK+4cODkEZgs+yOytvafBo= +github.com/openstack-k8s-operators/ironic-operator/api v0.5.1-0.20241120225637-63d25e2bf291 h1:wK/7eRfMI4bJxqC4NFRdNJKPL9CPf5gSQHNsn2EfqIc= +github.com/openstack-k8s-operators/ironic-operator/api v0.5.1-0.20241120225637-63d25e2bf291/go.mod h1:nKeZBXFCwbYxTpIW9mPs/SK+4cODkEZgs+yOytvafBo= github.com/openstack-k8s-operators/keystone-operator/api v0.5.1-0.20241119162247-18b741090348 h1:mJeXL6JpNWe7d8wA8UZ1EI5T70f8HIgE2ecNjfPFIq4= github.com/openstack-k8s-operators/keystone-operator/api v0.5.1-0.20241119162247-18b741090348/go.mod h1:AZhHY6dZzGyG9iVOf1poD7pTS9c7ZG/f99Fg+GdFVEk= github.com/openstack-k8s-operators/lib-common/modules/ansible v0.5.0 h1:M6tou1UD+en6fcZtV64RPsDVdHH5up6oqtENDU8dRyE= diff --git a/pkg/openstack/ironic.go b/pkg/openstack/ironic.go index 1c71e81c6..95c202615 100644 --- a/pkg/openstack/ironic.go +++ b/pkg/openstack/ironic.go @@ -47,6 +47,10 @@ func ReconcileIronic(ctx context.Context, instance *corev1beta1.OpenStackControl instance.Spec.Ironic.Template = &ironicv1.IronicSpecCore{} } + if instance.Spec.Ironic.Template.NodeSelector == nil { + instance.Spec.Ironic.Template.NodeSelector = &instance.Spec.NodeSelector + } + // add selector to service overrides for _, endpointType := range []service.Endpoint{service.EndpointPublic, service.EndpointInternal} { if instance.Spec.Ironic.Template.IronicAPI.Override.Service == nil { From 32b232fdb5fa2be989e2e8d96eed9230366d0e3d Mon Sep 17 00:00:00 2001 From: Oliver Walsh Date: Thu, 21 Nov 2024 10:44:20 +0000 Subject: [PATCH 03/14] Inherit top-level nodeSelector in manila template --- apis/go.mod | 2 +- apis/go.sum | 4 ++-- go.mod | 2 +- go.sum | 4 ++-- pkg/openstack/manila.go | 8 +++++--- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/apis/go.mod b/apis/go.mod index 8a5e9d30f..c1cdb221b 100644 --- a/apis/go.mod +++ b/apis/go.mod @@ -18,7 +18,7 @@ require ( github.com/openstack-k8s-operators/keystone-operator/api v0.5.1-0.20241119162247-18b741090348 github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20241114091812-6dc9fd0961dc github.com/openstack-k8s-operators/lib-common/modules/storage v0.5.1-0.20241114091812-6dc9fd0961dc - github.com/openstack-k8s-operators/manila-operator/api v0.5.1-0.20241117150431-21b7f58d9ddf + github.com/openstack-k8s-operators/manila-operator/api v0.5.1-0.20241121093406-bfd56f125086 github.com/openstack-k8s-operators/mariadb-operator/api v0.5.1-0.20241120160542-4b457715f74e github.com/openstack-k8s-operators/neutron-operator/api v0.5.1-0.20241114104932-eae3f8cd032b github.com/openstack-k8s-operators/nova-operator/api v0.5.1-0.20241119125634-42b7b8417b48 diff --git a/apis/go.sum b/apis/go.sum index daaa9d22c..3dca4611e 100644 --- a/apis/go.sum +++ b/apis/go.sum @@ -118,8 +118,8 @@ github.com/openstack-k8s-operators/lib-common/modules/openstack v0.5.1-0.2024111 github.com/openstack-k8s-operators/lib-common/modules/openstack v0.5.1-0.20241114091812-6dc9fd0961dc/go.mod h1:IASoGvp5QM/tBJUd/8i8uIjj4DBnI+64Ydh4r7pmnvA= github.com/openstack-k8s-operators/lib-common/modules/storage v0.5.1-0.20241114091812-6dc9fd0961dc h1:J5Kr0/ST3KqMzSRhcubr0fF9/vWzma+U63P9kfmgIA8= github.com/openstack-k8s-operators/lib-common/modules/storage v0.5.1-0.20241114091812-6dc9fd0961dc/go.mod h1:tfgBeLRqmlH/NQkLPe7396rj+t0whv2wPuMb8Ttvh8w= -github.com/openstack-k8s-operators/manila-operator/api v0.5.1-0.20241117150431-21b7f58d9ddf h1:UsAefjZBqFl0dYMg/efe75ECm8cAwc/2FCEBPYjQfIY= -github.com/openstack-k8s-operators/manila-operator/api v0.5.1-0.20241117150431-21b7f58d9ddf/go.mod h1:0/qgnjufYIqe439/3aUU/cwnjDwdUlNR3jnRubLTD5o= +github.com/openstack-k8s-operators/manila-operator/api v0.5.1-0.20241121093406-bfd56f125086 h1:83nj2btbl2i06eJHtZdudyj0r1uuFqkorwkLdgssfp0= +github.com/openstack-k8s-operators/manila-operator/api v0.5.1-0.20241121093406-bfd56f125086/go.mod h1:0/qgnjufYIqe439/3aUU/cwnjDwdUlNR3jnRubLTD5o= github.com/openstack-k8s-operators/mariadb-operator/api v0.5.1-0.20241120160542-4b457715f74e h1:id6qqUWUMo0h7LoIhjQlMIjy4iihoBCi7Pe/jWjKHcY= github.com/openstack-k8s-operators/mariadb-operator/api v0.5.1-0.20241120160542-4b457715f74e/go.mod h1:348EPtAdpE2LxHAH4bHdCMNP7HyX6DevwEsF9DQ0S2k= github.com/openstack-k8s-operators/neutron-operator/api v0.5.1-0.20241114104932-eae3f8cd032b h1:JMMPYDierS4YZdG9O/50kLihPQqmDz7p72btLy7Ibew= diff --git a/go.mod b/go.mod index 73f1233c8..465126712 100644 --- a/go.mod +++ b/go.mod @@ -27,7 +27,7 @@ require ( github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20241114091812-6dc9fd0961dc github.com/openstack-k8s-operators/lib-common/modules/storage v0.5.1-0.20241114091812-6dc9fd0961dc github.com/openstack-k8s-operators/lib-common/modules/test v0.5.1-0.20241114091812-6dc9fd0961dc - github.com/openstack-k8s-operators/manila-operator/api v0.5.1-0.20241117150431-21b7f58d9ddf + github.com/openstack-k8s-operators/manila-operator/api v0.5.1-0.20241121093406-bfd56f125086 github.com/openstack-k8s-operators/mariadb-operator/api v0.5.1-0.20241120160542-4b457715f74e github.com/openstack-k8s-operators/neutron-operator/api v0.5.1-0.20241114104932-eae3f8cd032b github.com/openstack-k8s-operators/nova-operator/api v0.5.1-0.20241119125634-42b7b8417b48 diff --git a/go.sum b/go.sum index 8bfb4175b..92c4d0813 100644 --- a/go.sum +++ b/go.sum @@ -130,8 +130,8 @@ github.com/openstack-k8s-operators/lib-common/modules/storage v0.5.1-0.202411140 github.com/openstack-k8s-operators/lib-common/modules/storage v0.5.1-0.20241114091812-6dc9fd0961dc/go.mod h1:tfgBeLRqmlH/NQkLPe7396rj+t0whv2wPuMb8Ttvh8w= github.com/openstack-k8s-operators/lib-common/modules/test v0.5.1-0.20241114091812-6dc9fd0961dc h1:knyjd0eg4DyY+dTDHSrE9QwrZ0mtr7MpASCrmhW+5pw= github.com/openstack-k8s-operators/lib-common/modules/test v0.5.1-0.20241114091812-6dc9fd0961dc/go.mod h1:LV0jo5etIsGyINpmB37i4oWR8zU6ApIuh7fsqGGA41o= -github.com/openstack-k8s-operators/manila-operator/api v0.5.1-0.20241117150431-21b7f58d9ddf h1:UsAefjZBqFl0dYMg/efe75ECm8cAwc/2FCEBPYjQfIY= -github.com/openstack-k8s-operators/manila-operator/api v0.5.1-0.20241117150431-21b7f58d9ddf/go.mod h1:0/qgnjufYIqe439/3aUU/cwnjDwdUlNR3jnRubLTD5o= +github.com/openstack-k8s-operators/manila-operator/api v0.5.1-0.20241121093406-bfd56f125086 h1:83nj2btbl2i06eJHtZdudyj0r1uuFqkorwkLdgssfp0= +github.com/openstack-k8s-operators/manila-operator/api v0.5.1-0.20241121093406-bfd56f125086/go.mod h1:0/qgnjufYIqe439/3aUU/cwnjDwdUlNR3jnRubLTD5o= github.com/openstack-k8s-operators/mariadb-operator/api v0.5.1-0.20241120160542-4b457715f74e h1:id6qqUWUMo0h7LoIhjQlMIjy4iihoBCi7Pe/jWjKHcY= github.com/openstack-k8s-operators/mariadb-operator/api v0.5.1-0.20241120160542-4b457715f74e/go.mod h1:348EPtAdpE2LxHAH4bHdCMNP7HyX6DevwEsF9DQ0S2k= github.com/openstack-k8s-operators/neutron-operator/api v0.5.1-0.20241114104932-eae3f8cd032b h1:JMMPYDierS4YZdG9O/50kLihPQqmDz7p72btLy7Ibew= diff --git a/pkg/openstack/manila.go b/pkg/openstack/manila.go index 3f526429c..468ee64d0 100644 --- a/pkg/openstack/manila.go +++ b/pkg/openstack/manila.go @@ -106,11 +106,16 @@ func ReconcileManila(ctx context.Context, instance *corev1beta1.OpenStackControl instance.Spec.Manila.Template.ManilaAPI.TLS.API.Internal.SecretName = endpointDetails.GetEndptCertSecret(service.EndpointInternal) } + if instance.Spec.Manila.Template.NodeSelector == nil { + instance.Spec.Manila.Template.NodeSelector = &instance.Spec.NodeSelector + } + Log.Info("Reconciling Manila", "Manila.Namespace", instance.Namespace, "Manila.Name", "manila") op, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), manila, func() error { instance.Spec.Manila.Template.ManilaSpecBase.DeepCopyInto(&manila.Spec.ManilaSpecBase) instance.Spec.Manila.Template.ManilaAPI.DeepCopyInto(&manila.Spec.ManilaAPI.ManilaAPITemplateCore) instance.Spec.Manila.Template.ManilaScheduler.DeepCopyInto(&manila.Spec.ManilaScheduler.ManilaSchedulerTemplateCore) + manila.Spec.NodeSelector = instance.Spec.Manila.Template.NodeSelector manila.Spec.ManilaAPI.ContainerImage = *version.Status.ContainerImages.ManilaAPIImage manila.Spec.ManilaScheduler.ContainerImage = *version.Status.ContainerImages.ManilaSchedulerImage @@ -137,9 +142,6 @@ func ReconcileManila(ctx context.Context, instance *corev1beta1.OpenStackControl if manila.Spec.Secret == "" { manila.Spec.Secret = instance.Spec.Secret } - if manila.Spec.NodeSelector == nil && instance.Spec.NodeSelector != nil { - manila.Spec.NodeSelector = instance.Spec.NodeSelector - } if manila.Spec.DatabaseInstance == "" { //manila.Spec.DatabaseInstance = instance.Name // name of MariaDB we create here manila.Spec.DatabaseInstance = "openstack" //FIXME: see above From 63f23c99c1a6d9b500ab1cedbcd2aff997d59f82 Mon Sep 17 00:00:00 2001 From: Oliver Walsh Date: Thu, 21 Nov 2024 10:46:54 +0000 Subject: [PATCH 04/14] Inherit top-level nodeSelector in neutron template --- apis/go.mod | 2 +- apis/go.sum | 4 ++-- go.mod | 2 +- go.sum | 4 ++-- pkg/openstack/neutron.go | 7 ++++--- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/apis/go.mod b/apis/go.mod index c1cdb221b..d23719794 100644 --- a/apis/go.mod +++ b/apis/go.mod @@ -20,7 +20,7 @@ require ( github.com/openstack-k8s-operators/lib-common/modules/storage v0.5.1-0.20241114091812-6dc9fd0961dc github.com/openstack-k8s-operators/manila-operator/api v0.5.1-0.20241121093406-bfd56f125086 github.com/openstack-k8s-operators/mariadb-operator/api v0.5.1-0.20241120160542-4b457715f74e - github.com/openstack-k8s-operators/neutron-operator/api v0.5.1-0.20241114104932-eae3f8cd032b + github.com/openstack-k8s-operators/neutron-operator/api v0.5.1-0.20241121095318-591a3bcbcda6 github.com/openstack-k8s-operators/nova-operator/api v0.5.1-0.20241119125634-42b7b8417b48 github.com/openstack-k8s-operators/octavia-operator/api v0.5.1-0.20241115111947-2336829c2d73 github.com/openstack-k8s-operators/openstack-baremetal-operator/api v0.5.1-0.20241118111717-a1d460a6d81f diff --git a/apis/go.sum b/apis/go.sum index 3dca4611e..ac73408da 100644 --- a/apis/go.sum +++ b/apis/go.sum @@ -122,8 +122,8 @@ github.com/openstack-k8s-operators/manila-operator/api v0.5.1-0.20241121093406-b github.com/openstack-k8s-operators/manila-operator/api v0.5.1-0.20241121093406-bfd56f125086/go.mod h1:0/qgnjufYIqe439/3aUU/cwnjDwdUlNR3jnRubLTD5o= github.com/openstack-k8s-operators/mariadb-operator/api v0.5.1-0.20241120160542-4b457715f74e h1:id6qqUWUMo0h7LoIhjQlMIjy4iihoBCi7Pe/jWjKHcY= github.com/openstack-k8s-operators/mariadb-operator/api v0.5.1-0.20241120160542-4b457715f74e/go.mod h1:348EPtAdpE2LxHAH4bHdCMNP7HyX6DevwEsF9DQ0S2k= -github.com/openstack-k8s-operators/neutron-operator/api v0.5.1-0.20241114104932-eae3f8cd032b h1:JMMPYDierS4YZdG9O/50kLihPQqmDz7p72btLy7Ibew= -github.com/openstack-k8s-operators/neutron-operator/api v0.5.1-0.20241114104932-eae3f8cd032b/go.mod h1:Kfuu3g4PSFpEowdWhbnTgSlDpsBGswQf/WU/kKQKK7s= +github.com/openstack-k8s-operators/neutron-operator/api v0.5.1-0.20241121095318-591a3bcbcda6 h1:ZFsA5wQwdITdXQxX99heejR9mWWsy8eGAaUoORk1pQI= +github.com/openstack-k8s-operators/neutron-operator/api v0.5.1-0.20241121095318-591a3bcbcda6/go.mod h1:Kfuu3g4PSFpEowdWhbnTgSlDpsBGswQf/WU/kKQKK7s= github.com/openstack-k8s-operators/nova-operator/api v0.5.1-0.20241119125634-42b7b8417b48 h1:eCvn/lCMqWTvlN74nFr7nG2EvZdvJPdSR9Ts2eTaM6c= github.com/openstack-k8s-operators/nova-operator/api v0.5.1-0.20241119125634-42b7b8417b48/go.mod h1:330SfEZuqG3b90HopY+Hk90y0OTyPcBa0GRKPUD7BHE= github.com/openstack-k8s-operators/octavia-operator/api v0.5.1-0.20241115111947-2336829c2d73 h1:HWHbtCBbTv3zvluSpV4ZG8Ov0VJxUn5uJOrH8orSnQs= diff --git a/go.mod b/go.mod index 465126712..9275df3b3 100644 --- a/go.mod +++ b/go.mod @@ -29,7 +29,7 @@ require ( github.com/openstack-k8s-operators/lib-common/modules/test v0.5.1-0.20241114091812-6dc9fd0961dc github.com/openstack-k8s-operators/manila-operator/api v0.5.1-0.20241121093406-bfd56f125086 github.com/openstack-k8s-operators/mariadb-operator/api v0.5.1-0.20241120160542-4b457715f74e - github.com/openstack-k8s-operators/neutron-operator/api v0.5.1-0.20241114104932-eae3f8cd032b + github.com/openstack-k8s-operators/neutron-operator/api v0.5.1-0.20241121095318-591a3bcbcda6 github.com/openstack-k8s-operators/nova-operator/api v0.5.1-0.20241119125634-42b7b8417b48 github.com/openstack-k8s-operators/octavia-operator/api v0.5.1-0.20241115111947-2336829c2d73 github.com/openstack-k8s-operators/openstack-baremetal-operator/api v0.5.1-0.20241118111717-a1d460a6d81f diff --git a/go.sum b/go.sum index 92c4d0813..c6d978601 100644 --- a/go.sum +++ b/go.sum @@ -134,8 +134,8 @@ github.com/openstack-k8s-operators/manila-operator/api v0.5.1-0.20241121093406-b github.com/openstack-k8s-operators/manila-operator/api v0.5.1-0.20241121093406-bfd56f125086/go.mod h1:0/qgnjufYIqe439/3aUU/cwnjDwdUlNR3jnRubLTD5o= github.com/openstack-k8s-operators/mariadb-operator/api v0.5.1-0.20241120160542-4b457715f74e h1:id6qqUWUMo0h7LoIhjQlMIjy4iihoBCi7Pe/jWjKHcY= github.com/openstack-k8s-operators/mariadb-operator/api v0.5.1-0.20241120160542-4b457715f74e/go.mod h1:348EPtAdpE2LxHAH4bHdCMNP7HyX6DevwEsF9DQ0S2k= -github.com/openstack-k8s-operators/neutron-operator/api v0.5.1-0.20241114104932-eae3f8cd032b h1:JMMPYDierS4YZdG9O/50kLihPQqmDz7p72btLy7Ibew= -github.com/openstack-k8s-operators/neutron-operator/api v0.5.1-0.20241114104932-eae3f8cd032b/go.mod h1:Kfuu3g4PSFpEowdWhbnTgSlDpsBGswQf/WU/kKQKK7s= +github.com/openstack-k8s-operators/neutron-operator/api v0.5.1-0.20241121095318-591a3bcbcda6 h1:ZFsA5wQwdITdXQxX99heejR9mWWsy8eGAaUoORk1pQI= +github.com/openstack-k8s-operators/neutron-operator/api v0.5.1-0.20241121095318-591a3bcbcda6/go.mod h1:Kfuu3g4PSFpEowdWhbnTgSlDpsBGswQf/WU/kKQKK7s= github.com/openstack-k8s-operators/nova-operator/api v0.5.1-0.20241119125634-42b7b8417b48 h1:eCvn/lCMqWTvlN74nFr7nG2EvZdvJPdSR9Ts2eTaM6c= github.com/openstack-k8s-operators/nova-operator/api v0.5.1-0.20241119125634-42b7b8417b48/go.mod h1:330SfEZuqG3b90HopY+Hk90y0OTyPcBa0GRKPUD7BHE= github.com/openstack-k8s-operators/octavia-operator/api v0.5.1-0.20241115111947-2336829c2d73 h1:HWHbtCBbTv3zvluSpV4ZG8Ov0VJxUn5uJOrH8orSnQs= diff --git a/pkg/openstack/neutron.go b/pkg/openstack/neutron.go index 211f3642f..425c7ac9a 100644 --- a/pkg/openstack/neutron.go +++ b/pkg/openstack/neutron.go @@ -141,6 +141,10 @@ func ReconcileNeutron(ctx context.Context, instance *corev1beta1.OpenStackContro instance.Spec.Neutron.Template.TLS.API.Internal.SecretName = endpointDetails.GetEndptCertSecret(service.EndpointInternal) } + if instance.Spec.Neutron.Template.NodeSelector == nil { + instance.Spec.Neutron.Template.NodeSelector = &instance.Spec.NodeSelector + } + Log.Info("Reconciling NeutronAPI", "NeutronAPI.Namespace", instance.Namespace, "NeutronAPI.Name", "neutron") op, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), neutronAPI, func() error { instance.Spec.Neutron.Template.DeepCopyInto(&neutronAPI.Spec.NeutronAPISpecCore) @@ -148,9 +152,6 @@ func ReconcileNeutron(ctx context.Context, instance *corev1beta1.OpenStackContro if neutronAPI.Spec.Secret == "" { neutronAPI.Spec.Secret = instance.Spec.Secret } - if neutronAPI.Spec.NodeSelector == nil && instance.Spec.NodeSelector != nil { - neutronAPI.Spec.NodeSelector = instance.Spec.NodeSelector - } if neutronAPI.Spec.DatabaseInstance == "" { neutronAPI.Spec.DatabaseInstance = "openstack" } From 2439aeaec448ef1b4c6509c353a3a1dd64c3c1a4 Mon Sep 17 00:00:00 2001 From: Oliver Walsh Date: Thu, 21 Nov 2024 10:50:04 +0000 Subject: [PATCH 05/14] Inherit top-level nodeSelector in ovn templates --- apis/go.mod | 2 +- apis/go.sum | 4 ++-- go.mod | 2 +- go.sum | 4 ++-- pkg/openstack/ovn.go | 23 ++++++++++++----------- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/apis/go.mod b/apis/go.mod index d23719794..314add8b6 100644 --- a/apis/go.mod +++ b/apis/go.mod @@ -24,7 +24,7 @@ require ( github.com/openstack-k8s-operators/nova-operator/api v0.5.1-0.20241119125634-42b7b8417b48 github.com/openstack-k8s-operators/octavia-operator/api v0.5.1-0.20241115111947-2336829c2d73 github.com/openstack-k8s-operators/openstack-baremetal-operator/api v0.5.1-0.20241118111717-a1d460a6d81f - github.com/openstack-k8s-operators/ovn-operator/api v0.5.1-0.20241118072048-45d5df9ad730 + github.com/openstack-k8s-operators/ovn-operator/api v0.5.1-0.20241121095319-a34ad51b8446 github.com/openstack-k8s-operators/placement-operator/api v0.5.1-0.20241119131546-e4c1ba679d22 github.com/openstack-k8s-operators/swift-operator/api v0.5.1-0.20241114094619-107d1aac9458 github.com/openstack-k8s-operators/telemetry-operator/api v0.5.1-0.20241118203716-9550c8740911 diff --git a/apis/go.sum b/apis/go.sum index ac73408da..95290b85f 100644 --- a/apis/go.sum +++ b/apis/go.sum @@ -130,8 +130,8 @@ github.com/openstack-k8s-operators/octavia-operator/api v0.5.1-0.20241115111947- github.com/openstack-k8s-operators/octavia-operator/api v0.5.1-0.20241115111947-2336829c2d73/go.mod h1:3bFE3g3OCC2vtwhxDKdjV7sezTj4yFeqP0C40Z5NOEA= github.com/openstack-k8s-operators/openstack-baremetal-operator/api v0.5.1-0.20241118111717-a1d460a6d81f h1:2aM3rxATUmgPdghtm8MoN2WVACMI5XYSQFv1JZV8iqA= github.com/openstack-k8s-operators/openstack-baremetal-operator/api v0.5.1-0.20241118111717-a1d460a6d81f/go.mod h1:G9nampuSFs/9i2Ldx3OasU6oehWchwYuhBu1qMWktMg= -github.com/openstack-k8s-operators/ovn-operator/api v0.5.1-0.20241118072048-45d5df9ad730 h1:unZ61c7+dUAALmQHRAVuqqmaTU0Ga5QeU53a4VXwtQU= -github.com/openstack-k8s-operators/ovn-operator/api v0.5.1-0.20241118072048-45d5df9ad730/go.mod h1:q5nvyCqRoCM9y6s/n8GfrBUzsGJltCEy8C1usKtkeJA= +github.com/openstack-k8s-operators/ovn-operator/api v0.5.1-0.20241121095319-a34ad51b8446 h1:IPbI+S2an1puMVCKzyW6dBwsTJ9QmaK1Cj9/qFHrHMY= +github.com/openstack-k8s-operators/ovn-operator/api v0.5.1-0.20241121095319-a34ad51b8446/go.mod h1:q5nvyCqRoCM9y6s/n8GfrBUzsGJltCEy8C1usKtkeJA= github.com/openstack-k8s-operators/placement-operator/api v0.5.1-0.20241119131546-e4c1ba679d22 h1:/53HgWuy6ZeqDVHevrv8dINctLF5/NY94LG+lKtDP08= github.com/openstack-k8s-operators/placement-operator/api v0.5.1-0.20241119131546-e4c1ba679d22/go.mod h1:3XfvmllEbmTSFzX44Smpq5Ec5nzNAU+aiMgrYKwiXs4= github.com/openstack-k8s-operators/rabbitmq-cluster-operator/v2 v2.6.1-0.20241017142550-a3524acedd49 h1:/7SnnHfGCH/dwuZFNUx54zw4cnwv2w6hjONq16aoowM= diff --git a/go.mod b/go.mod index 9275df3b3..77b93dff9 100644 --- a/go.mod +++ b/go.mod @@ -34,7 +34,7 @@ require ( github.com/openstack-k8s-operators/octavia-operator/api v0.5.1-0.20241115111947-2336829c2d73 github.com/openstack-k8s-operators/openstack-baremetal-operator/api v0.5.1-0.20241118111717-a1d460a6d81f github.com/openstack-k8s-operators/openstack-operator/apis v0.0.0-20240531084739-3b4c0451297c - github.com/openstack-k8s-operators/ovn-operator/api v0.5.1-0.20241118072048-45d5df9ad730 + github.com/openstack-k8s-operators/ovn-operator/api v0.5.1-0.20241121095319-a34ad51b8446 github.com/openstack-k8s-operators/placement-operator/api v0.5.1-0.20241119131546-e4c1ba679d22 github.com/openstack-k8s-operators/swift-operator/api v0.5.1-0.20241114094619-107d1aac9458 github.com/openstack-k8s-operators/telemetry-operator/api v0.5.1-0.20241118203716-9550c8740911 diff --git a/go.sum b/go.sum index c6d978601..299ab7f48 100644 --- a/go.sum +++ b/go.sum @@ -142,8 +142,8 @@ github.com/openstack-k8s-operators/octavia-operator/api v0.5.1-0.20241115111947- github.com/openstack-k8s-operators/octavia-operator/api v0.5.1-0.20241115111947-2336829c2d73/go.mod h1:3bFE3g3OCC2vtwhxDKdjV7sezTj4yFeqP0C40Z5NOEA= github.com/openstack-k8s-operators/openstack-baremetal-operator/api v0.5.1-0.20241118111717-a1d460a6d81f h1:2aM3rxATUmgPdghtm8MoN2WVACMI5XYSQFv1JZV8iqA= github.com/openstack-k8s-operators/openstack-baremetal-operator/api v0.5.1-0.20241118111717-a1d460a6d81f/go.mod h1:G9nampuSFs/9i2Ldx3OasU6oehWchwYuhBu1qMWktMg= -github.com/openstack-k8s-operators/ovn-operator/api v0.5.1-0.20241118072048-45d5df9ad730 h1:unZ61c7+dUAALmQHRAVuqqmaTU0Ga5QeU53a4VXwtQU= -github.com/openstack-k8s-operators/ovn-operator/api v0.5.1-0.20241118072048-45d5df9ad730/go.mod h1:q5nvyCqRoCM9y6s/n8GfrBUzsGJltCEy8C1usKtkeJA= +github.com/openstack-k8s-operators/ovn-operator/api v0.5.1-0.20241121095319-a34ad51b8446 h1:IPbI+S2an1puMVCKzyW6dBwsTJ9QmaK1Cj9/qFHrHMY= +github.com/openstack-k8s-operators/ovn-operator/api v0.5.1-0.20241121095319-a34ad51b8446/go.mod h1:q5nvyCqRoCM9y6s/n8GfrBUzsGJltCEy8C1usKtkeJA= github.com/openstack-k8s-operators/placement-operator/api v0.5.1-0.20241119131546-e4c1ba679d22 h1:/53HgWuy6ZeqDVHevrv8dINctLF5/NY94LG+lKtDP08= github.com/openstack-k8s-operators/placement-operator/api v0.5.1-0.20241119131546-e4c1ba679d22/go.mod h1:3XfvmllEbmTSFzX44Smpq5Ec5nzNAU+aiMgrYKwiXs4= github.com/openstack-k8s-operators/rabbitmq-cluster-operator/v2 v2.6.1-0.20241017142550-a3524acedd49 h1:/7SnnHfGCH/dwuZFNUx54zw4cnwv2w6hjONq16aoowM= diff --git a/pkg/openstack/ovn.go b/pkg/openstack/ovn.go index 25997af7a..32569abfc 100644 --- a/pkg/openstack/ovn.go +++ b/pkg/openstack/ovn.go @@ -142,6 +142,10 @@ func ReconcileOVNDbClusters(ctx context.Context, instance *corev1beta1.OpenStack dbcluster.TLS.SecretName = &certSecret.Name } + if dbcluster.NodeSelector == nil { + dbcluster.NodeSelector = &instance.Spec.NodeSelector + } + Log.Info("Reconciling OVNDBCluster", "OVNDBCluster.Namespace", instance.Namespace, "OVNDBCluster.Name", name) op, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), OVNDBCluster, func() error { @@ -154,9 +158,6 @@ func ReconcileOVNDbClusters(ctx context.Context, instance *corev1beta1.OpenStack OVNDBCluster.Spec.ContainerImage = *version.Status.ContainerImages.OvnSbDbclusterImage } - if OVNDBCluster.Spec.NodeSelector == nil && instance.Spec.NodeSelector != nil { - OVNDBCluster.Spec.NodeSelector = instance.Spec.NodeSelector - } if OVNDBCluster.Spec.StorageClass == "" { OVNDBCluster.Spec.StorageClass = instance.Spec.StorageClass } @@ -256,6 +257,10 @@ func ReconcileOVNNorthd(ctx context.Context, instance *corev1beta1.OpenStackCont } ovnNorthdSpec.TLS.CaBundleSecretName = instance.Status.TLS.CaBundleSecretName + if ovnNorthdSpec.NodeSelector == nil { + ovnNorthdSpec.NodeSelector = &instance.Spec.NodeSelector + } + Log.Info("Reconciling OVNNorthd", "OVNNorthd.Namespace", instance.Namespace, "OVNNorthd.Name", "ovnnorthd") op, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), OVNNorthd, func() error { @@ -263,10 +268,6 @@ func ReconcileOVNNorthd(ctx context.Context, instance *corev1beta1.OpenStackCont OVNNorthd.Spec.ContainerImage = *version.Status.ContainerImages.OvnNorthdImage - if OVNNorthd.Spec.NodeSelector == nil && instance.Spec.NodeSelector != nil { - OVNNorthd.Spec.NodeSelector = instance.Spec.NodeSelector - } - err := controllerutil.SetControllerReference(helper.GetBeforeObject(), OVNNorthd, helper.GetScheme()) if err != nil { return err @@ -373,6 +374,10 @@ func ReconcileOVNController(ctx context.Context, instance *corev1beta1.OpenStack } ovnControllerSpec.TLS.CaBundleSecretName = instance.Status.TLS.CaBundleSecretName + if ovnControllerSpec.NodeSelector == nil { + ovnControllerSpec.NodeSelector = &instance.Spec.NodeSelector + } + Log.Info("Reconciling OVNController", "OVNController.Namespace", instance.Namespace, "OVNController.Name", "ovncontroller") op, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), OVNController, func() error { @@ -381,10 +386,6 @@ func ReconcileOVNController(ctx context.Context, instance *corev1beta1.OpenStack OVNController.Spec.OvnContainerImage = *version.Status.ContainerImages.OvnControllerImage OVNController.Spec.OvsContainerImage = *version.Status.ContainerImages.OvnControllerOvsImage - if OVNController.Spec.NodeSelector == nil && instance.Spec.NodeSelector != nil { - OVNController.Spec.NodeSelector = instance.Spec.NodeSelector - } - err := controllerutil.SetControllerReference(helper.GetBeforeObject(), OVNController, helper.GetScheme()) if err != nil { return err From a77e2c69849fb71dea0f944ca3799f5330057f3d Mon Sep 17 00:00:00 2001 From: Oliver Walsh Date: Thu, 21 Nov 2024 10:51:41 +0000 Subject: [PATCH 06/14] Inherit top-level nodeSelector in swift template --- ...ore.openstack.org_openstackcontrolplanes.yaml | 16 ++++++++++++++++ apis/go.mod | 2 +- apis/go.sum | 4 ++-- ...ore.openstack.org_openstackcontrolplanes.yaml | 16 ++++++++++++++++ go.mod | 2 +- go.sum | 4 ++-- pkg/openstack/swift.go | 4 ++++ 7 files changed, 42 insertions(+), 6 deletions(-) diff --git a/apis/bases/core.openstack.org_openstackcontrolplanes.yaml b/apis/bases/core.openstack.org_openstackcontrolplanes.yaml index 9a0cc4db8..cec46e70f 100644 --- a/apis/bases/core.openstack.org_openstackcontrolplanes.yaml +++ b/apis/bases/core.openstack.org_openstackcontrolplanes.yaml @@ -14863,6 +14863,10 @@ spec: items: type: string type: array + nodeSelector: + additionalProperties: + type: string + type: object storageClass: default: "" type: string @@ -14885,6 +14889,10 @@ spec: items: type: string type: array + nodeSelector: + additionalProperties: + type: string + type: object override: properties: service: @@ -14990,6 +14998,10 @@ spec: format: int64 minimum: 1 type: integer + nodeSelector: + additionalProperties: + type: string + type: object partPower: default: 10 format: int64 @@ -15026,6 +15038,10 @@ spec: items: type: string type: array + nodeSelector: + additionalProperties: + type: string + type: object replicas: default: 1 format: int32 diff --git a/apis/go.mod b/apis/go.mod index 314add8b6..b067c0447 100644 --- a/apis/go.mod +++ b/apis/go.mod @@ -26,7 +26,7 @@ require ( github.com/openstack-k8s-operators/openstack-baremetal-operator/api v0.5.1-0.20241118111717-a1d460a6d81f github.com/openstack-k8s-operators/ovn-operator/api v0.5.1-0.20241121095319-a34ad51b8446 github.com/openstack-k8s-operators/placement-operator/api v0.5.1-0.20241119131546-e4c1ba679d22 - github.com/openstack-k8s-operators/swift-operator/api v0.5.1-0.20241114094619-107d1aac9458 + github.com/openstack-k8s-operators/swift-operator/api v0.5.1-0.20241121093118-6ab57de4e6cc github.com/openstack-k8s-operators/telemetry-operator/api v0.5.1-0.20241118203716-9550c8740911 github.com/rabbitmq/cluster-operator/v2 v2.11.0 github.com/rhobs/obo-prometheus-operator/pkg/apis/monitoring v0.71.0-rhobs1 // indirect diff --git a/apis/go.sum b/apis/go.sum index 95290b85f..9ed8b5fb1 100644 --- a/apis/go.sum +++ b/apis/go.sum @@ -136,8 +136,8 @@ github.com/openstack-k8s-operators/placement-operator/api v0.5.1-0.2024111913154 github.com/openstack-k8s-operators/placement-operator/api v0.5.1-0.20241119131546-e4c1ba679d22/go.mod h1:3XfvmllEbmTSFzX44Smpq5Ec5nzNAU+aiMgrYKwiXs4= github.com/openstack-k8s-operators/rabbitmq-cluster-operator/v2 v2.6.1-0.20241017142550-a3524acedd49 h1:/7SnnHfGCH/dwuZFNUx54zw4cnwv2w6hjONq16aoowM= github.com/openstack-k8s-operators/rabbitmq-cluster-operator/v2 v2.6.1-0.20241017142550-a3524acedd49/go.mod h1:6Mq2N/KtNFW20L+PQC5qkeK8R8UGadmGBXL8HDY6lcg= -github.com/openstack-k8s-operators/swift-operator/api v0.5.1-0.20241114094619-107d1aac9458 h1:jLM1a3sClYUKfWHdZzTZI9RIpJGA+H8XQh321CbO0D0= -github.com/openstack-k8s-operators/swift-operator/api v0.5.1-0.20241114094619-107d1aac9458/go.mod h1:JlOTO8hnn/RCDtmZXAvnpudqv38eEFGX6nbfwEbltv8= +github.com/openstack-k8s-operators/swift-operator/api v0.5.1-0.20241121093118-6ab57de4e6cc h1:ObbwXZbbXk+PQpYPZWmisdwzQaSHv9Lyk1juBLJctnM= +github.com/openstack-k8s-operators/swift-operator/api v0.5.1-0.20241121093118-6ab57de4e6cc/go.mod h1:JlOTO8hnn/RCDtmZXAvnpudqv38eEFGX6nbfwEbltv8= github.com/openstack-k8s-operators/telemetry-operator/api v0.5.1-0.20241118203716-9550c8740911 h1:4OysgPT+NOnOtC7dAKc9xdHLnVdEMz6JYDwFd6w3fxI= github.com/openstack-k8s-operators/telemetry-operator/api v0.5.1-0.20241118203716-9550c8740911/go.mod h1:wpC0oQUkW/a/BjgzZOEwknnKJxHY0DeAIqtAh7WNwSs= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= diff --git a/config/crd/bases/core.openstack.org_openstackcontrolplanes.yaml b/config/crd/bases/core.openstack.org_openstackcontrolplanes.yaml index 9a0cc4db8..cec46e70f 100644 --- a/config/crd/bases/core.openstack.org_openstackcontrolplanes.yaml +++ b/config/crd/bases/core.openstack.org_openstackcontrolplanes.yaml @@ -14863,6 +14863,10 @@ spec: items: type: string type: array + nodeSelector: + additionalProperties: + type: string + type: object storageClass: default: "" type: string @@ -14885,6 +14889,10 @@ spec: items: type: string type: array + nodeSelector: + additionalProperties: + type: string + type: object override: properties: service: @@ -14990,6 +14998,10 @@ spec: format: int64 minimum: 1 type: integer + nodeSelector: + additionalProperties: + type: string + type: object partPower: default: 10 format: int64 @@ -15026,6 +15038,10 @@ spec: items: type: string type: array + nodeSelector: + additionalProperties: + type: string + type: object replicas: default: 1 format: int32 diff --git a/go.mod b/go.mod index 77b93dff9..2f26b4ca6 100644 --- a/go.mod +++ b/go.mod @@ -36,7 +36,7 @@ require ( github.com/openstack-k8s-operators/openstack-operator/apis v0.0.0-20240531084739-3b4c0451297c github.com/openstack-k8s-operators/ovn-operator/api v0.5.1-0.20241121095319-a34ad51b8446 github.com/openstack-k8s-operators/placement-operator/api v0.5.1-0.20241119131546-e4c1ba679d22 - github.com/openstack-k8s-operators/swift-operator/api v0.5.1-0.20241114094619-107d1aac9458 + github.com/openstack-k8s-operators/swift-operator/api v0.5.1-0.20241121093118-6ab57de4e6cc github.com/openstack-k8s-operators/telemetry-operator/api v0.5.1-0.20241118203716-9550c8740911 github.com/openstack-k8s-operators/test-operator/api v0.5.1-0.20241118150825-cd41d06be047 github.com/rabbitmq/cluster-operator/v2 v2.11.0 diff --git a/go.sum b/go.sum index 299ab7f48..f425349ff 100644 --- a/go.sum +++ b/go.sum @@ -148,8 +148,8 @@ github.com/openstack-k8s-operators/placement-operator/api v0.5.1-0.2024111913154 github.com/openstack-k8s-operators/placement-operator/api v0.5.1-0.20241119131546-e4c1ba679d22/go.mod h1:3XfvmllEbmTSFzX44Smpq5Ec5nzNAU+aiMgrYKwiXs4= github.com/openstack-k8s-operators/rabbitmq-cluster-operator/v2 v2.6.1-0.20241017142550-a3524acedd49 h1:/7SnnHfGCH/dwuZFNUx54zw4cnwv2w6hjONq16aoowM= github.com/openstack-k8s-operators/rabbitmq-cluster-operator/v2 v2.6.1-0.20241017142550-a3524acedd49/go.mod h1:6Mq2N/KtNFW20L+PQC5qkeK8R8UGadmGBXL8HDY6lcg= -github.com/openstack-k8s-operators/swift-operator/api v0.5.1-0.20241114094619-107d1aac9458 h1:jLM1a3sClYUKfWHdZzTZI9RIpJGA+H8XQh321CbO0D0= -github.com/openstack-k8s-operators/swift-operator/api v0.5.1-0.20241114094619-107d1aac9458/go.mod h1:JlOTO8hnn/RCDtmZXAvnpudqv38eEFGX6nbfwEbltv8= +github.com/openstack-k8s-operators/swift-operator/api v0.5.1-0.20241121093118-6ab57de4e6cc h1:ObbwXZbbXk+PQpYPZWmisdwzQaSHv9Lyk1juBLJctnM= +github.com/openstack-k8s-operators/swift-operator/api v0.5.1-0.20241121093118-6ab57de4e6cc/go.mod h1:JlOTO8hnn/RCDtmZXAvnpudqv38eEFGX6nbfwEbltv8= github.com/openstack-k8s-operators/telemetry-operator/api v0.5.1-0.20241118203716-9550c8740911 h1:4OysgPT+NOnOtC7dAKc9xdHLnVdEMz6JYDwFd6w3fxI= github.com/openstack-k8s-operators/telemetry-operator/api v0.5.1-0.20241118203716-9550c8740911/go.mod h1:wpC0oQUkW/a/BjgzZOEwknnKJxHY0DeAIqtAh7WNwSs= github.com/openstack-k8s-operators/test-operator/api v0.5.1-0.20241118150825-cd41d06be047 h1:7fq7Zl2uFWHLWc4CLvEBEuIvKLO0JYDrqBZ1wtDfBQ8= diff --git a/pkg/openstack/swift.go b/pkg/openstack/swift.go index afcc04c77..700e51315 100644 --- a/pkg/openstack/swift.go +++ b/pkg/openstack/swift.go @@ -46,6 +46,10 @@ func ReconcileSwift(ctx context.Context, instance *corev1beta1.OpenStackControlP instance.Spec.Swift.Template = &swiftv1.SwiftSpecCore{} } + if instance.Spec.Swift.Template.NodeSelector == nil { + instance.Spec.Swift.Template.NodeSelector = &instance.Spec.NodeSelector + } + // add selector to service overrides for _, endpointType := range []service.Endpoint{service.EndpointPublic, service.EndpointInternal} { if instance.Spec.Swift.Template.SwiftProxy.Override.Service == nil { From 33b160d73b1be3415259d3f9351b2095a176776c Mon Sep 17 00:00:00 2001 From: Oliver Walsh Date: Thu, 21 Nov 2024 10:53:41 +0000 Subject: [PATCH 07/14] Inherit top-level nodeSelector in telemetry template --- .../core.openstack.org_openstackcontrolplanes.yaml | 13 ++++++++++++- apis/go.mod | 2 +- apis/go.sum | 4 ++-- .../core.openstack.org_openstackcontrolplanes.yaml | 13 ++++++++++++- go.mod | 2 +- go.sum | 4 ++-- pkg/openstack/telemetry.go | 4 ++++ 7 files changed, 34 insertions(+), 8 deletions(-) diff --git a/apis/bases/core.openstack.org_openstackcontrolplanes.yaml b/apis/bases/core.openstack.org_openstackcontrolplanes.yaml index cec46e70f..3ae4a450e 100644 --- a/apis/bases/core.openstack.org_openstackcontrolplanes.yaml +++ b/apis/bases/core.openstack.org_openstackcontrolplanes.yaml @@ -15482,6 +15482,10 @@ spec: items: type: string type: array + nodeSelector: + additionalProperties: + type: string + type: object override: properties: service: @@ -15576,7 +15580,6 @@ spec: type: object required: - databaseInstance - - memcachedInstance - secret type: object enabled: @@ -15634,6 +15637,10 @@ spec: items: type: string type: array + nodeSelector: + additionalProperties: + type: string + type: object passwordSelector: default: ceilometerService: CeilometerPassword @@ -16360,6 +16367,10 @@ spec: type: string type: object type: object + nodeSelector: + additionalProperties: + type: string + type: object type: object type: object tls: diff --git a/apis/go.mod b/apis/go.mod index b067c0447..7a1f84419 100644 --- a/apis/go.mod +++ b/apis/go.mod @@ -27,7 +27,7 @@ require ( github.com/openstack-k8s-operators/ovn-operator/api v0.5.1-0.20241121095319-a34ad51b8446 github.com/openstack-k8s-operators/placement-operator/api v0.5.1-0.20241119131546-e4c1ba679d22 github.com/openstack-k8s-operators/swift-operator/api v0.5.1-0.20241121093118-6ab57de4e6cc - github.com/openstack-k8s-operators/telemetry-operator/api v0.5.1-0.20241118203716-9550c8740911 + github.com/openstack-k8s-operators/telemetry-operator/api v0.5.1-0.20241121100420-f2c8dd9aa6c3 github.com/rabbitmq/cluster-operator/v2 v2.11.0 github.com/rhobs/obo-prometheus-operator/pkg/apis/monitoring v0.71.0-rhobs1 // indirect github.com/rhobs/observability-operator v0.3.1 // indirect diff --git a/apis/go.sum b/apis/go.sum index 9ed8b5fb1..bfb5a029c 100644 --- a/apis/go.sum +++ b/apis/go.sum @@ -138,8 +138,8 @@ github.com/openstack-k8s-operators/rabbitmq-cluster-operator/v2 v2.6.1-0.2024101 github.com/openstack-k8s-operators/rabbitmq-cluster-operator/v2 v2.6.1-0.20241017142550-a3524acedd49/go.mod h1:6Mq2N/KtNFW20L+PQC5qkeK8R8UGadmGBXL8HDY6lcg= github.com/openstack-k8s-operators/swift-operator/api v0.5.1-0.20241121093118-6ab57de4e6cc h1:ObbwXZbbXk+PQpYPZWmisdwzQaSHv9Lyk1juBLJctnM= github.com/openstack-k8s-operators/swift-operator/api v0.5.1-0.20241121093118-6ab57de4e6cc/go.mod h1:JlOTO8hnn/RCDtmZXAvnpudqv38eEFGX6nbfwEbltv8= -github.com/openstack-k8s-operators/telemetry-operator/api v0.5.1-0.20241118203716-9550c8740911 h1:4OysgPT+NOnOtC7dAKc9xdHLnVdEMz6JYDwFd6w3fxI= -github.com/openstack-k8s-operators/telemetry-operator/api v0.5.1-0.20241118203716-9550c8740911/go.mod h1:wpC0oQUkW/a/BjgzZOEwknnKJxHY0DeAIqtAh7WNwSs= +github.com/openstack-k8s-operators/telemetry-operator/api v0.5.1-0.20241121100420-f2c8dd9aa6c3 h1:w4OXa9ozND2cI155qktb7OUiRjKiw1yMLf4BQm+qs7g= +github.com/openstack-k8s-operators/telemetry-operator/api v0.5.1-0.20241121100420-f2c8dd9aa6c3/go.mod h1:wpC0oQUkW/a/BjgzZOEwknnKJxHY0DeAIqtAh7WNwSs= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= diff --git a/config/crd/bases/core.openstack.org_openstackcontrolplanes.yaml b/config/crd/bases/core.openstack.org_openstackcontrolplanes.yaml index cec46e70f..3ae4a450e 100644 --- a/config/crd/bases/core.openstack.org_openstackcontrolplanes.yaml +++ b/config/crd/bases/core.openstack.org_openstackcontrolplanes.yaml @@ -15482,6 +15482,10 @@ spec: items: type: string type: array + nodeSelector: + additionalProperties: + type: string + type: object override: properties: service: @@ -15576,7 +15580,6 @@ spec: type: object required: - databaseInstance - - memcachedInstance - secret type: object enabled: @@ -15634,6 +15637,10 @@ spec: items: type: string type: array + nodeSelector: + additionalProperties: + type: string + type: object passwordSelector: default: ceilometerService: CeilometerPassword @@ -16360,6 +16367,10 @@ spec: type: string type: object type: object + nodeSelector: + additionalProperties: + type: string + type: object type: object type: object tls: diff --git a/go.mod b/go.mod index 2f26b4ca6..5b21b064f 100644 --- a/go.mod +++ b/go.mod @@ -37,7 +37,7 @@ require ( github.com/openstack-k8s-operators/ovn-operator/api v0.5.1-0.20241121095319-a34ad51b8446 github.com/openstack-k8s-operators/placement-operator/api v0.5.1-0.20241119131546-e4c1ba679d22 github.com/openstack-k8s-operators/swift-operator/api v0.5.1-0.20241121093118-6ab57de4e6cc - github.com/openstack-k8s-operators/telemetry-operator/api v0.5.1-0.20241118203716-9550c8740911 + github.com/openstack-k8s-operators/telemetry-operator/api v0.5.1-0.20241121100420-f2c8dd9aa6c3 github.com/openstack-k8s-operators/test-operator/api v0.5.1-0.20241118150825-cd41d06be047 github.com/rabbitmq/cluster-operator/v2 v2.11.0 go.uber.org/zap v1.27.0 diff --git a/go.sum b/go.sum index f425349ff..7b97f11e1 100644 --- a/go.sum +++ b/go.sum @@ -150,8 +150,8 @@ github.com/openstack-k8s-operators/rabbitmq-cluster-operator/v2 v2.6.1-0.2024101 github.com/openstack-k8s-operators/rabbitmq-cluster-operator/v2 v2.6.1-0.20241017142550-a3524acedd49/go.mod h1:6Mq2N/KtNFW20L+PQC5qkeK8R8UGadmGBXL8HDY6lcg= github.com/openstack-k8s-operators/swift-operator/api v0.5.1-0.20241121093118-6ab57de4e6cc h1:ObbwXZbbXk+PQpYPZWmisdwzQaSHv9Lyk1juBLJctnM= github.com/openstack-k8s-operators/swift-operator/api v0.5.1-0.20241121093118-6ab57de4e6cc/go.mod h1:JlOTO8hnn/RCDtmZXAvnpudqv38eEFGX6nbfwEbltv8= -github.com/openstack-k8s-operators/telemetry-operator/api v0.5.1-0.20241118203716-9550c8740911 h1:4OysgPT+NOnOtC7dAKc9xdHLnVdEMz6JYDwFd6w3fxI= -github.com/openstack-k8s-operators/telemetry-operator/api v0.5.1-0.20241118203716-9550c8740911/go.mod h1:wpC0oQUkW/a/BjgzZOEwknnKJxHY0DeAIqtAh7WNwSs= +github.com/openstack-k8s-operators/telemetry-operator/api v0.5.1-0.20241121100420-f2c8dd9aa6c3 h1:w4OXa9ozND2cI155qktb7OUiRjKiw1yMLf4BQm+qs7g= +github.com/openstack-k8s-operators/telemetry-operator/api v0.5.1-0.20241121100420-f2c8dd9aa6c3/go.mod h1:wpC0oQUkW/a/BjgzZOEwknnKJxHY0DeAIqtAh7WNwSs= github.com/openstack-k8s-operators/test-operator/api v0.5.1-0.20241118150825-cd41d06be047 h1:7fq7Zl2uFWHLWc4CLvEBEuIvKLO0JYDrqBZ1wtDfBQ8= github.com/openstack-k8s-operators/test-operator/api v0.5.1-0.20241118150825-cd41d06be047/go.mod h1:+fnm5nepo//2fdEFWsGCWzjOyshRbomLTWN2ylo1PQI= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= diff --git a/pkg/openstack/telemetry.go b/pkg/openstack/telemetry.go index b9e08f9d7..9c72e91dc 100644 --- a/pkg/openstack/telemetry.go +++ b/pkg/openstack/telemetry.go @@ -58,6 +58,10 @@ func ReconcileTelemetry(ctx context.Context, instance *corev1beta1.OpenStackCont instance.Spec.Telemetry.Template = &telemetryv1.TelemetrySpecCore{} } + if instance.Spec.Telemetry.Template.NodeSelector == nil { + instance.Spec.Telemetry.Template.NodeSelector = &instance.Spec.NodeSelector + } + if err := helper.GetClient().Get(ctx, types.NamespacedName{Name: "telemetry", Namespace: instance.Namespace}, telemetry); err != nil { if !k8s_errors.IsNotFound(err) { return ctrl.Result{}, err From 5928a4cb8c0303a8d39cd21a71e8fe5317f1e640 Mon Sep 17 00:00:00 2001 From: Oliver Walsh Date: Thu, 21 Nov 2024 10:58:10 +0000 Subject: [PATCH 08/14] Inherit top-level nodeSelector in octavia template --- apis/go.mod | 2 +- apis/go.sum | 4 ++-- go.mod | 2 +- go.sum | 4 ++-- pkg/openstack/octavia.go | 4 ++++ 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/apis/go.mod b/apis/go.mod index 7a1f84419..d19a17748 100644 --- a/apis/go.mod +++ b/apis/go.mod @@ -22,7 +22,7 @@ require ( github.com/openstack-k8s-operators/mariadb-operator/api v0.5.1-0.20241120160542-4b457715f74e github.com/openstack-k8s-operators/neutron-operator/api v0.5.1-0.20241121095318-591a3bcbcda6 github.com/openstack-k8s-operators/nova-operator/api v0.5.1-0.20241119125634-42b7b8417b48 - github.com/openstack-k8s-operators/octavia-operator/api v0.5.1-0.20241115111947-2336829c2d73 + github.com/openstack-k8s-operators/octavia-operator/api v0.5.1-0.20241121093935-bc64ab6db016 github.com/openstack-k8s-operators/openstack-baremetal-operator/api v0.5.1-0.20241118111717-a1d460a6d81f github.com/openstack-k8s-operators/ovn-operator/api v0.5.1-0.20241121095319-a34ad51b8446 github.com/openstack-k8s-operators/placement-operator/api v0.5.1-0.20241119131546-e4c1ba679d22 diff --git a/apis/go.sum b/apis/go.sum index bfb5a029c..619449aed 100644 --- a/apis/go.sum +++ b/apis/go.sum @@ -126,8 +126,8 @@ github.com/openstack-k8s-operators/neutron-operator/api v0.5.1-0.20241121095318- github.com/openstack-k8s-operators/neutron-operator/api v0.5.1-0.20241121095318-591a3bcbcda6/go.mod h1:Kfuu3g4PSFpEowdWhbnTgSlDpsBGswQf/WU/kKQKK7s= github.com/openstack-k8s-operators/nova-operator/api v0.5.1-0.20241119125634-42b7b8417b48 h1:eCvn/lCMqWTvlN74nFr7nG2EvZdvJPdSR9Ts2eTaM6c= github.com/openstack-k8s-operators/nova-operator/api v0.5.1-0.20241119125634-42b7b8417b48/go.mod h1:330SfEZuqG3b90HopY+Hk90y0OTyPcBa0GRKPUD7BHE= -github.com/openstack-k8s-operators/octavia-operator/api v0.5.1-0.20241115111947-2336829c2d73 h1:HWHbtCBbTv3zvluSpV4ZG8Ov0VJxUn5uJOrH8orSnQs= -github.com/openstack-k8s-operators/octavia-operator/api v0.5.1-0.20241115111947-2336829c2d73/go.mod h1:3bFE3g3OCC2vtwhxDKdjV7sezTj4yFeqP0C40Z5NOEA= +github.com/openstack-k8s-operators/octavia-operator/api v0.5.1-0.20241121093935-bc64ab6db016 h1:3e98HQ5eP3S5cdQ3/G4BpipgbtHiY6fDN+CYo2z3RqU= +github.com/openstack-k8s-operators/octavia-operator/api v0.5.1-0.20241121093935-bc64ab6db016/go.mod h1:3bFE3g3OCC2vtwhxDKdjV7sezTj4yFeqP0C40Z5NOEA= github.com/openstack-k8s-operators/openstack-baremetal-operator/api v0.5.1-0.20241118111717-a1d460a6d81f h1:2aM3rxATUmgPdghtm8MoN2WVACMI5XYSQFv1JZV8iqA= github.com/openstack-k8s-operators/openstack-baremetal-operator/api v0.5.1-0.20241118111717-a1d460a6d81f/go.mod h1:G9nampuSFs/9i2Ldx3OasU6oehWchwYuhBu1qMWktMg= github.com/openstack-k8s-operators/ovn-operator/api v0.5.1-0.20241121095319-a34ad51b8446 h1:IPbI+S2an1puMVCKzyW6dBwsTJ9QmaK1Cj9/qFHrHMY= diff --git a/go.mod b/go.mod index 5b21b064f..9c6d770b7 100644 --- a/go.mod +++ b/go.mod @@ -31,7 +31,7 @@ require ( github.com/openstack-k8s-operators/mariadb-operator/api v0.5.1-0.20241120160542-4b457715f74e github.com/openstack-k8s-operators/neutron-operator/api v0.5.1-0.20241121095318-591a3bcbcda6 github.com/openstack-k8s-operators/nova-operator/api v0.5.1-0.20241119125634-42b7b8417b48 - github.com/openstack-k8s-operators/octavia-operator/api v0.5.1-0.20241115111947-2336829c2d73 + github.com/openstack-k8s-operators/octavia-operator/api v0.5.1-0.20241121093935-bc64ab6db016 github.com/openstack-k8s-operators/openstack-baremetal-operator/api v0.5.1-0.20241118111717-a1d460a6d81f github.com/openstack-k8s-operators/openstack-operator/apis v0.0.0-20240531084739-3b4c0451297c github.com/openstack-k8s-operators/ovn-operator/api v0.5.1-0.20241121095319-a34ad51b8446 diff --git a/go.sum b/go.sum index 7b97f11e1..ac806dec7 100644 --- a/go.sum +++ b/go.sum @@ -138,8 +138,8 @@ github.com/openstack-k8s-operators/neutron-operator/api v0.5.1-0.20241121095318- github.com/openstack-k8s-operators/neutron-operator/api v0.5.1-0.20241121095318-591a3bcbcda6/go.mod h1:Kfuu3g4PSFpEowdWhbnTgSlDpsBGswQf/WU/kKQKK7s= github.com/openstack-k8s-operators/nova-operator/api v0.5.1-0.20241119125634-42b7b8417b48 h1:eCvn/lCMqWTvlN74nFr7nG2EvZdvJPdSR9Ts2eTaM6c= github.com/openstack-k8s-operators/nova-operator/api v0.5.1-0.20241119125634-42b7b8417b48/go.mod h1:330SfEZuqG3b90HopY+Hk90y0OTyPcBa0GRKPUD7BHE= -github.com/openstack-k8s-operators/octavia-operator/api v0.5.1-0.20241115111947-2336829c2d73 h1:HWHbtCBbTv3zvluSpV4ZG8Ov0VJxUn5uJOrH8orSnQs= -github.com/openstack-k8s-operators/octavia-operator/api v0.5.1-0.20241115111947-2336829c2d73/go.mod h1:3bFE3g3OCC2vtwhxDKdjV7sezTj4yFeqP0C40Z5NOEA= +github.com/openstack-k8s-operators/octavia-operator/api v0.5.1-0.20241121093935-bc64ab6db016 h1:3e98HQ5eP3S5cdQ3/G4BpipgbtHiY6fDN+CYo2z3RqU= +github.com/openstack-k8s-operators/octavia-operator/api v0.5.1-0.20241121093935-bc64ab6db016/go.mod h1:3bFE3g3OCC2vtwhxDKdjV7sezTj4yFeqP0C40Z5NOEA= github.com/openstack-k8s-operators/openstack-baremetal-operator/api v0.5.1-0.20241118111717-a1d460a6d81f h1:2aM3rxATUmgPdghtm8MoN2WVACMI5XYSQFv1JZV8iqA= github.com/openstack-k8s-operators/openstack-baremetal-operator/api v0.5.1-0.20241118111717-a1d460a6d81f/go.mod h1:G9nampuSFs/9i2Ldx3OasU6oehWchwYuhBu1qMWktMg= github.com/openstack-k8s-operators/ovn-operator/api v0.5.1-0.20241121095319-a34ad51b8446 h1:IPbI+S2an1puMVCKzyW6dBwsTJ9QmaK1Cj9/qFHrHMY= diff --git a/pkg/openstack/octavia.go b/pkg/openstack/octavia.go index c3b2803c9..8a59cff54 100644 --- a/pkg/openstack/octavia.go +++ b/pkg/openstack/octavia.go @@ -64,6 +64,10 @@ func ReconcileOctavia(ctx context.Context, instance *corev1beta1.OpenStackContro instance.Spec.Octavia.Template = &octaviav1.OctaviaSpecCore{} } + if instance.Spec.Octavia.Template.NodeSelector == nil { + instance.Spec.Octavia.Template.NodeSelector = &instance.Spec.NodeSelector + } + // add selector to service overrides for _, endpointType := range []service.Endpoint{service.EndpointPublic, service.EndpointInternal} { if instance.Spec.Octavia.Template.OctaviaAPI.Override.Service == nil { From d3045b129d09122dd5403cd4b4612f2f3adea895 Mon Sep 17 00:00:00 2001 From: Oliver Walsh Date: Thu, 21 Nov 2024 11:07:06 +0000 Subject: [PATCH 09/14] Inherit top-level nodeSelector in rabbitmq template --- ...re.openstack.org_openstackcontrolplanes.yaml | 4 ++++ .../core/v1beta1/openstackcontrolplane_types.go | 4 ++++ apis/core/v1beta1/zz_generated.deepcopy.go | 11 +++++++++++ ...re.openstack.org_openstackcontrolplanes.yaml | 4 ++++ pkg/openstack/rabbitmq.go | 17 ++++++++++++----- 5 files changed, 35 insertions(+), 5 deletions(-) diff --git a/apis/bases/core.openstack.org_openstackcontrolplanes.yaml b/apis/bases/core.openstack.org_openstackcontrolplanes.yaml index 3ae4a450e..669280c40 100644 --- a/apis/bases/core.openstack.org_openstackcontrolplanes.yaml +++ b/apis/bases/core.openstack.org_openstackcontrolplanes.yaml @@ -10879,6 +10879,10 @@ spec: format: int32 minimum: 0 type: integer + nodeSelector: + additionalProperties: + type: string + type: object override: properties: service: diff --git a/apis/core/v1beta1/openstackcontrolplane_types.go b/apis/core/v1beta1/openstackcontrolplane_types.go index 54db1050f..b7a5bdec3 100644 --- a/apis/core/v1beta1/openstackcontrolplane_types.go +++ b/apis/core/v1beta1/openstackcontrolplane_types.go @@ -507,6 +507,10 @@ type RabbitmqTemplate struct { // +operator-sdk:csv:customresourcedefinitions:type=spec // Overrides to use when creating the Rabbitmq clusters rabbitmqv2.RabbitmqClusterSpecCore `json:",inline"` + // +kubebuilder:validation:Optional + // +operator-sdk:csv:customresourcedefinitions:type=spec + // NodeSelector to target subset of worker nodes running this service + NodeSelector *map[string]string `json:"nodeSelector,omitempty"` } // OvnSection defines the desired state of OVN services diff --git a/apis/core/v1beta1/zz_generated.deepcopy.go b/apis/core/v1beta1/zz_generated.deepcopy.go index 6b7938f14..9e3ebff7c 100644 --- a/apis/core/v1beta1/zz_generated.deepcopy.go +++ b/apis/core/v1beta1/zz_generated.deepcopy.go @@ -1470,6 +1470,17 @@ func (in *RabbitmqSection) DeepCopy() *RabbitmqSection { func (in *RabbitmqTemplate) DeepCopyInto(out *RabbitmqTemplate) { *out = *in in.RabbitmqClusterSpecCore.DeepCopyInto(&out.RabbitmqClusterSpecCore) + if in.NodeSelector != nil { + in, out := &in.NodeSelector, &out.NodeSelector + *out = new(map[string]string) + if **in != nil { + in, out := *in, *out + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RabbitmqTemplate. diff --git a/config/crd/bases/core.openstack.org_openstackcontrolplanes.yaml b/config/crd/bases/core.openstack.org_openstackcontrolplanes.yaml index 3ae4a450e..669280c40 100644 --- a/config/crd/bases/core.openstack.org_openstackcontrolplanes.yaml +++ b/config/crd/bases/core.openstack.org_openstackcontrolplanes.yaml @@ -10879,6 +10879,10 @@ spec: format: int32 minimum: 0 type: integer + nodeSelector: + additionalProperties: + type: string + type: object override: properties: service: diff --git a/pkg/openstack/rabbitmq.go b/pkg/openstack/rabbitmq.go index cbe7c21f9..c1f3ef979 100644 --- a/pkg/openstack/rabbitmq.go +++ b/pkg/openstack/rabbitmq.go @@ -310,6 +310,18 @@ func reconcileRabbitMQ( tlsCert = certSecret.Name } + if spec.Override.StatefulSet == nil { + spec.Override.StatefulSet = &defaultStatefulSet + } + + if spec.Override.StatefulSet.Spec.Template.Spec.NodeSelector == nil { + if spec.NodeSelector != nil { + spec.Override.StatefulSet.Spec.Template.Spec.NodeSelector = *spec.NodeSelector + } else { + spec.Override.StatefulSet.Spec.Template.Spec.NodeSelector = instance.Spec.NodeSelector + } + } + op, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), rabbitmq, func() error { rabbitmq.Spec.Image = *version.Status.ContainerImages.RabbitmqImage @@ -362,11 +374,6 @@ func reconcileRabbitMQ( rabbitmq.Spec.Persistence.StorageClassName = &instance.Spec.StorageClass } - if rabbitmq.Spec.Override.StatefulSet == nil { - Log.Info("Setting StatefulSet") - rabbitmq.Spec.Override.StatefulSet = &defaultStatefulSet - } - if rabbitmq.Spec.Override.Service != nil && rabbitmq.Spec.Override.Service.Spec != nil && rabbitmq.Spec.Override.Service.Spec.Type == corev1.ServiceTypeLoadBalancer { From ffe39d55ba04256eff1ed026cde86c9eeac9280c Mon Sep 17 00:00:00 2001 From: Oliver Walsh Date: Thu, 21 Nov 2024 11:13:04 +0000 Subject: [PATCH 10/14] Inherit top-level nodeSelector in openstackclient template --- apis/client/v1beta1/openstackclient_types.go | 4 ++-- apis/client/v1beta1/zz_generated.deepcopy.go | 10 +++++++--- pkg/openstack/openstackclient.go | 4 ++++ pkg/openstackclient/funcs.go | 4 ++-- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/apis/client/v1beta1/openstackclient_types.go b/apis/client/v1beta1/openstackclient_types.go index 9c6a12fa9..f2e044574 100644 --- a/apis/client/v1beta1/openstackclient_types.go +++ b/apis/client/v1beta1/openstackclient_types.go @@ -49,8 +49,8 @@ type OpenStackClientSpecCore struct { OpenStackConfigSecret *string `json:"openStackConfigSecret"` // +kubebuilder:validation:Optional - // NodeSelector to target subset of worker nodes running control plane services (currently only applies to KeystoneAPI and PlacementAPI) - NodeSelector map[string]string `json:"nodeSelector,omitempty"` + // NodeSelector to target subset of worker nodes + NodeSelector *map[string]string `json:"nodeSelector,omitempty"` // +kubebuilder:validation:Optional // +operator-sdk:csv:customresourcedefinitions:type=spec diff --git a/apis/client/v1beta1/zz_generated.deepcopy.go b/apis/client/v1beta1/zz_generated.deepcopy.go index 2cc8c40c9..010dfef40 100644 --- a/apis/client/v1beta1/zz_generated.deepcopy.go +++ b/apis/client/v1beta1/zz_generated.deepcopy.go @@ -131,9 +131,13 @@ func (in *OpenStackClientSpecCore) DeepCopyInto(out *OpenStackClientSpecCore) { } if in.NodeSelector != nil { in, out := &in.NodeSelector, &out.NodeSelector - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val + *out = new(map[string]string) + if **in != nil { + in, out := *in, *out + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } } } out.Ca = in.Ca diff --git a/pkg/openstack/openstackclient.go b/pkg/openstack/openstackclient.go index 4f49f0870..efc7fd520 100644 --- a/pkg/openstack/openstackclient.go +++ b/pkg/openstack/openstackclient.go @@ -47,6 +47,10 @@ func ReconcileOpenStackClient(ctx context.Context, instance *corev1.OpenStackCon return ctrl.Result{}, nil } + if instance.Spec.OpenStackClient.Template.NodeSelector == nil { + instance.Spec.OpenStackClient.Template.NodeSelector = &instance.Spec.NodeSelector + } + Log.Info("Reconciling OpenStackClient", "OpenStackClient.Namespace", instance.Namespace, "OpenStackClient.Name", openstackclient.Name) op, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), openstackclient, func() error { instance.Spec.OpenStackClient.Template.DeepCopyInto(&openstackclient.Spec.OpenStackClientSpecCore) diff --git a/pkg/openstackclient/funcs.go b/pkg/openstackclient/funcs.go index 661ce4302..c3975efea 100644 --- a/pkg/openstackclient/funcs.go +++ b/pkg/openstackclient/funcs.go @@ -87,8 +87,8 @@ func ClientPodSpec( }, } - if instance.Spec.NodeSelector != nil && len(instance.Spec.NodeSelector) > 0 { - podSpec.NodeSelector = instance.Spec.NodeSelector + if instance.Spec.NodeSelector != nil { + podSpec.NodeSelector = *instance.Spec.NodeSelector } return podSpec From 9fc57311e73af5ab12c6f41a1c6793fffdb855fd Mon Sep 17 00:00:00 2001 From: Oliver Walsh Date: Thu, 21 Nov 2024 11:41:41 +0000 Subject: [PATCH 11/14] Add functional tests for openstackclient and rabbitmq nodeSelector --- .../openstackoperator_controller_test.go | 143 +++++++++++++++--- 1 file changed, 122 insertions(+), 21 deletions(-) diff --git a/tests/functional/ctlplane/openstackoperator_controller_test.go b/tests/functional/ctlplane/openstackoperator_controller_test.go index d901b5e35..03e46dba3 100644 --- a/tests/functional/ctlplane/openstackoperator_controller_test.go +++ b/tests/functional/ctlplane/openstackoperator_controller_test.go @@ -1822,27 +1822,57 @@ var _ = Describe("OpenStackOperator controller", func() { th.DeleteInstance, CreateOpenStackControlPlane(names.OpenStackControlplaneName, spec), ) + + Eventually(func(g Gomega) { + keystoneAPI := keystone.GetKeystoneAPI(names.KeystoneAPIName) + g.Expect(keystoneAPI).Should(Not(BeNil())) + }, timeout, interval).Should(Succeed()) + keystone.SimulateKeystoneAPIReady(names.KeystoneAPIName) + + Eventually(func(g Gomega) { + osversion := GetOpenStackVersion(names.OpenStackControlplaneName) + g.Expect(osversion).Should(Not(BeNil())) + + th.ExpectCondition( + names.OpenStackVersionName, + ConditionGetterFunc(OpenStackVersionConditionGetter), + corev1.OpenStackVersionInitialized, + k8s_corev1.ConditionTrue, + ) + }, timeout, interval).Should(Succeed()) + + th.CreateSecret(types.NamespacedName{Name: "openstack-config-secret", Namespace: namespace}, map[string][]byte{"secure.yaml": []byte("foo")}) + th.CreateConfigMap(types.NamespacedName{Name: "openstack-config", Namespace: namespace}, map[string]interface{}{"clouds.yaml": string("foo"), "OS_CLOUD": "default"}) }) - It("should set the galera nodeSelector", func() { + It("sets nodeSelector in resource specs", func() { + Eventually(func(g Gomega) { + osc := th.GetPod(names.OpenStackClientName) + g.Expect(osc.Spec.NodeSelector).To(Equal(map[string]string{"foo": "bar"})) + }, timeout, interval).Should(Succeed()) Eventually(func(g Gomega) { db := mariadb.GetGalera(names.DBName) g.Expect(*db.Spec.NodeSelector).To(Equal(map[string]string{"foo": "bar"})) }, timeout, interval).Should(Succeed()) Eventually(func(g Gomega) { - db := mariadb.GetGalera(names.DBCell1Name) - g.Expect(*db.Spec.NodeSelector).To(Equal(map[string]string{"foo": "bar"})) + rmq := GetRabbitMQCluster(names.RabbitMQName) + g.Expect(rmq.Spec.Override.StatefulSet.Spec.Template.Spec.NodeSelector).To(Equal(map[string]string{"foo": "bar"})) }, timeout, interval).Should(Succeed()) + }) - It("should update the galera nodeSelector", func() { + It("updates nodeSelector in resource specs when changed", func() { + Eventually(func(g Gomega) { + osc := th.GetPod(names.OpenStackClientName) + g.Expect(osc.Spec.NodeSelector).To(Equal(map[string]string{"foo": "bar"})) + }, timeout, interval).Should(Succeed()) Eventually(func(g Gomega) { db := mariadb.GetGalera(names.DBName) g.Expect(*db.Spec.NodeSelector).To(Equal(map[string]string{"foo": "bar"})) }, timeout, interval).Should(Succeed()) Eventually(func(g Gomega) { - db := mariadb.GetGalera(names.DBCell1Name) - g.Expect(*db.Spec.NodeSelector).To(Equal(map[string]string{"foo": "bar"})) + rmq := GetRabbitMQCluster(names.RabbitMQName) + g.Expect(rmq.Spec.Override.StatefulSet.Spec.Template.Spec.NodeSelector).To(Equal(map[string]string{"foo": "bar"})) }, timeout, interval).Should(Succeed()) Eventually(func(g Gomega) { @@ -1854,55 +1884,126 @@ var _ = Describe("OpenStackOperator controller", func() { g.Expect(k8sClient.Update(ctx, OSCtlplane)).Should(Succeed()) }, timeout, interval).Should(Succeed()) + Eventually(func(g Gomega) { + osc := th.GetPod(names.OpenStackClientName) + g.Expect(osc.Spec.NodeSelector).To(Equal(map[string]string{"foo2": "bar2"})) + }, timeout, interval).Should(Succeed()) Eventually(func(g Gomega) { db := mariadb.GetGalera(names.DBName) g.Expect(*db.Spec.NodeSelector).To(Equal(map[string]string{"foo2": "bar2"})) }, timeout, interval).Should(Succeed()) Eventually(func(g Gomega) { - db := mariadb.GetGalera(names.DBCell1Name) - g.Expect(*db.Spec.NodeSelector).To(Equal(map[string]string{"foo2": "bar2"})) + rmq := GetRabbitMQCluster(names.RabbitMQName) + g.Expect(rmq.Spec.Override.StatefulSet.Spec.Template.Spec.NodeSelector).To(Equal(map[string]string{"foo2": "bar2"})) }, timeout, interval).Should(Succeed()) }) - It("should allow the galera nodeSelector to be overridden", func() { + It("allows nodeSelector service override", func() { + Eventually(func(g Gomega) { + osc := th.GetPod(names.OpenStackClientName) + g.Expect(osc.Spec.NodeSelector).To(Equal(map[string]string{"foo": "bar"})) + }, timeout, interval).Should(Succeed()) Eventually(func(g Gomega) { db := mariadb.GetGalera(names.DBName) g.Expect(*db.Spec.NodeSelector).To(Equal(map[string]string{"foo": "bar"})) }, timeout, interval).Should(Succeed()) Eventually(func(g Gomega) { - db := mariadb.GetGalera(names.DBCell1Name) - g.Expect(*db.Spec.NodeSelector).To(Equal(map[string]string{"foo": "bar"})) + rmq := GetRabbitMQCluster(names.RabbitMQName) + g.Expect(rmq.Spec.Override.StatefulSet.Spec.Template.Spec.NodeSelector).To(Equal(map[string]string{"foo": "bar"})) }, timeout, interval).Should(Succeed()) Eventually(func(g Gomega) { OSCtlplane := GetOpenStackControlPlane(names.OpenStackControlplaneName) - newNodeSelector := map[string]string{ - "foo2": "bar2", + oscNodeSelector := map[string]string{ + "foo": "osc", + } + OSCtlplane.Spec.OpenStackClient.Template.NodeSelector = &oscNodeSelector + + galeraNodeSelector := map[string]string{ + "foo": "galera", } galeraTemplates := *(OSCtlplane.Spec.Galera.Templates) dbTemplate := galeraTemplates[names.DBName.Name] - dbTemplate.NodeSelector = &newNodeSelector + dbTemplate.NodeSelector = &galeraNodeSelector galeraTemplates[names.DBName.Name] = dbTemplate + OSCtlplane.Spec.Galera.Templates = &galeraTemplates + + rmqNodeSelector := map[string]string{ + "foo": "rmq", + } + rmqTemplates := *OSCtlplane.Spec.Rabbitmq.Templates + rmqTemplate := rmqTemplates[names.RabbitMQName.Name] + rmqTemplate.NodeSelector = &rmqNodeSelector + rmqTemplates[names.RabbitMQName.Name] = rmqTemplate + OSCtlplane.Spec.Rabbitmq.Templates = &rmqTemplates - emptyNodeSelector := map[string]string{} - cell1Template := galeraTemplates[names.DBCell1Name.Name] - cell1Template.NodeSelector = &emptyNodeSelector - galeraTemplates[names.DBCell1Name.Name] = cell1Template + g.Expect(k8sClient.Update(ctx, OSCtlplane)).Should(Succeed()) + }, timeout, interval).Should(Succeed()) + + Eventually(func(g Gomega) { + osc := th.GetPod(names.OpenStackClientName) + g.Expect(osc.Spec.NodeSelector).To(Equal(map[string]string{"foo": "osc"})) + }, timeout, interval).Should(Succeed()) + Eventually(func(g Gomega) { + db := mariadb.GetGalera(names.DBName) + g.Expect(*db.Spec.NodeSelector).To(Equal(map[string]string{"foo": "galera"})) + }, timeout, interval).Should(Succeed()) + Eventually(func(g Gomega) { + rmq := GetRabbitMQCluster(names.RabbitMQName) + g.Expect(rmq.Spec.Override.StatefulSet.Spec.Template.Spec.NodeSelector).To(Equal(map[string]string{"foo": "rmq"})) + }, timeout, interval).Should(Succeed()) + }) + It("allows nodeSelector service override to empty", func() { + Eventually(func(g Gomega) { + osc := th.GetPod(names.OpenStackClientName) + g.Expect(osc.Spec.NodeSelector).To(Equal(map[string]string{"foo": "bar"})) + }, timeout, interval).Should(Succeed()) + Eventually(func(g Gomega) { + db := mariadb.GetGalera(names.DBName) + g.Expect(*db.Spec.NodeSelector).To(Equal(map[string]string{"foo": "bar"})) + }, timeout, interval).Should(Succeed()) + Eventually(func(g Gomega) { + rmq := GetRabbitMQCluster(names.RabbitMQName) + g.Expect(rmq.Spec.Override.StatefulSet.Spec.Template.Spec.NodeSelector).To(Equal(map[string]string{"foo": "bar"})) + }, timeout, interval).Should(Succeed()) + + Eventually(func(g Gomega) { + OSCtlplane := GetOpenStackControlPlane(names.OpenStackControlplaneName) + + oscNodeSelector := map[string]string{} + OSCtlplane.Spec.OpenStackClient.Template.NodeSelector = &oscNodeSelector + + galeraNodeSelector := map[string]string{} + galeraTemplates := *(OSCtlplane.Spec.Galera.Templates) + dbTemplate := galeraTemplates[names.DBName.Name] + dbTemplate.NodeSelector = &galeraNodeSelector + galeraTemplates[names.DBName.Name] = dbTemplate OSCtlplane.Spec.Galera.Templates = &galeraTemplates + rmqNodeSelector := map[string]string{} + rmqTemplates := *OSCtlplane.Spec.Rabbitmq.Templates + rmqTemplate := rmqTemplates[names.RabbitMQName.Name] + rmqTemplate.NodeSelector = &rmqNodeSelector + rmqTemplates[names.RabbitMQName.Name] = rmqTemplate + OSCtlplane.Spec.Rabbitmq.Templates = &rmqTemplates + g.Expect(k8sClient.Update(ctx, OSCtlplane)).Should(Succeed()) }, timeout, interval).Should(Succeed()) Eventually(func(g Gomega) { - db := mariadb.GetGalera(names.DBName) - g.Expect(*db.Spec.NodeSelector).To(Equal(map[string]string{"foo2": "bar2"})) + osc := th.GetPod(names.OpenStackClientName) + g.Expect(osc.Spec.NodeSelector).To(BeNil()) }, timeout, interval).Should(Succeed()) Eventually(func(g Gomega) { - db := mariadb.GetGalera(names.DBCell1Name) + db := mariadb.GetGalera(names.DBName) g.Expect(*db.Spec.NodeSelector).To(Equal(map[string]string{})) }, timeout, interval).Should(Succeed()) + Eventually(func(g Gomega) { + rmq := GetRabbitMQCluster(names.RabbitMQName) + g.Expect(rmq.Spec.Override.StatefulSet.Spec.Template.Spec.NodeSelector).To(BeNil()) + }, timeout, interval).Should(Succeed()) }) }) From ab2a01f045fd1dc04181448c7085af15c638b4c8 Mon Sep 17 00:00:00 2001 From: Oliver Walsh Date: Thu, 21 Nov 2024 12:00:46 +0000 Subject: [PATCH 12/14] Add kuttl test to catch any missing nodeSelectors dnsmasq that is created by the kuttl tests and ovn-controller-*-config is the only exception (sets a specific nodeName) --- .../nodeselectors/global/kustomization.yaml | 14 +++++++++++ .../samples/nodeselectors/global/patch.yaml | 7 ++++++ .../01-assert-deploy-openstack.yaml | 1 + .../01-deploy-openstack.yaml | 5 ++++ .../02-assert-nodeselector.yaml | 23 +++++++++++++++++++ .../03-assert-deploy-openstack.yaml | 1 + .../03-update-nodeselector.yaml | 16 +++++++++++++ .../04-assert-nodeselector.yaml | 23 +++++++++++++++++++ .../ctlplane-nodeselectors/05-cleanup.yaml | 13 +++++++++++ .../05-errors-cleanup.yaml | 1 + 10 files changed, 104 insertions(+) create mode 100644 config/samples/nodeselectors/global/kustomization.yaml create mode 100644 config/samples/nodeselectors/global/patch.yaml create mode 120000 tests/kuttl/tests/ctlplane-nodeselectors/01-assert-deploy-openstack.yaml create mode 100644 tests/kuttl/tests/ctlplane-nodeselectors/01-deploy-openstack.yaml create mode 100644 tests/kuttl/tests/ctlplane-nodeselectors/02-assert-nodeselector.yaml create mode 120000 tests/kuttl/tests/ctlplane-nodeselectors/03-assert-deploy-openstack.yaml create mode 100644 tests/kuttl/tests/ctlplane-nodeselectors/03-update-nodeselector.yaml create mode 100644 tests/kuttl/tests/ctlplane-nodeselectors/04-assert-nodeselector.yaml create mode 100644 tests/kuttl/tests/ctlplane-nodeselectors/05-cleanup.yaml create mode 120000 tests/kuttl/tests/ctlplane-nodeselectors/05-errors-cleanup.yaml diff --git a/config/samples/nodeselectors/global/kustomization.yaml b/config/samples/nodeselectors/global/kustomization.yaml new file mode 100644 index 000000000..94aa1cafb --- /dev/null +++ b/config/samples/nodeselectors/global/kustomization.yaml @@ -0,0 +1,14 @@ +resources: +- ../../base/openstackcontrolplane + +patches: +- target: + kind: OpenStackControlPlane + name: .* + patch: |- + - op: replace + path: /metadata/name + value: openstack +- target: + kind: OpenStackControlPlane + path: patch.yaml diff --git a/config/samples/nodeselectors/global/patch.yaml b/config/samples/nodeselectors/global/patch.yaml new file mode 100644 index 000000000..5b9fde167 --- /dev/null +++ b/config/samples/nodeselectors/global/patch.yaml @@ -0,0 +1,7 @@ +apiVersion: core.openstack.org/v1beta1 +kind: OpenStackControlPlane +metadata: + name: openstack +spec: + nodeSelector: + node-role.kubernetes.io/worker: "" diff --git a/tests/kuttl/tests/ctlplane-nodeselectors/01-assert-deploy-openstack.yaml b/tests/kuttl/tests/ctlplane-nodeselectors/01-assert-deploy-openstack.yaml new file mode 120000 index 000000000..762a8cf31 --- /dev/null +++ b/tests/kuttl/tests/ctlplane-nodeselectors/01-assert-deploy-openstack.yaml @@ -0,0 +1 @@ +../../common/assert-sample-deployment.yaml \ No newline at end of file diff --git a/tests/kuttl/tests/ctlplane-nodeselectors/01-deploy-openstack.yaml b/tests/kuttl/tests/ctlplane-nodeselectors/01-deploy-openstack.yaml new file mode 100644 index 000000000..bfffa10c8 --- /dev/null +++ b/tests/kuttl/tests/ctlplane-nodeselectors/01-deploy-openstack.yaml @@ -0,0 +1,5 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: + - script: | + oc kustomize ../../../../config/samples/nodeselectors/global | oc apply -n $NAMESPACE -f - diff --git a/tests/kuttl/tests/ctlplane-nodeselectors/02-assert-nodeselector.yaml b/tests/kuttl/tests/ctlplane-nodeselectors/02-assert-nodeselector.yaml new file mode 100644 index 000000000..dfb3f117a --- /dev/null +++ b/tests/kuttl/tests/ctlplane-nodeselectors/02-assert-nodeselector.yaml @@ -0,0 +1,23 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +commands: + - script: | + echo "Checking all pods have expected nodeselector" + EXPECTED_NODE_SELECTOR="node-role.kubernetes.io/worker:" + BAD_OR_MISSING_NODE_SELECTOR=$(oc get pods -n $NAMESPACE -l service!=dnsmasq -o=go-template --template='{{ range .items }}{{ .metadata.name}}: {{ .spec.nodeSelector }}{{"\n"}}{{ end }}' | grep -v 'ovn-controller-.*-config' | sed -e '\!map\['"$EXPECTED_NODE_SELECTOR"'\]$!d') + BAD_OR_MISSING_NODE_SELECTOR_COUNT=$(echo -n "$BAD_OR_MISSING_NODE_SELECTOR" | wc -l) + if [ $BAD_OR_MISSING_NODE_SELECTOR_COUNT -ne 0 ]; then + echo "Found $BAD_OR_MISSING_NODE_SELECTOR_COUNT pods with bad or missing nodeselector:" + echo "$BAD_OR_MISSING_NODE_SELECTOR" + exit 1 + fi + - script: | + echo "Checking all cronjobs have expected nodeselector" + EXPECTED_NODE_SELECTOR="node-role.kubernetes.io/worker:" + BAD_OR_MISSING_NODE_SELECTOR=$(oc get cronjobs -n $NAMESPACE -o=go-template --template='{{ range .items }}{{ .metadata.name}}: {{ .spec.jobTemplate.spec.template.spec.nodeSelector }}{{"\n"}}{{ end }}' | grep -v 'ovn-controller-.*-config' | sed -e '\!map\['"$EXPECTED_NODE_SELECTOR"'\]$!d') + BAD_OR_MISSING_NODE_SELECTOR_COUNT=$(echo -n "$BAD_OR_MISSING_NODE_SELECTOR" | wc -l) + if [ $BAD_OR_MISSING_NODE_SELECTOR_COUNT -ne 0 ]; then + echo "Found $BAD_OR_MISSING_NODE_SELECTOR_COUNT cronjobs with bad or missing nodeselector:" + echo "$BAD_OR_MISSING_NODE_SELECTOR" + exit 1 + fi diff --git a/tests/kuttl/tests/ctlplane-nodeselectors/03-assert-deploy-openstack.yaml b/tests/kuttl/tests/ctlplane-nodeselectors/03-assert-deploy-openstack.yaml new file mode 120000 index 000000000..762a8cf31 --- /dev/null +++ b/tests/kuttl/tests/ctlplane-nodeselectors/03-assert-deploy-openstack.yaml @@ -0,0 +1 @@ +../../common/assert-sample-deployment.yaml \ No newline at end of file diff --git a/tests/kuttl/tests/ctlplane-nodeselectors/03-update-nodeselector.yaml b/tests/kuttl/tests/ctlplane-nodeselectors/03-update-nodeselector.yaml new file mode 100644 index 000000000..2d50bda2e --- /dev/null +++ b/tests/kuttl/tests/ctlplane-nodeselectors/03-update-nodeselector.yaml @@ -0,0 +1,16 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +timeout: 60 +commands: + - script: | + oc patch dnsmasq -n $NAMESPACE dnsmasq --type='json' -p='[{ + "op": "replace", + "path": "/spec/nodeSelector", + "value": {"kubernetes.io/os":"linux"} + }]' + - script: | + oc patch openstackcontrolplane -n $NAMESPACE openstack --type='json' -p='[{ + "op": "replace", + "path": "/spec/nodeSelector", + "value": {"kubernetes.io/os":"linux"} + }]' diff --git a/tests/kuttl/tests/ctlplane-nodeselectors/04-assert-nodeselector.yaml b/tests/kuttl/tests/ctlplane-nodeselectors/04-assert-nodeselector.yaml new file mode 100644 index 000000000..031ccccc3 --- /dev/null +++ b/tests/kuttl/tests/ctlplane-nodeselectors/04-assert-nodeselector.yaml @@ -0,0 +1,23 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +commands: + - script: | + echo "Checking all running pods have new nodeselector" + EXPECTED_NODE_SELECTOR="kubernetes.io/os:linux" + BAD_OR_MISSING_NODE_SELECTOR=$(oc get pods -n $NAMESPACE -l service!=dnsmasq --field-selector=status.phase=Running -o=go-template --template='{{ range .items }}{{ .metadata.name}}: {{ .spec.nodeSelector }}{{"\n"}}{{ end }}' | grep -v 'ovn-controller-.*-config' | sed -e '\!map\['"$EXPECTED_NODE_SELECTOR"'\]$!d') + BAD_OR_MISSING_NODE_SELECTOR_COUNT=$(echo -n "$BAD_OR_MISSING_NODE_SELECTOR" | wc -l) + if [ $BAD_OR_MISSING_NODE_SELECTOR_COUNT -ne 0 ]; then + echo "Found $BAD_OR_MISSING_NODE_SELECTOR_COUNT pods with bad or missing nodeselector:" + echo "$BAD_OR_MISSING_NODE_SELECTOR" + exit 1 + fi + - script: | + echo "Checking all cronjobs have expected nodeselector" + EXPECTED_NODE_SELECTOR="kubernetes.io/os:linux" + BAD_OR_MISSING_NODE_SELECTOR=$(oc get cronjobs -n $NAMESPACE -o=go-template --template='{{ range .items }}{{ .metadata.name}}: {{ .spec.jobTemplate.spec.template.spec.nodeSelector }}{{"\n"}}{{ end }}' | grep -v 'ovn-controller-.*-config' | sed -e '\!map\['"$EXPECTED_NODE_SELECTOR"'\]$!d') + BAD_OR_MISSING_NODE_SELECTOR_COUNT=$(echo -n "$BAD_OR_MISSING_NODE_SELECTOR" | wc -l) + if [ $BAD_OR_MISSING_NODE_SELECTOR_COUNT -ne 0 ]; then + echo "Found $BAD_OR_MISSING_NODE_SELECTOR_COUNT cronjobs with bad or missing nodeselector:" + echo "$BAD_OR_MISSING_NODE_SELECTOR" + exit 1 + fi diff --git a/tests/kuttl/tests/ctlplane-nodeselectors/05-cleanup.yaml b/tests/kuttl/tests/ctlplane-nodeselectors/05-cleanup.yaml new file mode 100644 index 000000000..6b4992512 --- /dev/null +++ b/tests/kuttl/tests/ctlplane-nodeselectors/05-cleanup.yaml @@ -0,0 +1,13 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +delete: +- apiVersion: core.openstack.org/v1beta1 + kind: OpenStackControlPlane + name: openstack +commands: +- script: | + oc delete --ignore-not-found=true -n $NAMESPACE pvc \ + srv-swift-storage-0 + oc delete secret --ignore-not-found=true combined-ca-bundle -n $NAMESPACE + oc delete secret -l service-cert -n $NAMESPACE + oc delete secret -l ca-cert -n $NAMESPACE diff --git a/tests/kuttl/tests/ctlplane-nodeselectors/05-errors-cleanup.yaml b/tests/kuttl/tests/ctlplane-nodeselectors/05-errors-cleanup.yaml new file mode 120000 index 000000000..4d7b8362e --- /dev/null +++ b/tests/kuttl/tests/ctlplane-nodeselectors/05-errors-cleanup.yaml @@ -0,0 +1 @@ +../../common/errors_cleanup_openstack.yaml \ No newline at end of file From 78c7700faff0255cc5385de57c5d809317dcb5d1 Mon Sep 17 00:00:00 2001 From: Oliver Walsh Date: Thu, 21 Nov 2024 12:07:53 +0000 Subject: [PATCH 13/14] Update NodeSelector doc string --- apis/core/v1beta1/openstackcontrolplane_types.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apis/core/v1beta1/openstackcontrolplane_types.go b/apis/core/v1beta1/openstackcontrolplane_types.go index b7a5bdec3..6add4f982 100644 --- a/apis/core/v1beta1/openstackcontrolplane_types.go +++ b/apis/core/v1beta1/openstackcontrolplane_types.go @@ -86,7 +86,7 @@ type OpenStackControlPlaneSpec struct { // +kubebuilder:validation:Optional // +operator-sdk:csv:customresourcedefinitions:type=spec - // NodeSelector to target subset of worker nodes running control plane services (currently only applies to KeystoneAPI and PlacementAPI) + // NodeSelector to target subset of worker nodes running control plane services NodeSelector map[string]string `json:"nodeSelector,omitempty"` // +kubebuilder:validation:Optional From 712eec7dda27c330f1dfc35dbd5345d22378f441 Mon Sep 17 00:00:00 2001 From: Oliver Walsh Date: Thu, 21 Nov 2024 14:10:08 +0000 Subject: [PATCH 14/14] Fix openstackclient reconile logic --- .../client/openstackclient_controller.go | 46 +++---------------- 1 file changed, 7 insertions(+), 39 deletions(-) diff --git a/controllers/client/openstackclient_controller.go b/controllers/client/openstackclient_controller.go index db7ecdd15..d8d2eafc1 100644 --- a/controllers/client/openstackclient_controller.go +++ b/controllers/client/openstackclient_controller.go @@ -17,18 +17,15 @@ import ( "context" "errors" "fmt" - "reflect" "time" "github.com/go-logr/logr" - "golang.org/x/exp/slices" corev1 "k8s.io/api/core/v1" rbacv1 "k8s.io/api/rbac/v1" k8s_errors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/fields" - "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/runtime" @@ -308,45 +305,16 @@ func (r *OpenStackClientReconciler) Reconcile(ctx context.Context, req ctrl.Requ }, } + spec := openstackclient.ClientPodSpec(ctx, instance, helper, configVarsHash) + op, err := controllerutil.CreateOrPatch(ctx, r.Client, osclient, func() error { isPodUpdate := !osclient.ObjectMeta.CreationTimestamp.IsZero() if !isPodUpdate { - osclient.Spec = openstackclient.ClientPodSpec(ctx, instance, helper, configVarsHash) + osclient.Spec = spec } else { - hashupdate := false - - f := func(e corev1.EnvVar) bool { - return e.Name == "CONFIG_HASH" - } - idx := slices.IndexFunc(osclient.Spec.Containers[0].Env, f) - - if idx >= 0 && osclient.Spec.Containers[0].Env[idx].Value != configVarsHash { - hashupdate = true - } - - switch { - case osclient.Spec.Containers[0].Image != instance.Spec.ContainerImage: - // if container image change force re-create by triggering NewForbidden - return k8s_errors.NewForbidden( - schema.GroupResource{Group: "", Resource: "pods"}, // Specify the group and resource type - osclient.Name, - errors.New("Cannot update Pod spec field - Spec.Containers[0].Image"), // Specify the error message - ) - case hashupdate: - // if config hash changed, recreate the pod to use new config - return k8s_errors.NewForbidden( - schema.GroupResource{Group: "", Resource: "pods"}, // Specify the group and resource type - osclient.Name, - errors.New("Config changed recreate pod"), // Specify the error message - ) - case !reflect.DeepEqual(osclient.Spec.NodeSelector, instance.Spec.NodeSelector): - // if NodeSelector change force re-create by triggering NewForbidden - return k8s_errors.NewForbidden( - schema.GroupResource{Group: "", Resource: "pods"}, // Specify the group and resource type - osclient.Name, - errors.New("Cannot update Pod spec field - Spec.NodeSelector"), // Specify the error message - ) - } + osclient.Spec.Containers[0].Env = spec.Containers[0].Env + osclient.Spec.NodeSelector = spec.NodeSelector + osclient.Spec.Containers[0].Image = instance.Spec.ContainerImage } osclient.Labels = util.MergeStringMaps(osclient.Labels, clientLabels) @@ -376,7 +344,7 @@ func (r *OpenStackClientReconciler) Reconcile(ctx context.Context, req ctrl.Requ } Log.Info(fmt.Sprintf("OpenStackClient pod deleted due to change %s", err.Error())) - return ctrl.Result{}, nil + return ctrl.Result{Requeue: true}, nil } return ctrl.Result{}, fmt.Errorf("Failed to create or update pod %s: %w", osclient.Name, err)