Skip to content

Commit 3688a7c

Browse files
committed
[OSPRH-39942] Fix telemetry route overrides applied to the wrong routes
Select Aodh services by their service specific label, matching the approach used for Ceilometer and CloudKitty. This keeps the Aodh expose step from matching CloudKitty services. Default the CloudKitty route HAProxy timeout from its apiTimeout, while preserving manually set timeouts. The logic lives in telemetry-operator's CloudKittySpecCore.SetDefaultRouteAnnotations(), called from the webhook the same way as the Aodh one. Signed-off-by: Juan Larriba <jlarriba@redhat.com>
1 parent fbc23a8 commit 3688a7c

9 files changed

Lines changed: 142 additions & 9 deletions

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

‎api/go.mod‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ require (
2626
github.com/openstack-k8s-operators/openstack-baremetal-operator/api v0.6.1-0.20261103051032-1e54bb7406ef
2727
github.com/openstack-k8s-operators/ovn-operator/api v0.6.1-0.20261103051421-0b46dd0416bb
2828
github.com/openstack-k8s-operators/swift-operator/api v0.6.1-0.20261031091010-4a3ff95ec130
29-
github.com/openstack-k8s-operators/telemetry-operator/api v0.6.1-0.20261103174944-bbdc63341f5d
29+
github.com/openstack-k8s-operators/telemetry-operator/api v0.6.1-0.20261105161922-4ae93288c799
3030
github.com/openstack-k8s-operators/watcher-operator/api v0.6.1-0.20261103083711-2421be4b8e95
3131
github.com/rhobs/obo-prometheus-operator/pkg/apis/monitoring v0.77.1-rhobs1 // indirect
3232
github.com/rhobs/observability-operator v1.0.0 // indirect

‎api/go.sum‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ github.com/openstack-k8s-operators/ovn-operator/api v0.6.1-0.20261103051421-0b46
174174
github.com/openstack-k8s-operators/ovn-operator/api v0.6.1-0.20261103051421-0b46dd0416bb/go.mod h1:L7Z4pGiDlz31hr6henF2iESTborrQrJbpXNH7dtcS9k=
175175
github.com/openstack-k8s-operators/swift-operator/api v0.6.1-0.20261031091010-4a3ff95ec130 h1:pZmF9W3kcGHNGOcrj9Fs01mM0IqIkGLjiAjjBNsXCwE=
176176
github.com/openstack-k8s-operators/swift-operator/api v0.6.1-0.20261031091010-4a3ff95ec130/go.mod h1:YTkrKz6EdshbBwGdo5SVgr3uEPhFNhsLNxBvJp/owAw=
177-
github.com/openstack-k8s-operators/telemetry-operator/api v0.6.1-0.20261103174944-bbdc63341f5d h1:H2pdi4Pi79PvWqU6isPX68Syvw9BCjureSS/nevdas4=
178-
github.com/openstack-k8s-operators/telemetry-operator/api v0.6.1-0.20261103174944-bbdc63341f5d/go.mod h1:PfvN+eoz2Dzj2iRbW9ckyjEvHEnoO0TII8D/37YUAgE=
177+
github.com/openstack-k8s-operators/telemetry-operator/api v0.6.1-0.20261105161922-4ae93288c799 h1:JjKAeQ+O29UMfeNLc/fwEOB6WByIrP6xwabzxszgk8k=
178+
github.com/openstack-k8s-operators/telemetry-operator/api v0.6.1-0.20261105161922-4ae93288c799/go.mod h1:PfvN+eoz2Dzj2iRbW9ckyjEvHEnoO0TII8D/37YUAgE=
179179
github.com/openstack-k8s-operators/watcher-operator/api v0.6.1-0.20261103083711-2421be4b8e95 h1:PJp2bXL3hbWWgj5GA+MX38SjpAAcCLGSRw9Cpub+AzE=
180180
github.com/openstack-k8s-operators/watcher-operator/api v0.6.1-0.20261103083711-2421be4b8e95/go.mod h1:9PR8VXwCAO4Yg/pzTeMsQto1DLZyxP5vz6Hc4pZic08=
181181
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=

‎config/operator/manager_operator_images.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ spec:
4848
- name: RELATED_IMAGE_SWIFT_OPERATOR_MANAGER_IMAGE_URL
4949
value: quay.io/openstack-k8s-operators/swift-operator@sha256:dfe7445709ca94bab96bc80ec94977299c86f15a9707e8578925ebe9090e9d8b
5050
- name: RELATED_IMAGE_TELEMETRY_OPERATOR_MANAGER_IMAGE_URL
51-
value: quay.io/openstack-k8s-operators/telemetry-operator@sha256:bf6ded4dc05b611b566193f7ec16672cfd34c7e959e987e17e2cdc4e2866d6e3
51+
value: quay.io/openstack-k8s-operators/telemetry-operator@sha256:2441ece6ad5038a04d3b76622a3b9de618c83b3e7076a2a2790d1a61e59ceb0b
5252
- name: RELATED_IMAGE_TEST_OPERATOR_MANAGER_IMAGE_URL
5353
value: quay.io/openstack-k8s-operators/test-operator@sha256:54ac32df61015690c23f47d8071f12e940590eda073ba37743b2b30f07e3b99b
5454
- name: RELATED_IMAGE_WATCHER_OPERATOR_MANAGER_IMAGE_URL

‎go.mod‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ require (
3636
github.com/openstack-k8s-operators/openstack-operator/api v0.0.0-00010101000000-000000000000
3737
github.com/openstack-k8s-operators/ovn-operator/api v0.6.1-0.20261103051421-0b46dd0416bb
3838
github.com/openstack-k8s-operators/swift-operator/api v0.6.1-0.20261031091010-4a3ff95ec130
39-
github.com/openstack-k8s-operators/telemetry-operator/api v0.6.1-0.20261103174944-bbdc63341f5d
39+
github.com/openstack-k8s-operators/telemetry-operator/api v0.6.1-0.20261105161922-4ae93288c799
4040
github.com/openstack-k8s-operators/test-operator/api v0.6.1-0.20261103131032-1959b576ec37
4141
github.com/openstack-k8s-operators/watcher-operator/api v0.6.1-0.20261103083711-2421be4b8e95
4242
github.com/pkg/errors v0.9.1

‎go.sum‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ github.com/openstack-k8s-operators/ovn-operator/api v0.6.1-0.20261103051421-0b46
206206
github.com/openstack-k8s-operators/ovn-operator/api v0.6.1-0.20261103051421-0b46dd0416bb/go.mod h1:L7Z4pGiDlz31hr6henF2iESTborrQrJbpXNH7dtcS9k=
207207
github.com/openstack-k8s-operators/swift-operator/api v0.6.1-0.20261031091010-4a3ff95ec130 h1:pZmF9W3kcGHNGOcrj9Fs01mM0IqIkGLjiAjjBNsXCwE=
208208
github.com/openstack-k8s-operators/swift-operator/api v0.6.1-0.20261031091010-4a3ff95ec130/go.mod h1:YTkrKz6EdshbBwGdo5SVgr3uEPhFNhsLNxBvJp/owAw=
209-
github.com/openstack-k8s-operators/telemetry-operator/api v0.6.1-0.20261103174944-bbdc63341f5d h1:H2pdi4Pi79PvWqU6isPX68Syvw9BCjureSS/nevdas4=
210-
github.com/openstack-k8s-operators/telemetry-operator/api v0.6.1-0.20261103174944-bbdc63341f5d/go.mod h1:PfvN+eoz2Dzj2iRbW9ckyjEvHEnoO0TII8D/37YUAgE=
209+
github.com/openstack-k8s-operators/telemetry-operator/api v0.6.1-0.20261105161922-4ae93288c799 h1:JjKAeQ+O29UMfeNLc/fwEOB6WByIrP6xwabzxszgk8k=
210+
github.com/openstack-k8s-operators/telemetry-operator/api v0.6.1-0.20261105161922-4ae93288c799/go.mod h1:PfvN+eoz2Dzj2iRbW9ckyjEvHEnoO0TII8D/37YUAgE=
211211
github.com/openstack-k8s-operators/test-operator/api v0.6.1-0.20261103131032-1959b576ec37 h1:lQ9qMNnq07QHgAjrUtnVHUcyUtOQbkMkEMhmSn4hGVo=
212212
github.com/openstack-k8s-operators/test-operator/api v0.6.1-0.20261103131032-1959b576ec37/go.mod h1:zBazYSWjHTj+7IHzrXyRqywS6tLFnmzHtHVJ2pV2+jc=
213213
github.com/openstack-k8s-operators/watcher-operator/api v0.6.1-0.20261103083711-2421be4b8e95 h1:PJp2bXL3hbWWgj5GA+MX38SjpAAcCLGSRw9Cpub+AzE=

‎hack/export_operator_related_images.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ export RELATED_IMAGE_OCTAVIA_OPERATOR_MANAGER_IMAGE_URL=quay.io/openstack-k8s-op
1717
export RELATED_IMAGE_OPENSTACK_BAREMETAL_OPERATOR_MANAGER_IMAGE_URL=quay.io/openstack-k8s-operators/openstack-baremetal-operator@sha256:2b34fa6e0e18208ae7c3722f4005a6462ad4c6a7d991c94d0334471c707bbe72
1818
export RELATED_IMAGE_OVN_OPERATOR_MANAGER_IMAGE_URL=quay.io/openstack-k8s-operators/ovn-operator@sha256:463203dcdf64d3ba31ddb8690b0318e1227ab4b7b3a2c8cbac179136824e05d7
1919
export RELATED_IMAGE_SWIFT_OPERATOR_MANAGER_IMAGE_URL=quay.io/openstack-k8s-operators/swift-operator@sha256:dfe7445709ca94bab96bc80ec94977299c86f15a9707e8578925ebe9090e9d8b
20-
export RELATED_IMAGE_TELEMETRY_OPERATOR_MANAGER_IMAGE_URL=quay.io/openstack-k8s-operators/telemetry-operator@sha256:bf6ded4dc05b611b566193f7ec16672cfd34c7e959e987e17e2cdc4e2866d6e3
20+
export RELATED_IMAGE_TELEMETRY_OPERATOR_MANAGER_IMAGE_URL=quay.io/openstack-k8s-operators/telemetry-operator@sha256:2441ece6ad5038a04d3b76622a3b9de618c83b3e7076a2a2790d1a61e59ceb0b
2121
export RELATED_IMAGE_TEST_OPERATOR_MANAGER_IMAGE_URL=quay.io/openstack-k8s-operators/test-operator@sha256:54ac32df61015690c23f47d8071f12e940590eda073ba37743b2b30f07e3b99b
2222
export RELATED_IMAGE_WATCHER_OPERATOR_MANAGER_IMAGE_URL=quay.io/openstack-k8s-operators/watcher-operator@sha256:263503099909d67dd34e2770a839d6085668d796fdfa4fb54aa0a40ccf12a2b8

‎internal/openstack/telemetry.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ func ReconcileTelemetry(ctx context.Context, instance *corev1beta1.OpenStackCont
301301
ctx,
302302
helper,
303303
instance.Namespace,
304-
GetServiceOpenStackOperatorLabel(telemetry.Name),
304+
map[string]string{common.AppSelector: "aodh"},
305305
)
306306
if err != nil {
307307
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
@@ -2464,6 +2464,137 @@ var _ = Describe("OpenStackOperator controller", func() {
24642464
})
24652465
})
24662466

2467+
When("A telemetry OpenStackControlplane instance is created with cloudkitty enabled and autoscaling disabled", func() {
2468+
BeforeEach(func() {
2469+
spec := GetDefaultOpenStackControlPlaneSpec()
2470+
spec["telemetry"] = map[string]interface{}{
2471+
"enabled": true,
2472+
"template": map[string]interface{}{
2473+
"ceilometer": map[string]interface{}{
2474+
"enabled": false,
2475+
},
2476+
"metricStorage": map[string]interface{}{
2477+
"enabled": false,
2478+
},
2479+
"logging": map[string]interface{}{
2480+
"enabled": false,
2481+
},
2482+
"autoscaling": map[string]interface{}{
2483+
"enabled": false,
2484+
},
2485+
"cloudkitty": map[string]interface{}{
2486+
"enabled": true,
2487+
"apiTimeout": 300,
2488+
},
2489+
},
2490+
}
2491+
2492+
// create cert secrets for rabbitmq instances
2493+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQCertName))
2494+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQCell1CertName))
2495+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQNotificationsCertName))
2496+
// create cert secrets for memcached instance
2497+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.MemcachedCertName))
2498+
// create cert secrets for ovn instance
2499+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.OVNNorthdCertName))
2500+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.OVNControllerCertName))
2501+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.OVNMetricsCertName))
2502+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.InstanceHAMetricsCertName))
2503+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.NeutronOVNCertName))
2504+
// create cert secrets for cloudkitty
2505+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(types.NamespacedName{Name: "cert-cloudkitty-public-route", Namespace: namespace}))
2506+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(types.NamespacedName{Name: "cert-cloudkitty-public-svc", Namespace: namespace}))
2507+
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(types.NamespacedName{Name: "cert-cloudkitty-internal-svc", Namespace: namespace}))
2508+
2509+
DeferCleanup(
2510+
th.DeleteInstance,
2511+
CreateOpenStackControlPlane(names.OpenStackControlplaneName, spec),
2512+
)
2513+
})
2514+
2515+
It("should default the cloudkitty route timeout from the cloudkitty apiTimeout", func() {
2516+
OSCtlplane := GetOpenStackControlPlane(names.OpenStackControlplaneName)
2517+
Expect(OSCtlplane.Spec.Telemetry.CloudKittyAPIOverride.Route).Should(Not(BeNil()))
2518+
Expect(OSCtlplane.Spec.Telemetry.CloudKittyAPIOverride.Route.Annotations).Should(HaveKeyWithValue("haproxy.router.openshift.io/timeout", "300s"))
2519+
Expect(OSCtlplane.Spec.Telemetry.CloudKittyAPIOverride.Route.Annotations).Should(HaveKeyWithValue("api.cloudkitty.openstack.org/timeout", "300s"))
2520+
// aodh route defaults are independent of the cloudkitty ones
2521+
Expect(OSCtlplane.Spec.Telemetry.AodhAPIOverride.Route).Should(Not(BeNil()))
2522+
Expect(OSCtlplane.Spec.Telemetry.AodhAPIOverride.Route.Annotations).Should(HaveKeyWithValue("haproxy.router.openshift.io/timeout", "60s"))
2523+
Expect(OSCtlplane.Spec.Telemetry.AodhAPIOverride.Route.Annotations).Should(HaveKeyWithValue("api.aodh.openstack.org/timeout", "60s"))
2524+
})
2525+
2526+
It("should apply the cloudKittyApiOverride and not the aodhApiOverride to the cloudkitty route", func() {
2527+
cloudKittyPublicSvcName := types.NamespacedName{Name: "cloudkitty-public", Namespace: namespace}
2528+
cloudKittyInternalSvcName := types.NamespacedName{Name: "cloudkitty-internal", Namespace: namespace}
2529+
// labels as set by the telemetry-operator on the cloudkitty
2530+
// services, including the osctlplane-service label the
2531+
// openstack-operator injects via the service override
2532+
cloudKittySvcLabels := map[string]string{
2533+
"service": "cloudkitty",
2534+
"osctlplane-service": "telemetry",
2535+
"osctlplane": "",
2536+
}
2537+
2538+
th.CreateService(
2539+
cloudKittyPublicSvcName,
2540+
cloudKittySvcLabels,
2541+
k8s_corev1.ServiceSpec{
2542+
Ports: []k8s_corev1.ServicePort{
2543+
{
2544+
Name: "cloudkitty-public",
2545+
Port: int32(8889),
2546+
Protocol: k8s_corev1.ProtocolTCP,
2547+
},
2548+
},
2549+
})
2550+
cloudKittySvc := th.GetService(cloudKittyPublicSvcName)
2551+
if cloudKittySvc.Annotations == nil {
2552+
cloudKittySvc.Annotations = map[string]string{}
2553+
}
2554+
cloudKittySvc.Annotations[service.AnnotationIngressCreateKey] = "true"
2555+
cloudKittySvc.Annotations[service.AnnotationEndpointKey] = "public"
2556+
Expect(th.K8sClient.Status().Update(th.Ctx, cloudKittySvc)).To(Succeed())
2557+
2558+
th.CreateService(
2559+
cloudKittyInternalSvcName,
2560+
cloudKittySvcLabels,
2561+
k8s_corev1.ServiceSpec{
2562+
Ports: []k8s_corev1.ServicePort{
2563+
{
2564+
Name: "cloudkitty-internal",
2565+
Port: int32(8889),
2566+
Protocol: k8s_corev1.ProtocolTCP,
2567+
},
2568+
},
2569+
})
2570+
cloudKittyIntSvc := th.GetService(cloudKittyInternalSvcName)
2571+
if cloudKittyIntSvc.Annotations == nil {
2572+
cloudKittyIntSvc.Annotations = map[string]string{}
2573+
}
2574+
cloudKittyIntSvc.Annotations[service.AnnotationIngressCreateKey] = "false"
2575+
cloudKittyIntSvc.Annotations[service.AnnotationEndpointKey] = "internal"
2576+
Expect(th.K8sClient.Status().Update(th.Ctx, cloudKittyIntSvc)).To(Succeed())
2577+
2578+
Eventually(func(g Gomega) {
2579+
cloudKittyRoute := &routev1.Route{}
2580+
g.Expect(th.K8sClient.Get(th.Ctx, cloudKittyPublicSvcName, cloudKittyRoute)).Should(Succeed())
2581+
g.Expect(cloudKittyRoute.Annotations).Should(HaveKeyWithValue("haproxy.router.openshift.io/timeout", "300s"))
2582+
g.Expect(cloudKittyRoute.Annotations).Should(HaveKeyWithValue("api.cloudkitty.openstack.org/timeout", "300s"))
2583+
g.Expect(cloudKittyRoute.Annotations).ShouldNot(HaveKey("api.aodh.openstack.org/timeout"))
2584+
}, timeout, interval).Should(Succeed())
2585+
2586+
// the cloudkitty endpoint got exposed, but the aodh service
2587+
// overrides must not be populated from the cloudkitty services
2588+
Eventually(func(g Gomega) {
2589+
telemetry := GetTelemetry(names.TelemetryName)
2590+
g.Expect(telemetry.Spec.CloudKitty.CloudKittyAPI.Override.Service[service.EndpointPublic].EndpointURL).Should(Not(BeNil()))
2591+
for _, svcOverride := range telemetry.Spec.Autoscaling.Aodh.Override.Service {
2592+
g.Expect(svcOverride.EndpointURL).Should(BeNil())
2593+
}
2594+
}, timeout, interval).Should(Succeed())
2595+
})
2596+
})
2597+
24672598
When("OpenStackControlplane instance is deleted", func() {
24682599
BeforeEach(func() {
24692600
DeferCleanup(

0 commit comments

Comments
 (0)