@@ -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