Skip to content

Commit

Permalink
Support cinder setting route annotations
Browse files Browse the repository at this point in the history
This patch allows Cinder to set its route annotations.

Depends-On: openstack-k8s-operators/cinder-operator#396

Jira: https://issues.redhat.com/browse/OSPRH-7393
  • Loading branch information
Akrog authored and abays committed Jun 10, 2024
1 parent 8813d7e commit 8f107c7
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 12 deletions.
4 changes: 4 additions & 0 deletions apis/bases/core.openstack.org_openstackcontrolplanes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,10 @@ spec:
type: boolean
template:
properties:
apiTimeout:
default: 60
minimum: 10
type: integer
cinderAPI:
properties:
customServiceConfig:
Expand Down
18 changes: 16 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 Down Expand Up @@ -459,7 +473,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
2 changes: 1 addition & 1 deletion apis/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/onsi/ginkgo/v2 v2.19.0
github.com/onsi/gomega v1.33.1
github.com/openstack-k8s-operators/barbican-operator/api v0.0.0-20240603141403-1ad477d065a2
github.com/openstack-k8s-operators/cinder-operator/api v0.3.1-0.20240529155246-4afc791bbb82
github.com/openstack-k8s-operators/cinder-operator/api v0.3.1-0.20240607122134-9a88752489a2
github.com/openstack-k8s-operators/designate-operator/api v0.0.0-20240604124031-77b21b330d86
github.com/openstack-k8s-operators/glance-operator/api v0.3.1-0.20240605101720-9531b1fa7924
github.com/openstack-k8s-operators/heat-operator/api v0.3.1-0.20240605063719-371c02948c8c
Expand Down
4 changes: 2 additions & 2 deletions apis/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ github.com/openshift/api v0.0.0-20230414143018-3367bc7e6ac7 h1:rncLxJBpFGqBztyxC
github.com/openshift/api v0.0.0-20230414143018-3367bc7e6ac7/go.mod h1:ctXNyWanKEjGj8sss1KjjHQ3ENKFm33FFnS5BKaIPh4=
github.com/openstack-k8s-operators/barbican-operator/api v0.0.0-20240603141403-1ad477d065a2 h1:spZSWGJ/7VYmowqrZ8lr1RtPV1LdEGF9PXQnQtBqCrw=
github.com/openstack-k8s-operators/barbican-operator/api v0.0.0-20240603141403-1ad477d065a2/go.mod h1:FBMttmFnsXleh/Gohxvgaz5c5HdF7Gsc6/ySC9TU770=
github.com/openstack-k8s-operators/cinder-operator/api v0.3.1-0.20240529155246-4afc791bbb82 h1:Q+U8JpT+grvSaDD9wqpdF6OyrJc1v+qDDkcg60xmDMg=
github.com/openstack-k8s-operators/cinder-operator/api v0.3.1-0.20240529155246-4afc791bbb82/go.mod h1:8Wn6ZAPaJshxozJVPI7uq4qrcUXZmECGAPJK7Ed+uGQ=
github.com/openstack-k8s-operators/cinder-operator/api v0.3.1-0.20240607122134-9a88752489a2 h1:9FUjtE9XUqOw4AsJwBlwX027ZWJYO4RiwqlKzUqJft0=
github.com/openstack-k8s-operators/cinder-operator/api v0.3.1-0.20240607122134-9a88752489a2/go.mod h1:8Wn6ZAPaJshxozJVPI7uq4qrcUXZmECGAPJK7Ed+uGQ=
github.com/openstack-k8s-operators/designate-operator/api v0.0.0-20240604124031-77b21b330d86 h1:pE/BD9Qg5A2CFQHiKJfqZ8Os7obIoTsy8UYNI3sDblc=
github.com/openstack-k8s-operators/designate-operator/api v0.0.0-20240604124031-77b21b330d86/go.mod h1:u53p2KRT083miTWA5oQlU4zITB4FXJOzI/eao51CkbE=
github.com/openstack-k8s-operators/glance-operator/api v0.3.1-0.20240605101720-9531b1fa7924 h1:FtYYqki9eYmXJ2j8mSO9Sqjn2dByvvziIxJWoCQgUhU=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,10 @@ spec:
type: boolean
template:
properties:
apiTimeout:
default: 60
minimum: 10
type: integer
cinderAPI:
properties:
customServiceConfig:
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ require (
github.com/onsi/gomega v1.33.1
github.com/openshift/api v3.9.0+incompatible
github.com/openstack-k8s-operators/barbican-operator/api v0.0.0-20240603141403-1ad477d065a2
github.com/openstack-k8s-operators/cinder-operator/api v0.3.1-0.20240529155246-4afc791bbb82
github.com/openstack-k8s-operators/dataplane-operator/api v0.3.1-0.20240608024258-319ec0e5a28b
github.com/openstack-k8s-operators/cinder-operator/api v0.3.1-0.20240607122134-9a88752489a2
github.com/openstack-k8s-operators/dataplane-operator/api v0.3.1-0.20240605111219-06b9cbfa8a2e
github.com/openstack-k8s-operators/designate-operator/api v0.0.0-20240604124031-77b21b330d86
github.com/openstack-k8s-operators/glance-operator/api v0.3.1-0.20240605101720-9531b1fa7924
github.com/openstack-k8s-operators/heat-operator/api v0.3.1-0.20240605063719-371c02948c8c
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ github.com/openshift/api v0.0.0-20230414143018-3367bc7e6ac7 h1:rncLxJBpFGqBztyxC
github.com/openshift/api v0.0.0-20230414143018-3367bc7e6ac7/go.mod h1:ctXNyWanKEjGj8sss1KjjHQ3ENKFm33FFnS5BKaIPh4=
github.com/openstack-k8s-operators/barbican-operator/api v0.0.0-20240603141403-1ad477d065a2 h1:spZSWGJ/7VYmowqrZ8lr1RtPV1LdEGF9PXQnQtBqCrw=
github.com/openstack-k8s-operators/barbican-operator/api v0.0.0-20240603141403-1ad477d065a2/go.mod h1:FBMttmFnsXleh/Gohxvgaz5c5HdF7Gsc6/ySC9TU770=
github.com/openstack-k8s-operators/cinder-operator/api v0.3.1-0.20240529155246-4afc791bbb82 h1:Q+U8JpT+grvSaDD9wqpdF6OyrJc1v+qDDkcg60xmDMg=
github.com/openstack-k8s-operators/cinder-operator/api v0.3.1-0.20240529155246-4afc791bbb82/go.mod h1:8Wn6ZAPaJshxozJVPI7uq4qrcUXZmECGAPJK7Ed+uGQ=
github.com/openstack-k8s-operators/dataplane-operator/api v0.3.1-0.20240608024258-319ec0e5a28b h1:VRAXcHzieo0mYoXLwkZD1nrfqXyk0a/ok085KKiJDo0=
github.com/openstack-k8s-operators/dataplane-operator/api v0.3.1-0.20240608024258-319ec0e5a28b/go.mod h1:ESTcEmtCGEvlrMPzdbNDeIUozxfKA4zEqhYt/rxJxmE=
github.com/openstack-k8s-operators/cinder-operator/api v0.3.1-0.20240607122134-9a88752489a2 h1:9FUjtE9XUqOw4AsJwBlwX027ZWJYO4RiwqlKzUqJft0=
github.com/openstack-k8s-operators/cinder-operator/api v0.3.1-0.20240607122134-9a88752489a2/go.mod h1:8Wn6ZAPaJshxozJVPI7uq4qrcUXZmECGAPJK7Ed+uGQ=
github.com/openstack-k8s-operators/dataplane-operator/api v0.3.1-0.20240605111219-06b9cbfa8a2e h1:spf4U4j9li8bcdyPn8q83JYdrqRboKtPyZQ8oOR+Gyk=
github.com/openstack-k8s-operators/dataplane-operator/api v0.3.1-0.20240605111219-06b9cbfa8a2e/go.mod h1:ESTcEmtCGEvlrMPzdbNDeIUozxfKA4zEqhYt/rxJxmE=
github.com/openstack-k8s-operators/designate-operator/api v0.0.0-20240604124031-77b21b330d86 h1:pE/BD9Qg5A2CFQHiKJfqZ8Os7obIoTsy8UYNI3sDblc=
github.com/openstack-k8s-operators/designate-operator/api v0.0.0-20240604124031-77b21b330d86/go.mod h1:u53p2KRT083miTWA5oQlU4zITB4FXJOzI/eao51CkbE=
github.com/openstack-k8s-operators/glance-operator/api v0.3.1-0.20240605101720-9531b1fa7924 h1:FtYYqki9eYmXJ2j8mSO9Sqjn2dByvvziIxJWoCQgUhU=
Expand Down
6 changes: 5 additions & 1 deletion tests/functional/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,9 @@ func GetDefaultOpenStackControlPlaneSpec() map[string]interface{} {
ironicTemplate := map[string]interface{}{
"ironicConductors": []interface{}{},
}
cinderTemplate := map[string]interface{}{
"apiTimeout": 60,
}

return map[string]interface{}{
"secret": "osp-secret",
Expand Down Expand Up @@ -379,7 +382,8 @@ func GetDefaultOpenStackControlPlaneSpec() map[string]interface{} {
"enabled": true,
},
"cinder": map[string]interface{}{
"enabled": false,
"enabled": false,
"template": cinderTemplate,
},
"ovn": map[string]interface{}{
"enabled": false,
Expand Down
2 changes: 2 additions & 0 deletions tests/functional/openstackoperator_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,8 @@ 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"))
})

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

0 comments on commit 8f107c7

Please sign in to comment.