Skip to content

Commit ddd6c59

Browse files
committed
Deprecate OpenStackDataPlaneService CertsFrom and EDPMRoleServiceName fields
The CertsFrom and EDPMRoleServiceName were both added to solve slightly different use cases related to ansible content and expected mount paths in the AEE pod. Later, EDPMServiceType was also added to more broadly solve all the related issues. This patch deprecates CertsFrom and EDPMRoleServiceName in favor of using EDPMServiceType exclusively. The deprecated fields can still be used with the same functionality until they are officially removed. The existing usage of EDPMServiceType has also been expanded to cover all use cases of the previous fields, of which there were 2 cases: The first was in the deployment controller where certs are issued. EDPMServiceType is now considered and used to issue certs when it's set differently than the service name. The second instance addresses the usage of CertsFrom for creating cert mounts for the install-certs service. EDPMServiceType is now considered there as well if it's set differently from the service name. Signed-off-by: James Slagle <[email protected]>
1 parent 0202328 commit ddd6c59

File tree

4 files changed

+50
-14
lines changed

4 files changed

+50
-14
lines changed

apis/dataplane/v1beta1/openstackdataplaneservice_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ type OpenstackDataPlaneServiceCert struct {
5353
// not set, OpenStackDataPlaneService.Spec.EDPMServiceType is used. If
5454
// OpenStackDataPlaneService.Spec.EDPMServiceType is not set, then
5555
// OpenStackDataPlaneService.Name is used.
56+
// DEPRECATED: Will be removed in a future release. Use EDPMServiceType instead.
5657
EDPMRoleServiceName string `json:"edpmRoleServiceName,omitempty"`
5758
}
5859

@@ -88,6 +89,7 @@ type OpenStackDataPlaneServiceSpec struct {
8889
// CertsFrom - Service name used to obtain TLSCert and CACerts data. If both
8990
// CertsFrom and either TLSCert or CACerts is set, then those fields take
9091
// precedence.
92+
// DEPRECATED: Will be removed in a future release. Use EDPMServiceType instead.
9193
// +kubebuilder:validation:Optional
9294
CertsFrom string `json:"certsFrom,omitempty" yaml:"certsFrom,omitempty"`
9395

apis/operator/v1beta1/conditions.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,4 @@ const (
4242

4343
// OpenStackOperatorReadyMessage
4444
OpenStackOperatorReadyMessage = "OpenStackOperator completed"
45-
4645
)

controllers/dataplane/openstackdataplanedeployment_controller.go

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -209,22 +209,21 @@ func (r *OpenStackDataPlaneDeploymentReconciler) Reconcile(ctx context.Context,
209209
nsConditions := instance.Status.NodeSetConditions[nodeSet.Name]
210210

211211
for _, serviceName := range services {
212-
service, err := deployment.GetService(ctx, helper, serviceName)
212+
service, err := r.GetService(ctx, helper, instance, nsConditions, serviceName)
213213
if err != nil {
214-
instance.Status.Conditions.MarkFalse(
215-
condition.InputReadyCondition,
216-
condition.ErrorReason,
217-
condition.SeverityError,
218-
dataplanev1.ServiceErrorMessage,
219-
err.Error())
220-
nsConditions.MarkFalse(
221-
dataplanev1.NodeSetDeploymentReadyCondition,
222-
condition.ErrorReason,
223-
condition.SeverityError,
224-
dataplanev1.ServiceErrorMessage,
225-
err.Error())
226214
return ctrl.Result{}, err
227215
}
216+
217+
// If there is a different EDPMServiceType set and TLSCerts is
218+
// not also set, get the service referenced by EDPMServiceType
219+
// instead and use its cert data.
220+
if serviceName != service.Spec.EDPMServiceType && service.Spec.TLSCerts == nil {
221+
service, err = r.GetService(ctx, helper, instance, nsConditions, service.Spec.EDPMServiceType)
222+
if err != nil {
223+
return ctrl.Result{}, err
224+
}
225+
}
226+
228227
if service.Spec.TLSCerts != nil {
229228
for certKey := range service.Spec.TLSCerts {
230229
result, err := deployment.EnsureTLSCerts(ctx, helper, &nodeSet,
@@ -397,6 +396,32 @@ func (r *OpenStackDataPlaneDeploymentReconciler) Reconcile(ctx context.Context,
397396
return ctrl.Result{}, nil
398397
}
399398

399+
// GetService
400+
func (r *OpenStackDataPlaneDeploymentReconciler) GetService(
401+
ctx context.Context,
402+
helper *helper.Helper,
403+
instance *dataplanev1.OpenStackDataPlaneDeployment,
404+
nsConditions condition.Conditions,
405+
serviceName string,
406+
) (dataplanev1.OpenStackDataPlaneService, error) {
407+
service, err := deployment.GetService(ctx, helper, serviceName)
408+
if err != nil {
409+
instance.Status.Conditions.MarkFalse(
410+
condition.InputReadyCondition,
411+
condition.ErrorReason,
412+
condition.SeverityError,
413+
dataplanev1.ServiceErrorMessage,
414+
err.Error())
415+
nsConditions.MarkFalse(
416+
dataplanev1.NodeSetDeploymentReadyCondition,
417+
condition.ErrorReason,
418+
condition.SeverityError,
419+
dataplanev1.ServiceErrorMessage,
420+
err.Error())
421+
}
422+
return service, err
423+
}
424+
400425
func (r *OpenStackDataPlaneDeploymentReconciler) setHashes(
401426
ctx context.Context,
402427
helper *helper.Helper,

pkg/dataplane/deployment.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,16 @@ func (d *Deployer) addCertMounts(
273273
}
274274
}
275275

276+
if service.Spec.EDPMServiceType != service.Name && service.Spec.TLSCerts == nil {
277+
if slices.Contains(services, service.Spec.EDPMServiceType) {
278+
continue
279+
}
280+
service, err = GetService(d.Ctx, d.Helper, service.Spec.EDPMServiceType)
281+
if err != nil {
282+
return nil, err
283+
}
284+
}
285+
276286
if service.Spec.TLSCerts != nil && d.NodeSet.Spec.TLSEnabled {
277287
// sort cert list to ensure mount list is consistent
278288
certKeyList := make([]string, 0, len(service.Spec.TLSCerts))

0 commit comments

Comments
 (0)