Skip to content

Commit

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

Depends-On: openstack-k8s-operators/glance-operator#550

Jira: https://issues.redhat.com/browse/OSPRH-7415
  • Loading branch information
Akrog authored and abays committed Jun 10, 2024
1 parent 8f107c7 commit 1361437
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 21 deletions.
7 changes: 7 additions & 0 deletions apis/bases/core.openstack.org_openstackcontrolplanes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3505,6 +3505,10 @@ spec:
type: boolean
template:
properties:
apiTimeout:
default: 60
minimum: 1
type: integer
customServiceConfig:
type: string
customServiceConfigSecrets:
Expand Down Expand Up @@ -4285,6 +4289,9 @@ spec:
glanceAPIs:
additionalProperties:
properties:
apiTimeout:
minimum: 1
type: integer
containerImage:
type: string
customServiceConfig:
Expand Down
16 changes: 16 additions & 0 deletions apis/core/v1beta1/openstackcontrolplane_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,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 Down
4 changes: 2 additions & 2 deletions apis/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ require (
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.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/glance-operator/api v0.3.1-0.20240607103704-ebd246f3792c
github.com/openstack-k8s-operators/heat-operator/api v0.3.1-0.20240605063719-371c02948c8c
github.com/openstack-k8s-operators/horizon-operator/api v0.3.1-0.20240604091541-cdb648f9a7ac
github.com/openstack-k8s-operators/infra-operator/apis v0.3.1-0.20240604144138-996e41d1af19
github.com/openstack-k8s-operators/ironic-operator/api v0.3.1-0.20240523093522-7a25580a799d
github.com/openstack-k8s-operators/keystone-operator/api v0.3.1-0.20240605055850-8ee0ece70906
github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240603143707-f5c5fe030fdd
github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240606071226-62abb00585ce
github.com/openstack-k8s-operators/lib-common/modules/storage v0.3.1-0.20240603143707-f5c5fe030fdd
github.com/openstack-k8s-operators/manila-operator/api v0.3.1-0.20240602180119-bb1bd220b0ff
github.com/openstack-k8s-operators/mariadb-operator/api v0.3.1-0.20240604125710-954ab886bb52
Expand Down
8 changes: 4 additions & 4 deletions apis/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ github.com/openstack-k8s-operators/cinder-operator/api v0.3.1-0.20240607122134-9
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=
github.com/openstack-k8s-operators/glance-operator/api v0.3.1-0.20240605101720-9531b1fa7924/go.mod h1:f0L4NpxrXd+yPoBmizGYLEn9ffU8VMMheYilRV/hNWc=
github.com/openstack-k8s-operators/glance-operator/api v0.3.1-0.20240607103704-ebd246f3792c h1:A13NniqLrN6DtdE3ULXT6zF3ZqDqvM8YOWdPv46GLe4=
github.com/openstack-k8s-operators/glance-operator/api v0.3.1-0.20240607103704-ebd246f3792c/go.mod h1:AeZpbVpCapdr3T4j9dPlGccNzLstzYTsXVjlqFYTWvQ=
github.com/openstack-k8s-operators/heat-operator/api v0.3.1-0.20240605063719-371c02948c8c h1:jY2lmfBh1Z/nSFwOrna/yIqJhMH4i1YYaBpdr+8Sc40=
github.com/openstack-k8s-operators/heat-operator/api v0.3.1-0.20240605063719-371c02948c8c/go.mod h1:uIOH4pC2ka8229p40Wz0AWBCev0LGQxZfOcrDUTahqs=
github.com/openstack-k8s-operators/horizon-operator/api v0.3.1-0.20240604091541-cdb648f9a7ac h1:PefPL9dy16A47TmEsjlGbJcM9tmXA75qAxh9jxQ/Vx4=
Expand All @@ -91,8 +91,8 @@ github.com/openstack-k8s-operators/ironic-operator/api v0.3.1-0.20240523093522-7
github.com/openstack-k8s-operators/ironic-operator/api v0.3.1-0.20240523093522-7a25580a799d/go.mod h1:rltaem4x0R2LE4fTdUOVNAp7nBwzTSpKBdhfrQxZIX8=
github.com/openstack-k8s-operators/keystone-operator/api v0.3.1-0.20240605055850-8ee0ece70906 h1:sq7CD7w44uAs+5Yd5wX1TgZR2vyMKY3YN6iddCJwz8M=
github.com/openstack-k8s-operators/keystone-operator/api v0.3.1-0.20240605055850-8ee0ece70906/go.mod h1:GWJdAtjPUEwNFbRKwlXkeTHMiGCqySE4qJo0fKZSayo=
github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240603143707-f5c5fe030fdd h1:8s6RMighpgvpYF3WEdEKoLjfrqQ8QJpF4FaP7tOvXSI=
github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240603143707-f5c5fe030fdd/go.mod h1:4Fe07vWr4OYg2qoFwoOM8rHEukdD3/r3FBqkYKE5//E=
github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240606071226-62abb00585ce h1:3+BwULpV9ooBYtZ3CVnOXsO40gu/w76a8tqvM45qLYk=
github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240606071226-62abb00585ce/go.mod h1:4Fe07vWr4OYg2qoFwoOM8rHEukdD3/r3FBqkYKE5//E=
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.3.1-0.20240603143707-f5c5fe030fdd h1:bdwHfkscWl/RtCZHsnbd2hSj4kM0EhJpkrQ7ivajPN0=
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.3.1-0.20240603143707-f5c5fe030fdd/go.mod h1:TMUocGLbCA0t/wR418+Y+KpyASgk4Ng/EwZu41rpGck=
github.com/openstack-k8s-operators/lib-common/modules/storage v0.3.1-0.20240603143707-f5c5fe030fdd h1:+5pEzyWRQEb6ijtXgqzTkJFY8sU324Iz+TJ4q1GxtIs=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3505,6 +3505,10 @@ spec:
type: boolean
template:
properties:
apiTimeout:
default: 60
minimum: 1
type: integer
customServiceConfig:
type: string
customServiceConfigSecrets:
Expand Down Expand Up @@ -4285,6 +4289,9 @@ spec:
glanceAPIs:
additionalProperties:
properties:
apiTimeout:
minimum: 1
type: integer
containerImage:
type: string
customServiceConfig:
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ require (
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/glance-operator/api v0.3.1-0.20240607103704-ebd246f3792c
github.com/openstack-k8s-operators/heat-operator/api v0.3.1-0.20240605063719-371c02948c8c
github.com/openstack-k8s-operators/horizon-operator/api v0.3.1-0.20240604091541-cdb648f9a7ac
github.com/openstack-k8s-operators/infra-operator/apis v0.3.1-0.20240604144138-996e41d1af19
github.com/openstack-k8s-operators/ironic-operator/api v0.3.1-0.20240523093522-7a25580a799d
github.com/openstack-k8s-operators/keystone-operator/api v0.3.1-0.20240605055850-8ee0ece70906
github.com/openstack-k8s-operators/lib-common/modules/certmanager v0.0.0-20240603143707-f5c5fe030fdd
github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240603143707-f5c5fe030fdd
github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240606071226-62abb00585ce
github.com/openstack-k8s-operators/lib-common/modules/test v0.3.1-0.20240603143707-f5c5fe030fdd
github.com/openstack-k8s-operators/manila-operator/api v0.3.1-0.20240602180119-bb1bd220b0ff
github.com/openstack-k8s-operators/mariadb-operator/api v0.3.1-0.20240604125710-954ab886bb52
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ github.com/openstack-k8s-operators/dataplane-operator/api v0.3.1-0.2024060511121
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=
github.com/openstack-k8s-operators/glance-operator/api v0.3.1-0.20240605101720-9531b1fa7924/go.mod h1:f0L4NpxrXd+yPoBmizGYLEn9ffU8VMMheYilRV/hNWc=
github.com/openstack-k8s-operators/glance-operator/api v0.3.1-0.20240607103704-ebd246f3792c h1:A13NniqLrN6DtdE3ULXT6zF3ZqDqvM8YOWdPv46GLe4=
github.com/openstack-k8s-operators/glance-operator/api v0.3.1-0.20240607103704-ebd246f3792c/go.mod h1:AeZpbVpCapdr3T4j9dPlGccNzLstzYTsXVjlqFYTWvQ=
github.com/openstack-k8s-operators/heat-operator/api v0.3.1-0.20240605063719-371c02948c8c h1:jY2lmfBh1Z/nSFwOrna/yIqJhMH4i1YYaBpdr+8Sc40=
github.com/openstack-k8s-operators/heat-operator/api v0.3.1-0.20240605063719-371c02948c8c/go.mod h1:uIOH4pC2ka8229p40Wz0AWBCev0LGQxZfOcrDUTahqs=
github.com/openstack-k8s-operators/horizon-operator/api v0.3.1-0.20240604091541-cdb648f9a7ac h1:PefPL9dy16A47TmEsjlGbJcM9tmXA75qAxh9jxQ/Vx4=
Expand All @@ -118,8 +118,8 @@ github.com/openstack-k8s-operators/keystone-operator/api v0.3.1-0.20240605055850
github.com/openstack-k8s-operators/keystone-operator/api v0.3.1-0.20240605055850-8ee0ece70906/go.mod h1:GWJdAtjPUEwNFbRKwlXkeTHMiGCqySE4qJo0fKZSayo=
github.com/openstack-k8s-operators/lib-common/modules/certmanager v0.0.0-20240603143707-f5c5fe030fdd h1:HCh4vEjBhzCLmovOvDmnHVdRlGW3HC51geNhUuxhK+c=
github.com/openstack-k8s-operators/lib-common/modules/certmanager v0.0.0-20240603143707-f5c5fe030fdd/go.mod h1:f7idGLPDLGerFTLB1W8R+eb68GjI3105VoqtzKH77LI=
github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240603143707-f5c5fe030fdd h1:8s6RMighpgvpYF3WEdEKoLjfrqQ8QJpF4FaP7tOvXSI=
github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240603143707-f5c5fe030fdd/go.mod h1:4Fe07vWr4OYg2qoFwoOM8rHEukdD3/r3FBqkYKE5//E=
github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240606071226-62abb00585ce h1:3+BwULpV9ooBYtZ3CVnOXsO40gu/w76a8tqvM45qLYk=
github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240606071226-62abb00585ce/go.mod h1:4Fe07vWr4OYg2qoFwoOM8rHEukdD3/r3FBqkYKE5//E=
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.3.1-0.20240603143707-f5c5fe030fdd h1:bdwHfkscWl/RtCZHsnbd2hSj4kM0EhJpkrQ7ivajPN0=
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.3.1-0.20240603143707-f5c5fe030fdd/go.mod h1:TMUocGLbCA0t/wR418+Y+KpyASgk4Ng/EwZu41rpGck=
github.com/openstack-k8s-operators/lib-common/modules/storage v0.3.1-0.20240603143707-f5c5fe030fdd h1:+5pEzyWRQEb6ijtXgqzTkJFY8sU324Iz+TJ4q1GxtIs=
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
6 changes: 5 additions & 1 deletion tests/functional/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,9 @@ func GetDefaultOpenStackControlPlaneSpec() map[string]interface{} {
cinderTemplate := map[string]interface{}{
"apiTimeout": 60,
}
glanceTemplate := map[string]interface{}{
"apiTimeout": 60,
}

return map[string]interface{}{
"secret": "osp-secret",
Expand All @@ -376,7 +379,8 @@ func GetDefaultOpenStackControlPlaneSpec() map[string]interface{} {
"enabled": false,
},
"glance": map[string]interface{}{
"enabled": false,
"enabled": false,
"template": glanceTemplate,
},
"horizon": map[string]interface{}{
"enabled": true,
Expand Down
4 changes: 4 additions & 0 deletions tests/functional/openstackoperator_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,10 @@ var _ = Describe("OpenStackOperator controller", func() {
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"))
}
})

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

0 comments on commit 1361437

Please sign in to comment.