Skip to content

Commit

Permalink
Add Neutron's default route annotations
Browse files Browse the repository at this point in the history
When the webhook calls for Neutron defaults, it should also write the
route override annotation on Neutron's CR section.

Signed-off-by: Elvira García <[email protected]>
  • Loading branch information
elvgarrui committed Mar 27, 2024
1 parent 2fcb054 commit 1c976b7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
10 changes: 10 additions & 0 deletions apis/core/v1beta1/openstackcontrolplane_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package v1beta1
import (
"fmt"

"github.com/openstack-k8s-operators/lib-common/modules/common/route"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
Expand Down Expand Up @@ -318,6 +319,14 @@ func (r *OpenStackControlPlane) Default() {
r.DefaultServices()
}

// Helper function to initialize overrideSpec object. Could be moved to lib-common.
func initializeOverrideSpec(override **route.OverrideSpec, anno map[string]string) {
if *override == nil {
*override = &route.OverrideSpec{}
}
(*override).AddAnnotation(anno)
}

// DefaultServices - common function for calling individual services' defaulting functions
func (r *OpenStackControlPlane) DefaultServices() {
// RabbitMQ
Expand Down Expand Up @@ -381,6 +390,7 @@ func (r *OpenStackControlPlane) DefaultServices() {

// Neutron
r.Spec.Neutron.Template.Default()
initializeOverrideSpec(&r.Spec.Neutron.APIOverride.Route, r.Spec.Neutron.Template.GetDefaultRouteAnnotations())

// Nova
r.Spec.Nova.Template.Default()
Expand Down
5 changes: 5 additions & 0 deletions tests/functional/openstackoperator_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ var _ = Describe("OpenStackOperator controller", func() {
g.Expect(keystoneAPI).Should(Not(BeNil()))
}, timeout, interval).Should(Succeed())
})
// Default route timeouts are set
It("should have default timeout for the routes set", func() {
OSCtlplane := GetOpenStackControlPlane(names.OpenStackControlplaneName)
Expect(OSCtlplane.Spec.Neutron.APIOverride.Route.Annotations).Should(HaveKeyWithValue("haproxy.router.openshift.io/timeout", "120s"))
})

It("should create selfsigned issuer and public+internal CA and issuer", func() {
OSCtlplane := GetOpenStackControlPlane(names.OpenStackControlplaneName)
Expand Down

0 comments on commit 1c976b7

Please sign in to comment.