From f0ab14d8296c2b3e721ae432c9c40ac076036614 Mon Sep 17 00:00:00 2001 From: Fabricio Aguiar Date: Tue, 18 Jun 2024 08:48:34 +0100 Subject: [PATCH] Drop DataPlaneService ConfigMaps and Secrets - Drops the ConfigMaps and Secrets fields from OpenStackDataPlaneService. - Updates all services under config/services to use the OpenStackDataPlaneService.Spec.DataSources field instead. - Update docs for the switch to DataSources. Signed-off-by: Fabricio Aguiar --- ...nstack.org_openstackdataplaneservices.yaml | 8 ----- .../openstackdataplaneservice_types.go | 8 ----- .../v1beta1/zz_generated.deepcopy.go | 10 ------ ...nstack.org_openstackdataplaneservices.yaml | 8 ----- ...ta1_openstackdataplaneservice_libvirt.yaml | 5 +-- ...ta1_openstackdataplaneservice_logging.yaml | 5 +-- ...penstackdataplaneservice_neutron_dhcp.yaml | 5 +-- ...tackdataplaneservice_neutron_metadata.yaml | 8 +++-- ...openstackdataplaneservice_neutron_ovn.yaml | 5 +-- ...enstackdataplaneservice_neutron_sriov.yaml | 5 +-- ...v1beta1_openstackdataplaneservice_ovn.yaml | 5 +-- ...enstackdataplaneservice_ovn_bgp_agent.yaml | 5 +-- ...beta1_openstackdataplaneservice_swift.yaml | 12 ++++--- ...1_openstackdataplaneservice_telemetry.yaml | 5 +-- docs/assemblies/dataplane_resources.adoc | 10 ------ pkg/dataplane/deployment.go | 19 ----------- pkg/dataplane/hashes.go | 34 ------------------- ...enstackdataplaneservice_controller_test.go | 6 ++-- .../dataplane-service-config/00-create.yaml | 11 +++--- 19 files changed, 45 insertions(+), 129 deletions(-) diff --git a/apis/bases/dataplane.openstack.org_openstackdataplaneservices.yaml b/apis/bases/dataplane.openstack.org_openstackdataplaneservices.yaml index 940c4d7f2..5172854ac 100644 --- a/apis/bases/dataplane.openstack.org_openstackdataplaneservices.yaml +++ b/apis/bases/dataplane.openstack.org_openstackdataplaneservices.yaml @@ -38,10 +38,6 @@ spec: type: string certsFrom: type: string - configMaps: - items: - type: string - type: array containerImageFields: items: type: string @@ -79,10 +75,6 @@ spec: type: string playbookContents: type: string - secrets: - items: - type: string - type: array tlsCerts: additionalProperties: properties: diff --git a/apis/dataplane/v1beta1/openstackdataplaneservice_types.go b/apis/dataplane/v1beta1/openstackdataplaneservice_types.go index d68554616..068ac805f 100644 --- a/apis/dataplane/v1beta1/openstackdataplaneservice_types.go +++ b/apis/dataplane/v1beta1/openstackdataplaneservice_types.go @@ -58,14 +58,6 @@ type OpenstackDataPlaneServiceCert struct { // OpenStackDataPlaneServiceSpec defines the desired state of OpenStackDataPlaneService type OpenStackDataPlaneServiceSpec struct { - // ConfigMaps list of ConfigMap names to mount as ExtraMounts for the OpenStackAnsibleEE - // +kubebuilder:validation:Optional - ConfigMaps []string `json:"configMaps,omitempty" yaml:"configMaps,omitempty"` - - // Secrets list of Secret names to mount as ExtraMounts for the OpenStackAnsibleEE - // +kubebuilder:validation:Optional - Secrets []string `json:"secrets,omitempty"` - // DataSources list of DataSource objects to mount as ExtraMounts for the // OpenStackAnsibleEE DataSources []DataSource `json:"dataSources,omitempty" yaml:"dataSources,omitempty"` diff --git a/apis/dataplane/v1beta1/zz_generated.deepcopy.go b/apis/dataplane/v1beta1/zz_generated.deepcopy.go index 22ae6d42b..3731d9b42 100644 --- a/apis/dataplane/v1beta1/zz_generated.deepcopy.go +++ b/apis/dataplane/v1beta1/zz_generated.deepcopy.go @@ -700,16 +700,6 @@ func (in *OpenStackDataPlaneServiceList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *OpenStackDataPlaneServiceSpec) DeepCopyInto(out *OpenStackDataPlaneServiceSpec) { *out = *in - if in.ConfigMaps != nil { - in, out := &in.ConfigMaps, &out.ConfigMaps - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.Secrets != nil { - in, out := &in.Secrets, &out.Secrets - *out = make([]string, len(*in)) - copy(*out, *in) - } if in.DataSources != nil { in, out := &in.DataSources, &out.DataSources *out = make([]DataSource, len(*in)) diff --git a/config/crd/bases/dataplane.openstack.org_openstackdataplaneservices.yaml b/config/crd/bases/dataplane.openstack.org_openstackdataplaneservices.yaml index 940c4d7f2..5172854ac 100644 --- a/config/crd/bases/dataplane.openstack.org_openstackdataplaneservices.yaml +++ b/config/crd/bases/dataplane.openstack.org_openstackdataplaneservices.yaml @@ -38,10 +38,6 @@ spec: type: string certsFrom: type: string - configMaps: - items: - type: string - type: array containerImageFields: items: type: string @@ -79,10 +75,6 @@ spec: type: string playbookContents: type: string - secrets: - items: - type: string - type: array tlsCerts: additionalProperties: properties: diff --git a/config/services/dataplane_v1beta1_openstackdataplaneservice_libvirt.yaml b/config/services/dataplane_v1beta1_openstackdataplaneservice_libvirt.yaml index 7defe3840..04cb6d962 100644 --- a/config/services/dataplane_v1beta1_openstackdataplaneservice_libvirt.yaml +++ b/config/services/dataplane_v1beta1_openstackdataplaneservice_libvirt.yaml @@ -4,10 +4,11 @@ metadata: name: libvirt spec: playbook: osp.edpm.libvirt - secrets: + dataSources: # NOTE: this Secret needs to be created before deploying the data plane. # It should contain the libvirt sasl auth password using the key LibvirtPassword - - libvirt-secret + - secretRef: + name: libvirt-secret tlsCerts: default: contents: diff --git a/config/services/dataplane_v1beta1_openstackdataplaneservice_logging.yaml b/config/services/dataplane_v1beta1_openstackdataplaneservice_logging.yaml index 2d5a5dac6..449eeeed2 100644 --- a/config/services/dataplane_v1beta1_openstackdataplaneservice_logging.yaml +++ b/config/services/dataplane_v1beta1_openstackdataplaneservice_logging.yaml @@ -3,6 +3,7 @@ kind: OpenStackDataPlaneService metadata: name: logging spec: - secrets: - - logging-compute-config-data + dataSources: + - secretRef: + name: logging-compute-config-data playbook: osp.edpm.telemetry_logging diff --git a/config/services/dataplane_v1beta1_openstackdataplaneservice_neutron_dhcp.yaml b/config/services/dataplane_v1beta1_openstackdataplaneservice_neutron_dhcp.yaml index c12bf69a8..52a171ff4 100644 --- a/config/services/dataplane_v1beta1_openstackdataplaneservice_neutron_dhcp.yaml +++ b/config/services/dataplane_v1beta1_openstackdataplaneservice_neutron_dhcp.yaml @@ -4,8 +4,9 @@ metadata: name: neutron-dhcp spec: playbook: osp.edpm.neutron_dhcp - secrets: - - neutron-dhcp-agent-neutron-config + dataSources: + - secretRef: + name: neutron-dhcp-agent-neutron-config caCerts: combined-ca-bundle containerImageFields: - EdpmNeutronDhcpAgentImage diff --git a/config/services/dataplane_v1beta1_openstackdataplaneservice_neutron_metadata.yaml b/config/services/dataplane_v1beta1_openstackdataplaneservice_neutron_metadata.yaml index e487b5bab..8d2b96e59 100644 --- a/config/services/dataplane_v1beta1_openstackdataplaneservice_neutron_metadata.yaml +++ b/config/services/dataplane_v1beta1_openstackdataplaneservice_neutron_metadata.yaml @@ -4,9 +4,11 @@ metadata: name: neutron-metadata spec: playbook: osp.edpm.neutron_metadata - secrets: - - neutron-ovn-metadata-agent-neutron-config - - nova-metadata-neutron-config + dataSources: + - secretRef: + name: neutron-ovn-metadata-agent-neutron-config + - secretRef: + name: nova-metadata-neutron-config tlsCerts: default: contents: diff --git a/config/services/dataplane_v1beta1_openstackdataplaneservice_neutron_ovn.yaml b/config/services/dataplane_v1beta1_openstackdataplaneservice_neutron_ovn.yaml index 04391b22a..3634e112c 100644 --- a/config/services/dataplane_v1beta1_openstackdataplaneservice_neutron_ovn.yaml +++ b/config/services/dataplane_v1beta1_openstackdataplaneservice_neutron_ovn.yaml @@ -4,8 +4,9 @@ metadata: name: neutron-ovn spec: playbook: osp.edpm.neutron_ovn - secrets: - - neutron-ovn-agent-neutron-config + dataSources: + - secretRef: + name: neutron-ovn-agent-neutron-config tlsCerts: default: contents: diff --git a/config/services/dataplane_v1beta1_openstackdataplaneservice_neutron_sriov.yaml b/config/services/dataplane_v1beta1_openstackdataplaneservice_neutron_sriov.yaml index 89fc2f036..12980afb3 100644 --- a/config/services/dataplane_v1beta1_openstackdataplaneservice_neutron_sriov.yaml +++ b/config/services/dataplane_v1beta1_openstackdataplaneservice_neutron_sriov.yaml @@ -4,8 +4,9 @@ metadata: name: neutron-sriov spec: playbook: osp.edpm.neutron_sriov - secrets: - - neutron-sriov-agent-neutron-config + dataSources: + - secretRef: + name: neutron-sriov-agent-neutron-config caCerts: combined-ca-bundle containerImageFields: - EdpmNeutronSriovAgentImage diff --git a/config/services/dataplane_v1beta1_openstackdataplaneservice_ovn.yaml b/config/services/dataplane_v1beta1_openstackdataplaneservice_ovn.yaml index 3493a3071..eacde16b4 100644 --- a/config/services/dataplane_v1beta1_openstackdataplaneservice_ovn.yaml +++ b/config/services/dataplane_v1beta1_openstackdataplaneservice_ovn.yaml @@ -4,8 +4,9 @@ metadata: name: ovn spec: playbook: osp.edpm.ovn - configMaps: - - ovncontroller-config + dataSources: + - configMapRef: + name: ovncontroller-config tlsCerts: default: contents: diff --git a/config/services/dataplane_v1beta1_openstackdataplaneservice_ovn_bgp_agent.yaml b/config/services/dataplane_v1beta1_openstackdataplaneservice_ovn_bgp_agent.yaml index 808b2ca52..f4e9790a4 100644 --- a/config/services/dataplane_v1beta1_openstackdataplaneservice_ovn_bgp_agent.yaml +++ b/config/services/dataplane_v1beta1_openstackdataplaneservice_ovn_bgp_agent.yaml @@ -4,8 +4,9 @@ metadata: name: ovn-bgp-agent spec: playbook: osp.edpm.ovn_bgp_agent - secrets: - - neutron-ovn-agent-neutron-config + dataSources: + - secretRef: + name: neutron-ovn-agent-neutron-config tlsCerts: default: contents: diff --git a/config/services/dataplane_v1beta1_openstackdataplaneservice_swift.yaml b/config/services/dataplane_v1beta1_openstackdataplaneservice_swift.yaml index c8ebf2448..04d7ac02b 100644 --- a/config/services/dataplane_v1beta1_openstackdataplaneservice_swift.yaml +++ b/config/services/dataplane_v1beta1_openstackdataplaneservice_swift.yaml @@ -4,8 +4,10 @@ metadata: name: swift spec: playbook: osp.edpm.swift - secrets: - - swift-conf - configMaps: - - swift-storage-config-data - - swift-ring-files + dataSources: + - secretRef: + name: swift-conf + - configMapRef: + name: swift-storage-config-data + - configMapRef: + name: swift-ring-files diff --git a/config/services/dataplane_v1beta1_openstackdataplaneservice_telemetry.yaml b/config/services/dataplane_v1beta1_openstackdataplaneservice_telemetry.yaml index 995f884db..b8a48fd2d 100644 --- a/config/services/dataplane_v1beta1_openstackdataplaneservice_telemetry.yaml +++ b/config/services/dataplane_v1beta1_openstackdataplaneservice_telemetry.yaml @@ -3,8 +3,9 @@ kind: OpenStackDataPlaneService metadata: name: telemetry spec: - secrets: - - ceilometer-compute-config-data + dataSources: + - secretRef: + name: ceilometer-compute-config-data playbook: osp.edpm.telemetry tlsCerts: default: diff --git a/docs/assemblies/dataplane_resources.adoc b/docs/assemblies/dataplane_resources.adoc index 018b99cc4..0417d8407 100644 --- a/docs/assemblies/dataplane_resources.adoc +++ b/docs/assemblies/dataplane_resources.adoc @@ -420,16 +420,6 @@ OpenStackDataPlaneServiceSpec defines the desired state of OpenStackDataPlaneSer |=== | Field | Description | Scheme | Required -| configMaps -| ConfigMaps list of ConfigMap names to mount as ExtraMounts for the OpenStackAnsibleEE -| []string -| false - -| secrets -| Secrets list of Secret names to mount as ExtraMounts for the OpenStackAnsibleEE -| []string -| false - | dataSources | DataSources list of DataSource objects to mount as ExtraMounts for the OpenStackAnsibleEE | []<> diff --git a/pkg/dataplane/deployment.go b/pkg/dataplane/deployment.go index bf515eee7..5020038df 100644 --- a/pkg/dataplane/deployment.go +++ b/pkg/dataplane/deployment.go @@ -368,7 +368,6 @@ func (d *Deployer) addCertMounts( func (d *Deployer) addServiceExtraMounts( service dataplanev1.OpenStackDataPlaneService, ) (*dataplanev1.AnsibleEESpec, error) { - client := d.Helper.GetClient() baseMountPath := path.Join(ConfigPaths, service.Name) var configMaps []*corev1.ConfigMap @@ -388,24 +387,6 @@ func (d *Deployer) addServiceExtraMounts( } } - for _, cmName := range service.Spec.ConfigMaps { - cm := &corev1.ConfigMap{} - err := client.Get(d.Ctx, types.NamespacedName{Name: cmName, Namespace: service.Namespace}, cm) - if err != nil { - return d.AeeSpec, err - } - configMaps = append(configMaps, cm) - } - - for _, secretName := range service.Spec.Secrets { - sec := &corev1.Secret{} - err := client.Get(d.Ctx, types.NamespacedName{Name: secretName, Namespace: service.Namespace}, sec) - if err != nil { - return d.AeeSpec, err - } - secrets = append(secrets, sec) - } - for _, cm := range configMaps { volMounts := storage.VolMounts{} diff --git a/pkg/dataplane/hashes.go b/pkg/dataplane/hashes.go index 8f57dc498..e46cba629 100644 --- a/pkg/dataplane/hashes.go +++ b/pkg/dataplane/hashes.go @@ -70,40 +70,6 @@ func GetDeploymentHashesForService( } } - for _, cmName := range service.Spec.ConfigMaps { - namespacedName := types.NamespacedName{ - Name: cmName, - Namespace: namespace, - } - cm := &corev1.ConfigMap{} - err := helper.GetClient().Get(context.Background(), namespacedName, cm) - if err != nil { - helper.GetLogger().Error(err, "Unable to retrieve ConfigMap %v") - return err - } - configMapHashes[cmName], err = configmap.Hash(cm) - if err != nil { - helper.GetLogger().Error(err, "Unable to hash ConfigMap %v") - } - - } - for _, secretName := range service.Spec.Secrets { - namespacedName := types.NamespacedName{ - Name: secretName, - Namespace: namespace, - } - sec := &corev1.Secret{} - err := helper.GetClient().Get(ctx, namespacedName, sec) - if err != nil { - helper.GetLogger().Error(err, "Unable to retrieve Secret %v") - return err - } - secretHashes[secretName], err = secret.Hash(sec) - if err != nil { - helper.GetLogger().Error(err, "Unable to hash Secret %v") - } - } - if service.Spec.TLSCerts != nil { for certKey := range service.Spec.TLSCerts { var secrets *corev1.SecretList diff --git a/tests/functional/dataplane/openstackdataplaneservice_controller_test.go b/tests/functional/dataplane/openstackdataplaneservice_controller_test.go index c1d5d9b2a..1a622486e 100644 --- a/tests/functional/dataplane/openstackdataplaneservice_controller_test.go +++ b/tests/functional/dataplane/openstackdataplaneservice_controller_test.go @@ -41,9 +41,8 @@ var _ = Describe("OpenstackDataplaneService Test", func() { It("spec fields are set up", func() { service := GetService(dataplaneServiceName) - Expect(service.Spec.Secrets).To(BeEmpty()) + Expect(service.Spec.DataSources).To(BeEmpty()) Expect(service.Spec.Playbook).To(BeEmpty()) - Expect(service.Spec.ConfigMaps).To(BeEmpty()) Expect(service.Spec.DeployOnAllNodeSets).To(BeFalse()) }) }) @@ -57,9 +56,8 @@ var _ = Describe("OpenstackDataplaneService Test", func() { It("spec fields are set up", func() { service := GetService(dataplaneServiceName) - Expect(service.Spec.Secrets).To(BeEmpty()) + Expect(service.Spec.DataSources).To(BeEmpty()) Expect(service.Spec.Playbook).To(BeEmpty()) - Expect(service.Spec.ConfigMaps).To(BeEmpty()) Expect(service.Spec.DeployOnAllNodeSets).To(BeTrue()) }) }) diff --git a/tests/kuttl/tests/dataplane-service-config/00-create.yaml b/tests/kuttl/tests/dataplane-service-config/00-create.yaml index 5d97149c5..41884f8ad 100644 --- a/tests/kuttl/tests/dataplane-service-config/00-create.yaml +++ b/tests/kuttl/tests/dataplane-service-config/00-create.yaml @@ -47,10 +47,13 @@ spec: - name: Sleep command: sleep infinity delegate_to: localhost - configMaps: - - kuttl-service-cm-0 - - kuttl-service-cm-1 - - kuttl-service-cm-2 + dataSources: + - configMapRef: + name: kuttl-service-cm-0 + - configMapRef: + name: kuttl-service-cm-1 + - configMapRef: + name: kuttl-service-cm-2 --- apiVersion: dataplane.openstack.org/v1beta1 kind: OpenStackDataPlaneNodeSet