@@ -28,13 +28,28 @@ const (
2828
2929// ReconcileGlance -
3030func ReconcileGlance (ctx context.Context , instance * corev1beta1.OpenStackControlPlane , version * corev1beta1.OpenStackVersion , helper * helper.Helper ) (ctrl.Result , error ) {
31+ glanceName := "glance"
32+ altGlanceName := fmt .Sprintf ("glance-%s" , instance .UID [:5 ])
33+ if instance .Spec .Glance .UniquePodNames {
34+ glanceName , altGlanceName = altGlanceName , glanceName
35+ }
36+ // Ensure the alternate cinder CR doesn't exist, as the ramdomPodNames flag may have been toggled
3137 glance := & glancev1.Glance {
3238 ObjectMeta : metav1.ObjectMeta {
33- Name : "glance" ,
39+ Name : altGlanceName ,
3440 Namespace : instance .Namespace ,
3541 },
3642 }
43+ if res , err := EnsureDeleted (ctx , helper , glance ); err != nil {
44+ return res , err
45+ }
3746
47+ glance = & glancev1.Glance {
48+ ObjectMeta : metav1.ObjectMeta {
49+ Name : glanceName ,
50+ Namespace : instance .Namespace ,
51+ },
52+ }
3853 Log := GetLogger (ctx )
3954
4055 if ! instance .Spec .Glance .Enabled {
@@ -52,7 +67,7 @@ func ReconcileGlance(ctx context.Context, instance *corev1beta1.OpenStackControl
5267 }
5368
5469 // When component services got created check if there is the need to create a route
55- if err := helper .GetClient ().Get (ctx , types.NamespacedName {Name : "glance" , Namespace : instance .Namespace }, glance ); err != nil {
70+ if err := helper .GetClient ().Get (ctx , types.NamespacedName {Name : glanceName , Namespace : instance .Namespace }, glance ); err != nil {
5671 if ! k8s_errors .IsNotFound (err ) {
5772 return ctrl.Result {}, err
5873 }
@@ -144,7 +159,7 @@ func ReconcileGlance(ctx context.Context, instance *corev1beta1.OpenStackControl
144159 return ctrl.Result {}, nil
145160 }
146161
147- Log .Info ("Reconciling Glance" , "Glance.Namespace" , instance .Namespace , "Glance.Name" , "glance" )
162+ Log .Info ("Reconciling Glance" , "Glance.Namespace" , instance .Namespace , "Glance.Name" , glanceName )
148163 op , err := controllerutil .CreateOrPatch (ctx , helper .GetClient (), glance , func () error {
149164 instance .Spec .Glance .Template .DeepCopyInto (& glance .Spec .GlanceSpecCore )
150165 glance .Spec .ContainerImage = * version .Status .ContainerImages .GlanceAPIImage
0 commit comments