Skip to content

Commit

Permalink
Require EDPMServiceType
Browse files Browse the repository at this point in the history
This change switches EDPMServiceType from optional to required.
Since the EDPMServiceType of custom services needs to match that of an existing service,
we also remove the defaulting mechanism in the webhook.

Signed-off-by: Brendan Shephard <[email protected]>
  • Loading branch information
bshephar committed Jan 8, 2025
1 parent 28f7169 commit b6c2b10
Showing 38 changed files with 48 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -129,6 +129,8 @@ spec:
- contents
type: object
type: object
required:
- edpmServiceType
type: object
status:
properties:
3 changes: 2 additions & 1 deletion apis/dataplane/v1beta1/openstackdataplaneservice_types.go
Original file line number Diff line number Diff line change
@@ -114,7 +114,8 @@ 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.
EDPMServiceType string `json:"edpmServiceType,omitempty" yaml:"edpmServiceType,omitempty"`
// +kubebuilder:validation:Required
EDPMServiceType string `json:"edpmServiceType" yaml:"edpmServiceType"`
}

// OpenStackDataPlaneServiceStatus defines the observed state of OpenStackDataPlaneService
8 changes: 0 additions & 8 deletions apis/dataplane/v1beta1/openstackdataplaneservice_webhook.go
Original file line number Diff line number Diff line change
@@ -44,17 +44,9 @@ var _ webhook.Defaulter = &OpenStackDataPlaneService{}
func (r *OpenStackDataPlaneService) Default() {

openstackdataplaneservicelog.Info("default", "name", r.Name)
r.Spec.Default(r.Name)
r.DefaultLabels()
}

// Default - set defaults for this OpenStackDataPlaneService
func (spec *OpenStackDataPlaneServiceSpec) Default(name string) {
if spec.EDPMServiceType == "" {
spec.EDPMServiceType = name
}
}

// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
// +kubebuilder:webhook:path=/validate-dataplane-openstack-org-v1beta1-openstackdataplaneservice,mutating=false,failurePolicy=fail,sideEffects=None,groups=dataplane.openstack.org,resources=openstackdataplaneservices,verbs=create;update,versions=v1beta1,name=vopenstackdataplaneservice.kb.io,admissionReviewVersions=v1

Original file line number Diff line number Diff line change
@@ -129,6 +129,8 @@ spec:
- contents
type: object
type: object
required:
- edpmServiceType
type: object
status:
properties:
Original file line number Diff line number Diff line change
@@ -4,3 +4,4 @@ metadata:
name: bootstrap
spec:
playbook: osp.edpm.bootstrap
edpmServiceType: bootstrap
Original file line number Diff line number Diff line change
@@ -4,3 +4,4 @@ metadata:
name: ceph-client
spec:
playbook: osp.edpm.ceph_client
edpmServiceType: ceph-client
Original file line number Diff line number Diff line change
@@ -4,3 +4,4 @@ metadata:
name: ceph-hci-pre
spec:
playbook: osp.edpm.ceph_hci_pre
edpmServiceType: ceph-hci-pre
Original file line number Diff line number Diff line change
@@ -4,3 +4,4 @@ metadata:
name: configure-network
spec:
playbook: osp.edpm.configure_network
edpmServiceType: configure-network
Original file line number Diff line number Diff line change
@@ -4,3 +4,4 @@ metadata:
name: configure-os
spec:
playbook: osp.edpm.configure_os
edpmServiceType: configure-os
Original file line number Diff line number Diff line change
@@ -4,3 +4,4 @@ metadata:
name: configure-ovs-dpdk
spec:
playbook: osp.edpm.configure_ovs_dpdk
edpmServiceType: configure-ovs-dpdk
Original file line number Diff line number Diff line change
@@ -4,3 +4,4 @@ metadata:
name: ddp-package-option
spec:
playbook: osp.edpm.select_kernel_ddp_package
edpmServiceType: ddp-package-option
Original file line number Diff line number Diff line change
@@ -4,3 +4,4 @@ metadata:
name: derive-pci-devicespec
spec:
playbook: osp.edpm.sriov_derive_device_spec
edpmServiceType: derive-pci-devicespec
Original file line number Diff line number Diff line change
@@ -4,3 +4,4 @@ metadata:
name: download-cache
spec:
playbook: osp.edpm.download_cache
edpmServiceType: download-cache
Original file line number Diff line number Diff line change
@@ -5,3 +5,4 @@ metadata:
spec:
label: fips-status
playbook: osp.edpm.fips_status
edpmServiceType: fips-status
Original file line number Diff line number Diff line change
@@ -6,3 +6,4 @@ spec:
playbook: osp.edpm.frr
containerImageFields:
- EdpmFrrImage
edpmServiceType: frr
Original file line number Diff line number Diff line change
@@ -5,3 +5,4 @@ metadata:
spec:
playbook: osp.edpm.install_certs
addCertMounts: True
edpmServiceType: install-certs
Original file line number Diff line number Diff line change
@@ -4,3 +4,4 @@ metadata:
name: install-os
spec:
playbook: osp.edpm.install_os
edpmServiceType: install-os
Original file line number Diff line number Diff line change
@@ -23,3 +23,4 @@ spec:
- client auth
issuer: osp-rootca-issuer-libvirt
caCerts: combined-ca-bundle
edpmServiceType: libvirt
Original file line number Diff line number Diff line change
@@ -7,3 +7,4 @@ spec:
- secretRef:
name: logging-compute-config-data
playbook: osp.edpm.telemetry_logging
edpmServiceType: logging
Original file line number Diff line number Diff line change
@@ -10,3 +10,4 @@ spec:
caCerts: combined-ca-bundle
containerImageFields:
- EdpmNeutronDhcpAgentImage
edpmServiceType: neutron-dhcp
Original file line number Diff line number Diff line change
@@ -24,3 +24,4 @@ spec:
caCerts: combined-ca-bundle
containerImageFields:
- EdpmNeutronMetadataAgentImage
edpmServiceType: neutron-metadata
Original file line number Diff line number Diff line change
@@ -22,3 +22,4 @@ spec:
caCerts: combined-ca-bundle
containerImageFields:
- EdpmNeutronOvnAgentImage
edpmServiceType: neutron-ovn
Original file line number Diff line number Diff line change
@@ -10,3 +10,4 @@ spec:
caCerts: combined-ca-bundle
containerImageFields:
- EdpmNeutronSriovAgentImage
edpmServiceType: neutron-sriov
Original file line number Diff line number Diff line change
@@ -4,3 +4,4 @@ metadata:
name: reboot-os
spec:
playbook: osp.edpm.reboot
edpmServiceType: reboot-os
Original file line number Diff line number Diff line change
@@ -23,3 +23,4 @@ spec:
caCerts: combined-ca-bundle
containerImageFields:
- OvnControllerImage
edpmServiceType: ovn
Original file line number Diff line number Diff line change
@@ -23,3 +23,4 @@ spec:
caCerts: combined-ca-bundle
containerImageFields:
- EdpmOvnBgpAgentImage
edpmServiceType: ovn-bgp-agent
Original file line number Diff line number Diff line change
@@ -7,3 +7,4 @@ spec:
containerImageFields:
- EdpmLogrotateCrondImage
- EdpmIscsidImage
edpmServiceType: run-os
Original file line number Diff line number Diff line change
@@ -5,3 +5,4 @@ metadata:
spec:
playbook: osp.edpm.ssh_known_hosts
deployOnAllNodeSets: true
edpmServiceType: ssh-known-hosts
Original file line number Diff line number Diff line change
@@ -11,3 +11,4 @@ spec:
name: swift-storage-config-data
- configMapRef:
name: swift-ring-files
edpmServiceType: swift
Original file line number Diff line number Diff line change
@@ -16,3 +16,4 @@ spec:
containerImageFields:
- CeilometerComputeImage
- EdpmNodeExporterImage
edpmServiceType: telemetry
Original file line number Diff line number Diff line change
@@ -16,3 +16,4 @@ spec:
containerImageFields:
- CeilometerIpmiImage
- EdpmKeplerImage
edpmServiceType: telemetry-power-monitoring
Original file line number Diff line number Diff line change
@@ -4,3 +4,4 @@ metadata:
name: update
spec:
playbook: osp.edpm.update
edpmServiceType: update
Original file line number Diff line number Diff line change
@@ -4,3 +4,4 @@ metadata:
name: validate-network
spec:
playbook: osp.edpm.validate_network
edpmServiceType: validate-network
2 changes: 1 addition & 1 deletion docs/assemblies/proc_creating-a-custom-service.adoc
Original file line number Diff line number Diff line change
@@ -112,7 +112,7 @@ spec:
deployOnAllNodeSets: true
----

. Optional: Specify the `edpmServiceType` field for the service. Different custom services may use the same ansible content to manage the same EDPM service (such as `ovn` or `nova`). The `DataSources`, TLS certificates, and CA certificates need to be mounted at the same locations so they can be found by the ansible content even when using a custom service. `edpmServiceType` is used to create this association. The value is the name of the default service that uses the same ansible content as the custom service. If there are multiple services with the same `edpmServiceType` listed in a nodeset or deployment spec, latter ones would be ignored.
. Required: Specify the `edpmServiceType` field for the service. Different custom services may use the same ansible content to manage the same EDPM service (such as `ovn` or `nova`). The `DataSources`, TLS certificates, and CA certificates need to be mounted at the same locations so they can be found by the ansible content even when using a custom service. `edpmServiceType` is used to create this association. The value is the name of the default service that uses the same ansible content as the custom service. If there are multiple services with the same `edpmServiceType` listed in a nodeset or deployment spec, latter ones would be ignored.
+
For example, a custom service that uses the `edpm_ovn` ansible content from `edpm-ansible` would set `edpmServiceType` to `ovn`, which matches the default `ovn` service name provided by `openstack-operator`.
+
7 changes: 5 additions & 2 deletions tests/functional/dataplane/base_test.go
Original file line number Diff line number Diff line change
@@ -519,8 +519,10 @@ func DefaultDataplaneService(name types.NamespacedName) map[string]interface{} {
"namespace": name.Namespace,
},
"spec": map[string]interface{}{
"playbook": "test",
}}
"playbook": "test",
"edpmServiceType": "notGlobal",
},
}
}

// Create an empty OpenStackDataPlaneService struct
@@ -538,6 +540,7 @@ func DefaultDataplaneGlobalService(name types.NamespacedName) map[string]interfa
"spec": map[string]interface{}{
"deployOnAllNodeSets": true,
"playbook": "test",
"edpmServiceType": "global",
},
}
}
Original file line number Diff line number Diff line change
@@ -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": "foo-update-service"})

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": "foo-update-service"})

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": "foo-update-service"})

DeferCleanup(th.DeleteService, dataplaneServiceName)
DeferCleanup(th.DeleteService, dataplaneGlobalServiceName)
Original file line number Diff line number Diff line change
@@ -1239,7 +1239,8 @@ var _ = Describe("Dataplane NodeSet Test", func() {

dataplanev1.SetupDefaults()
updateServiceSpec := map[string]interface{}{
"playbook": "osp.edpm.update",
"playbook": "osp.edpm.update",
"edpmServiceType": "update",
}
CreateDataPlaneServiceFromSpec(dataplaneUpdateServiceName, updateServiceSpec)
DeferCleanup(th.DeleteService, dataplaneUpdateServiceName)
Original file line number Diff line number Diff line change
@@ -90,6 +90,7 @@ spec:
command: sleep 1
delegate_to: localhost
deployOnAllNodeSets: true
edpmServiceType: "custom-global-service"
---
apiVersion: v1
kind: ConfigMap

0 comments on commit b6c2b10

Please sign in to comment.