From 1a62c070ed8bd4478538727fb0e1d2f693ae3863 Mon Sep 17 00:00:00 2001 From: Brendan Shephard Date: Mon, 21 Oct 2024 14:13:16 +1000 Subject: [PATCH] Switch EDPMServiceType to Enum This change switches the EDPMServiceType parameter to be an Enum that accepts a fixed list of service names. This is required, since allowing arbitrary names can interfere with the TLS mounts desribed in the referenced Jira. Instead of defaulting to the name of the service, we will instead default to generic and attempt to mount in a generic CA cert to ensure functionality of the dataplane. Jira: https://issues.redhat.com/browse/OSPRH-10804 Signed-off-by: Brendan Shephard --- ...plane.openstack.org_openstackdataplaneservices.yaml | 8 ++++++++ .../v1beta1/openstackdataplaneservice_types.go | 1 + .../v1beta1/openstackdataplaneservice_webhook.go | 7 ++++--- ...plane.openstack.org_openstackdataplaneservices.yaml | 8 ++++++++ .../openstackdataplanedeployment_controller_test.go | 10 +++++----- 5 files changed, 26 insertions(+), 8 deletions(-) diff --git a/apis/bases/dataplane.openstack.org_openstackdataplaneservices.yaml b/apis/bases/dataplane.openstack.org_openstackdataplaneservices.yaml index 85330b265..f5cd852bb 100644 --- a/apis/bases/dataplane.openstack.org_openstackdataplaneservices.yaml +++ b/apis/bases/dataplane.openstack.org_openstackdataplaneservices.yaml @@ -71,6 +71,14 @@ spec: deployOnAllNodeSets: type: boolean edpmServiceType: + enum: + - nova + - ovn + - update + - libvirt + - neutron-metadata + - telemetry + - generic type: string openStackAnsibleEERunnerImage: type: string diff --git a/apis/dataplane/v1beta1/openstackdataplaneservice_types.go b/apis/dataplane/v1beta1/openstackdataplaneservice_types.go index 607863151..4ca6ab0f9 100644 --- a/apis/dataplane/v1beta1/openstackdataplaneservice_types.go +++ b/apis/dataplane/v1beta1/openstackdataplaneservice_types.go @@ -110,6 +110,7 @@ type OpenStackDataPlaneServiceSpec struct { // corresponds to the ansible role name (without the "edpm_" prefix) used // to manage the service. If not set, will default to the // OpenStackDataPlaneService name. + // +kubebuilder:validation:Enum=nova;ovn;update;libvirt;neutron-metadata;telemetry;generic EDPMServiceType string `json:"edpmServiceType,omitempty" yaml:"edpmServiceType,omitempty"` } diff --git a/apis/dataplane/v1beta1/openstackdataplaneservice_webhook.go b/apis/dataplane/v1beta1/openstackdataplaneservice_webhook.go index 7088a12c3..e8fcf8ef5 100644 --- a/apis/dataplane/v1beta1/openstackdataplaneservice_webhook.go +++ b/apis/dataplane/v1beta1/openstackdataplaneservice_webhook.go @@ -44,14 +44,15 @@ var _ webhook.Defaulter = &OpenStackDataPlaneService{} func (r *OpenStackDataPlaneService) Default() { openstackdataplaneservicelog.Info("default", "name", r.Name) - r.Spec.Default(r.Name) + r.Spec.Default() r.DefaultLabels() } // Default - set defaults for this OpenStackDataPlaneService -func (spec *OpenStackDataPlaneServiceSpec) Default(name string) { +func (spec *OpenStackDataPlaneServiceSpec) Default() { + const EdpmGenericServiceName string = "generic" if spec.EDPMServiceType == "" { - spec.EDPMServiceType = name + spec.EDPMServiceType = EdpmGenericServiceName } } diff --git a/config/crd/bases/dataplane.openstack.org_openstackdataplaneservices.yaml b/config/crd/bases/dataplane.openstack.org_openstackdataplaneservices.yaml index 85330b265..f5cd852bb 100644 --- a/config/crd/bases/dataplane.openstack.org_openstackdataplaneservices.yaml +++ b/config/crd/bases/dataplane.openstack.org_openstackdataplaneservices.yaml @@ -71,6 +71,14 @@ spec: deployOnAllNodeSets: type: boolean edpmServiceType: + enum: + - nova + - ovn + - update + - libvirt + - neutron-metadata + - telemetry + - generic type: string openStackAnsibleEERunnerImage: type: string diff --git a/tests/functional/dataplane/openstackdataplanedeployment_controller_test.go b/tests/functional/dataplane/openstackdataplanedeployment_controller_test.go index 29abd907d..ae277a559 100644 --- a/tests/functional/dataplane/openstackdataplanedeployment_controller_test.go +++ b/tests/functional/dataplane/openstackdataplanedeployment_controller_test.go @@ -133,7 +133,7 @@ var _ = Describe("Dataplane Deployment Test", func() { CreateDataplaneService(dataplaneGlobalServiceName, true) // with EDPMServiceType set CreateDataPlaneServiceFromSpec(dataplaneUpdateServiceName, map[string]interface{}{ - "edpmServiceType": "foo-update-service", + "edpmServiceType": "update", "openStackAnsibleEERunnerImage": "foo-image:latest"}) DeferCleanup(th.DeleteService, dataplaneServiceName) @@ -279,7 +279,7 @@ var _ = Describe("Dataplane Deployment Test", func() { CreateDataplaneService(dataplaneServiceName, false) CreateDataplaneService(dataplaneGlobalServiceName, true) CreateDataPlaneServiceFromSpec(dataplaneUpdateServiceName, map[string]interface{}{ - "edpmServiceType": "foo-update-service", + "edpmServiceType": "update", "openStackAnsibleEERunnerImage": "foo-image:latest"}) DeferCleanup(th.DeleteService, dataplaneServiceName) @@ -750,7 +750,7 @@ var _ = Describe("Dataplane Deployment Test", func() { CreateDataplaneService(dataplaneServiceName, false) CreateDataplaneService(dataplaneGlobalServiceName, true) CreateDataPlaneServiceFromSpec(dataplaneUpdateServiceName, map[string]interface{}{ - "EDPMServiceType": "foo-update-service"}) + "EDPMServiceType": "update"}) DeferCleanup(th.DeleteService, dataplaneServiceName) DeferCleanup(th.DeleteService, dataplaneGlobalServiceName) @@ -1081,7 +1081,7 @@ var _ = Describe("Dataplane Deployment Test", func() { CreateDataplaneService(dataplaneServiceName, false) CreateDataplaneService(dataplaneGlobalServiceName, true) CreateDataPlaneServiceFromSpec(dataplaneUpdateServiceName, map[string]interface{}{ - "EDPMServiceType": "foo-update-service"}) + "EDPMServiceType": "update"}) DeferCleanup(th.DeleteService, dataplaneServiceName) DeferCleanup(th.DeleteService, dataplaneGlobalServiceName) @@ -1288,7 +1288,7 @@ var _ = Describe("Dataplane Deployment Test", func() { CreateDataplaneService(dataplaneServiceName, false) CreateDataplaneService(dataplaneGlobalServiceName, true) CreateDataPlaneServiceFromSpec(dataplaneUpdateServiceName, map[string]interface{}{ - "EDPMServiceType": "foo-update-service"}) + "EDPMServiceType": "update"}) DeferCleanup(th.DeleteService, dataplaneServiceName) DeferCleanup(th.DeleteService, dataplaneGlobalServiceName)