Skip to content

Commit 66d5a8e

Browse files
Merge pull request #2211 from jlarriba/telemetry-route-overrides
[OSPRH-39942] Fix telemetry route overrides applied to the wrong routes
2 parents 582a89a + 4250ad0 commit 66d5a8e

3 files changed

Lines changed: 134 additions & 1 deletion

File tree

‎api/core/v1beta1/openstackcontrolplane_webhook.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,6 +1151,8 @@ func (r *OpenStackControlPlane) DefaultServices() {
11511151
r.Spec.Telemetry.Template.Default()
11521152
initializeOverrideSpec(&r.Spec.Telemetry.AodhAPIOverride.Route, true)
11531153
r.Spec.Telemetry.Template.Autoscaling.SetDefaultRouteAnnotations(r.Spec.Telemetry.AodhAPIOverride.Route.Annotations)
1154+
initializeOverrideSpec(&r.Spec.Telemetry.CloudKittyAPIOverride.Route, true)
1155+
r.Spec.Telemetry.Template.CloudKitty.SetDefaultRouteAnnotations(r.Spec.Telemetry.CloudKittyAPIOverride.Route.Annotations)
11541156
}
11551157

11561158
// Heat

‎internal/openstack/telemetry.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ func ReconcileTelemetry(ctx context.Context, instance *corev1beta1.OpenStackCont
306306
ctx,
307307
helper,
308308
instance.Namespace,
309-
GetServiceOpenStackOperatorLabel(telemetry.Name),
309+
map[string]string{common.AppSelector: "aodh"},
310310
)
311311
if err != nil {
312312
return ctrl.Result{}, err

‎test/functional/ctlplane/openstackoperator_controller_test.go‎

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2662,6 +2662,137 @@ var _ = Describe("OpenStackOperator controller", func() {
26622662
})
26632663
})
26642664

2665+
When("A telemetry OpenStackControlplane instance is created with cloudkitty enabled and autoscaling disabled", func() {
2666+
BeforeEach(func() {
2667+
spec := GetDefaultOpenStackControlPlaneSpec()
2668+
spec["telemetry"] = map[string]interface{}{
2669+
"enabled": true,
2670+
"template": map[string]interface{}{
2671+
"ceilometer": map[string]interface{}{
2672+
"enabled": false,
2673+
},
2674+
"metricStorage": map[string]interface{}{
2675+
"enabled": false,
2676+
},
2677+
"logging": map[string]interface{}{
2678+
"enabled": false,
2679+
},
2680+
"autoscaling": map[string]interface{}{
2681+
"enabled": false,
2682+
},
2683+
"cloudkitty": map[string]interface{}{
2684+
"enabled": true,
2685+
"apiTimeout": 300,
2686+
},
2687+
},
2688+
}
2689+
2690+
// create cert secrets for rabbitmq instances
2691+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQCertName))
2692+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQCell1CertName))
2693+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQNotificationsCertName))
2694+
// create cert secrets for memcached instance
2695+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.MemcachedCertName))
2696+
// create cert secrets for ovn instance
2697+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.OVNNorthdCertName))
2698+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.OVNControllerCertName))
2699+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.OVNMetricsCertName))
2700+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.InstanceHAMetricsCertName))
2701+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.NeutronOVNCertName))
2702+
// create cert secrets for cloudkitty
2703+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(types.NamespacedName{Name: "cert-cloudkitty-public-route", Namespace: namespace}))
2704+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(types.NamespacedName{Name: "cert-cloudkitty-public-svc", Namespace: namespace}))
2705+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(types.NamespacedName{Name: "cert-cloudkitty-internal-svc", Namespace: namespace}))
2706+
2707+
DeferCleanup(
2708+
th.DeleteInstance,
2709+
CreateOpenStackControlPlane(names.OpenStackControlplaneName, spec),
2710+
)
2711+
})
2712+
2713+
It("should default the cloudkitty route timeout from the cloudkitty apiTimeout", func() {
2714+
OSCtlplane := GetOpenStackControlPlane(names.OpenStackControlplaneName)
2715+
Expect(OSCtlplane.Spec.Telemetry.CloudKittyAPIOverride.Route).Should(Not(BeNil()))
2716+
Expect(OSCtlplane.Spec.Telemetry.CloudKittyAPIOverride.Route.Annotations).Should(HaveKeyWithValue("haproxy.router.openshift.io/timeout", "300s"))
2717+
Expect(OSCtlplane.Spec.Telemetry.CloudKittyAPIOverride.Route.Annotations).Should(HaveKeyWithValue("api.cloudkitty.openstack.org/timeout", "300s"))
2718+
// aodh route defaults are independent of the cloudkitty ones
2719+
Expect(OSCtlplane.Spec.Telemetry.AodhAPIOverride.Route).Should(Not(BeNil()))
2720+
Expect(OSCtlplane.Spec.Telemetry.AodhAPIOverride.Route.Annotations).Should(HaveKeyWithValue("haproxy.router.openshift.io/timeout", "60s"))
2721+
Expect(OSCtlplane.Spec.Telemetry.AodhAPIOverride.Route.Annotations).Should(HaveKeyWithValue("api.aodh.openstack.org/timeout", "60s"))
2722+
})
2723+
2724+
It("should apply the cloudKittyApiOverride and not the aodhApiOverride to the cloudkitty route", func() {
2725+
cloudKittyPublicSvcName := types.NamespacedName{Name: "cloudkitty-public", Namespace: namespace}
2726+
cloudKittyInternalSvcName := types.NamespacedName{Name: "cloudkitty-internal", Namespace: namespace}
2727+
// labels as set by the telemetry-operator on the cloudkitty
2728+
// services, including the osctlplane-service label the
2729+
// openstack-operator injects via the service override
2730+
cloudKittySvcLabels := map[string]string{
2731+
"service": "cloudkitty",
2732+
"osctlplane-service": "telemetry",
2733+
"osctlplane": "",
2734+
}
2735+
2736+
th.CreateService(
2737+
cloudKittyPublicSvcName,
2738+
cloudKittySvcLabels,
2739+
k8s_corev1.ServiceSpec{
2740+
Ports: []k8s_corev1.ServicePort{
2741+
{
2742+
Name: "cloudkitty-public",
2743+
Port: int32(8889),
2744+
Protocol: k8s_corev1.ProtocolTCP,
2745+
},
2746+
},
2747+
})
2748+
cloudKittySvc := th.GetService(cloudKittyPublicSvcName)
2749+
if cloudKittySvc.Annotations == nil {
2750+
cloudKittySvc.Annotations = map[string]string{}
2751+
}
2752+
cloudKittySvc.Annotations[service.AnnotationIngressCreateKey] = "true"
2753+
cloudKittySvc.Annotations[service.AnnotationEndpointKey] = "public"
2754+
Expect(th.K8sClient.Status().Update(th.Ctx, cloudKittySvc)).To(Succeed())
2755+
2756+
th.CreateService(
2757+
cloudKittyInternalSvcName,
2758+
cloudKittySvcLabels,
2759+
k8s_corev1.ServiceSpec{
2760+
Ports: []k8s_corev1.ServicePort{
2761+
{
2762+
Name: "cloudkitty-internal",
2763+
Port: int32(8889),
2764+
Protocol: k8s_corev1.ProtocolTCP,
2765+
},
2766+
},
2767+
})
2768+
cloudKittyIntSvc := th.GetService(cloudKittyInternalSvcName)
2769+
if cloudKittyIntSvc.Annotations == nil {
2770+
cloudKittyIntSvc.Annotations = map[string]string{}
2771+
}
2772+
cloudKittyIntSvc.Annotations[service.AnnotationIngressCreateKey] = "false"
2773+
cloudKittyIntSvc.Annotations[service.AnnotationEndpointKey] = "internal"
2774+
Expect(th.K8sClient.Status().Update(th.Ctx, cloudKittyIntSvc)).To(Succeed())
2775+
2776+
Eventually(func(g Gomega) {
2777+
cloudKittyRoute := &routev1.Route{}
2778+
g.Expect(th.K8sClient.Get(th.Ctx, cloudKittyPublicSvcName, cloudKittyRoute)).Should(Succeed())
2779+
g.Expect(cloudKittyRoute.Annotations).Should(HaveKeyWithValue("haproxy.router.openshift.io/timeout", "300s"))
2780+
g.Expect(cloudKittyRoute.Annotations).Should(HaveKeyWithValue("api.cloudkitty.openstack.org/timeout", "300s"))
2781+
g.Expect(cloudKittyRoute.Annotations).ShouldNot(HaveKey("api.aodh.openstack.org/timeout"))
2782+
}, timeout, interval).Should(Succeed())
2783+
2784+
// the cloudkitty endpoint got exposed, but the aodh service
2785+
// overrides must not be populated from the cloudkitty services
2786+
Eventually(func(g Gomega) {
2787+
telemetry := GetTelemetry(names.TelemetryName)
2788+
g.Expect(telemetry.Spec.CloudKitty.CloudKittyAPI.Override.Service[service.EndpointPublic].EndpointURL).Should(Not(BeNil()))
2789+
for _, svcOverride := range telemetry.Spec.Autoscaling.Aodh.Override.Service {
2790+
g.Expect(svcOverride.EndpointURL).Should(BeNil())
2791+
}
2792+
}, timeout, interval).Should(Succeed())
2793+
})
2794+
})
2795+
26652796
When("OpenStackControlplane instance is deleted", func() {
26662797
BeforeEach(func() {
26672798
DeferCleanup(

0 commit comments

Comments
 (0)