Skip to content

Commit

Permalink
Merge pull request #830 from Akrog/apiTimeout
Browse files Browse the repository at this point in the history
Support storage setting route annotations
  • Loading branch information
openshift-merge-bot[bot] authored Jun 11, 2024
2 parents 67b5c23 + bbb3c66 commit c2019c1
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 10 deletions.
36 changes: 34 additions & 2 deletions apis/core/v1beta1/openstackcontrolplane_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,17 +401,31 @@ func (r *OpenStackControlPlane) Default() {
}

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

func setOverrideSpec(override **route.OverrideSpec, anno map[string]string) {
initializeOverrideSpec(override, false)
(*override).AddAnnotation(anno)
}

// DefaultServices - common function for calling individual services' defaulting functions
func (r *OpenStackControlPlane) DefaultServices() {
// Cinder
r.Spec.Cinder.Template.Default()
initializeOverrideSpec(&r.Spec.Cinder.APIOverride.Route, true)
r.Spec.Cinder.Template.SetDefaultRouteAnnotations(r.Spec.Cinder.APIOverride.Route.Annotations)

// Galera
for key, template := range r.Spec.Galera.Templates {
Expand All @@ -429,6 +443,22 @@ func (r *OpenStackControlPlane) DefaultServices() {
// Glance
r.Spec.Glance.Template.Default()

// initialize the main APIOverride struct
if r.Spec.Glance.APIOverride == nil {
r.Spec.Glance.APIOverride = map[string]Override{}
}
for name, glanceAPI := range r.Spec.Glance.Template.GlanceAPIs {
var override Override
var ok bool

if override, ok = r.Spec.Glance.APIOverride[name]; !ok {
override = Override{}
}
initializeOverrideSpec(&override.Route, true)
glanceAPI.SetDefaultRouteAnnotations(override.Route.Annotations)
r.Spec.Glance.APIOverride[name] = override
}

// Ironic
// Default Secret
if r.Spec.Ironic.Template.Secret == "" {
Expand All @@ -449,6 +479,8 @@ func (r *OpenStackControlPlane) DefaultServices() {

// Manila
r.Spec.Manila.Template.Default()
initializeOverrideSpec(&r.Spec.Manila.APIOverride.Route, true)
r.Spec.Manila.Template.SetDefaultRouteAnnotations(r.Spec.Manila.APIOverride.Route.Annotations)

// Memcached
for key, template := range r.Spec.Memcached.Templates {
Expand All @@ -459,7 +491,7 @@ func (r *OpenStackControlPlane) DefaultServices() {

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

// Nova
r.Spec.Nova.Template.Default()
Expand Down
9 changes: 1 addition & 8 deletions pkg/openstack/glance.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,8 @@ func ReconcileGlance(ctx context.Context, instance *corev1beta1.OpenStackControl
instance.Spec.Glance.Template.GlanceAPIs[name] = glanceAPI
}

// initialize the main APIOverride struct
if instance.Spec.Glance.APIOverride == nil {
instance.Spec.Glance.APIOverride = map[string]corev1beta1.Override{}
}

var changed = false
for name, glanceAPI := range instance.Spec.Glance.Template.GlanceAPIs {
if _, ok := instance.Spec.Glance.APIOverride[name]; !ok {
instance.Spec.Glance.APIOverride[name] = corev1beta1.Override{}
}
// Retrieve the services by Label and filter on glanceAPI: for
// each instance we should get **only** the associated `SVCs`
// and not the whole list. As per the Glance design doc we know
Expand All @@ -109,6 +101,7 @@ func ReconcileGlance(ctx context.Context, instance *corev1beta1.OpenStackControl
return ctrl.Result{}, err
}
// make sure to get to EndpointConfig when all service got created
// Webhook initializes APIOverride and always has at least the timeout override
if len(svcs.Items) == len(glanceAPI.Override.Service) {
endpointDetails, ctrlResult, err := EnsureEndpointConfig(
ctx,
Expand Down
8 changes: 8 additions & 0 deletions tests/functional/openstackoperator_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,14 @@ var _ = Describe("OpenStackOperator controller", func() {
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"))
Expect(OSCtlplane.Spec.Cinder.APIOverride.Route.Annotations).Should(HaveKeyWithValue("haproxy.router.openshift.io/timeout", "60s"))
Expect(OSCtlplane.Spec.Cinder.APIOverride.Route.Annotations).Should(HaveKeyWithValue("api.cinder.openstack.org/timeout", "60s"))
for name := range OSCtlplane.Spec.Glance.Template.GlanceAPIs {
Expect(OSCtlplane.Spec.Glance.APIOverride[name].Route.Annotations).Should(HaveKeyWithValue("haproxy.router.openshift.io/timeout", "60s"))
Expect(OSCtlplane.Spec.Glance.APIOverride[name].Route.Annotations).Should(HaveKeyWithValue("api.glance.openstack.org/timeout", "60s"))
}
Expect(OSCtlplane.Spec.Manila.APIOverride.Route.Annotations).Should(HaveKeyWithValue("haproxy.router.openshift.io/timeout", "60s"))
Expect(OSCtlplane.Spec.Manila.APIOverride.Route.Annotations).Should(HaveKeyWithValue("api.manila.openstack.org/timeout", "60s"))
})

It("should create selfsigned issuer and public+internal CA and issuer", func() {
Expand Down

0 comments on commit c2019c1

Please sign in to comment.