@@ -15,6 +15,7 @@ import (
1515 "k8s.io/apimachinery/pkg/types"
1616 ctrl "sigs.k8s.io/controller-runtime"
1717 "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
18+ "strconv"
1819)
1920
2021const (
@@ -23,17 +24,32 @@ const (
2324 // label set by the service operator as in case of split glanceAPI type the
2425 // the label on public svc gets set to -external and internal instance svc
2526 // to -internal instead of the glance top level glanceType split
26- svcSelector = "tlGlanceAPI"
27+ svcSelector = "tlGlanceAPI"
28+ targetVersion = "v18.0.9"
2729)
2830
2931// ReconcileGlance -
3032func ReconcileGlance (ctx context.Context , instance * corev1beta1.OpenStackControlPlane , version * corev1beta1.OpenStackVersion , helper * helper.Helper ) (ctrl.Result , error ) {
3133 glanceName , altGlanceName := instance .GetServiceName (corev1beta1 .GlanceName , instance .Spec .Glance .UniquePodNames )
32- // Ensure the alternate cinder CR doesn't exist, as the ramdomPodNames flag may have been toggled
34+ apiAnnotations := map [string ]string {}
35+
36+ // Set WSGI annotation to either deploy GlanceAPI in wsgi mode or httpd +
37+ // ProxyPass
38+ //
39+ // - wsgi=true for both greenfield deployments and when a minor update is
40+ // performed from a version greater than v18.0.9
41+ //
42+ // - wsgi=false keeps the httpd + proxypass deployment method.
43+ // This is required when a minor update from a version < FR3 is performed
44+ apiAnnotations ["wsgi" ] = GlanceWSGIAnnotation (version , targetVersion )
45+
46+ // Ensure the alternate glance CR doesn't exist, as the ramdomPodNames flag may have
47+ // been toggled
3348 glance := & glancev1.Glance {
3449 ObjectMeta : metav1.ObjectMeta {
35- Name : altGlanceName ,
36- Namespace : instance .Namespace ,
50+ Name : altGlanceName ,
51+ Namespace : instance .Namespace ,
52+ Annotations : apiAnnotations ,
3753 },
3854 }
3955 if res , err := EnsureDeleted (ctx , helper , glance ); err != nil {
@@ -42,8 +58,9 @@ func ReconcileGlance(ctx context.Context, instance *corev1beta1.OpenStackControl
4258
4359 glance = & glancev1.Glance {
4460 ObjectMeta : metav1.ObjectMeta {
45- Name : glanceName ,
46- Namespace : instance .Namespace ,
61+ Name : glanceName ,
62+ Namespace : instance .Namespace ,
63+ Annotations : apiAnnotations ,
4764 },
4865 }
4966 Log := GetLogger (ctx )
@@ -171,6 +188,9 @@ func ReconcileGlance(ctx context.Context, instance *corev1beta1.OpenStackControl
171188 op , err := controllerutil .CreateOrPatch (ctx , helper .GetClient (), glance , func () error {
172189 instance .Spec .Glance .Template .DeepCopyInto (& glance .Spec .GlanceSpecCore )
173190 glance .Spec .ContainerImage = * version .Status .ContainerImages .GlanceAPIImage
191+ // Set apiAnnotations in the Glance CR: this is currently used to
192+ // influence
193+ glance .SetAnnotations (apiAnnotations )
174194 if glance .Spec .Secret == "" {
175195 glance .Spec .Secret = instance .Spec .Secret
176196 }
@@ -243,3 +263,20 @@ func GlanceImageMatch(ctx context.Context, controlPlane *corev1beta1.OpenStackCo
243263
244264 return true
245265}
266+
267+ // GlanceWSGIAnnotation -
268+ func GlanceWSGIAnnotation (version * corev1beta1.OpenStackVersion , targetVersion string ) string {
269+ wsgi := true
270+ // if there is no deployed version, it is a greenfield scenario and we can
271+ // deploy in wsgi mode (which is the default)
272+ if version .Status .DeployedVersion == nil {
273+ return strconv .FormatBool (wsgi )
274+ }
275+ // Do not deploy Glance in wsgi mode, but keep http+ProxyPass model when the
276+ // version is lower than FR3 (18.0.9). This is required because the previous
277+ // Glance ContainerImage is incompatitble with WSGI.
278+ if version .IsLowerSemVer (targetVersion ) {
279+ wsgi = false
280+ }
281+ return strconv .FormatBool (wsgi )
282+ }
0 commit comments