|
6 | 6 |
|
7 | 7 | "github.com/openstack-k8s-operators/lib-common/modules/common/condition" |
8 | 8 | "github.com/openstack-k8s-operators/lib-common/modules/common/helper" |
| 9 | + "github.com/openstack-k8s-operators/lib-common/modules/common/service" |
9 | 10 |
|
10 | 11 | corev1beta1 "github.com/openstack-k8s-operators/openstack-operator/apis/core/v1beta1" |
11 | 12 | telemetryv1 "github.com/openstack-k8s-operators/telemetry-operator/api/v1beta1" |
@@ -38,6 +39,59 @@ func ReconcileTelemetry(ctx context.Context, instance *corev1beta1.OpenStackCont |
38 | 39 | return ctrl.Result{}, nil |
39 | 40 | } |
40 | 41 |
|
| 42 | + // add selector to service overrides |
| 43 | + for _, endpointType := range []service.Endpoint{service.EndpointPublic, service.EndpointInternal} { |
| 44 | + if instance.Spec.Telemetry.Template.Autoscaling.Aodh.Override.Service == nil { |
| 45 | + instance.Spec.Telemetry.Template.Autoscaling.Aodh.Override.Service = make(map[service.Endpoint]service.RoutedOverrideSpec) |
| 46 | + } |
| 47 | + instance.Spec.Telemetry.Template.Autoscaling.Aodh.Override.Service[endpointType] = |
| 48 | + AddServiceOpenStackOperatorLabel( |
| 49 | + instance.Spec.Telemetry.Template.Autoscaling.Aodh.Override.Service[endpointType], |
| 50 | + telemetry.Name) |
| 51 | + } |
| 52 | + |
| 53 | + // preserve any previously set TLS certs, set CA cert |
| 54 | + if instance.Spec.TLS.Enabled(service.EndpointInternal) { |
| 55 | + instance.Spec.Telemetry.Template.Autoscaling.Aodh.TLS = telemetry.Spec.Autoscaling.Aodh.TLS |
| 56 | + } |
| 57 | + instance.Spec.Telemetry.Template.Autoscaling.Aodh.TLS.CaBundleSecretName = instance.Status.TLS.CaBundleSecretName |
| 58 | + |
| 59 | + svcs, err := service.GetServicesListWithLabel( |
| 60 | + ctx, |
| 61 | + helper, |
| 62 | + instance.Namespace, |
| 63 | + GetServiceOpenStackOperatorLabel(telemetry.Name), |
| 64 | + ) |
| 65 | + if err != nil { |
| 66 | + return ctrl.Result{}, err |
| 67 | + } |
| 68 | + |
| 69 | + // make sure to get to EndpointConfig when all service got created |
| 70 | + if len(svcs.Items) == len(instance.Spec.Telemetry.Template.Autoscaling.Aodh.Override.Service) { |
| 71 | + endpointDetails, ctrlResult, err := EnsureEndpointConfig( |
| 72 | + ctx, |
| 73 | + instance, |
| 74 | + helper, |
| 75 | + telemetry, |
| 76 | + svcs, |
| 77 | + instance.Spec.Telemetry.Template.Autoscaling.Aodh.Override.Service, |
| 78 | + instance.Spec.Telemetry.APIOverride, |
| 79 | + corev1beta1.OpenStackControlPlaneExposeTelemetryReadyCondition, |
| 80 | + false, // TODO (mschuppert) could be removed when all integrated service support TLS |
| 81 | + instance.Spec.Telemetry.Template.Autoscaling.Aodh.TLS, |
| 82 | + ) |
| 83 | + if err != nil { |
| 84 | + return ctrlResult, err |
| 85 | + } else if (ctrlResult != ctrl.Result{}) { |
| 86 | + return ctrlResult, nil |
| 87 | + } |
| 88 | + // set service overrides |
| 89 | + instance.Spec.Telemetry.Template.Autoscaling.Aodh.Override.Service = endpointDetails.GetEndpointServiceOverrides() |
| 90 | + // update TLS settings with cert secret |
| 91 | + instance.Spec.Telemetry.Template.Autoscaling.Aodh.TLS.API.Public.SecretName = endpointDetails.GetEndptCertSecret(service.EndpointPublic) |
| 92 | + instance.Spec.Telemetry.Template.Autoscaling.Aodh.TLS.API.Internal.SecretName = endpointDetails.GetEndptCertSecret(service.EndpointInternal) |
| 93 | + } |
| 94 | + |
41 | 95 | helper.GetLogger().Info("Reconciling Telemetry", telemetryNamespaceLabel, instance.Namespace, telemetryNameLabel, telemetryName) |
42 | 96 | op, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), telemetry, func() error { |
43 | 97 | instance.Spec.Telemetry.Template.DeepCopyInto(&telemetry.Spec) |
|
0 commit comments