Skip to content

Commit 5882ae3

Browse files
committed
Concatenate global and service specific extraMounts
The list of global and service specific extraMounts are now concatenated, instead of the previous behavior where service specific extraMounts would supersede/override the global list. The services that support their own list of extraMounts is unchanged. Those services are cinder, glance, manila and neutron.
1 parent 81a98c7 commit 5882ae3

File tree

4 files changed

+28
-56
lines changed

4 files changed

+28
-56
lines changed

pkg/openstack/cinder.go

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -111,20 +111,13 @@ func ReconcileCinder(ctx context.Context, instance *corev1beta1.OpenStackControl
111111
//cinder.Spec.DatabaseInstance = instance.Name // name of MariaDB we create here
112112
cinder.Spec.DatabaseInstance = "openstack" //FIXME: see above
113113
}
114-
// if already defined at service level (template section), we don't merge
115-
// with the global defined extra volumes
116-
if len(cinder.Spec.ExtraMounts) == 0 {
117-
118-
var cinderVolumes []cinderv1.CinderExtraVolMounts
119-
120-
for _, ev := range instance.Spec.ExtraMounts {
121-
cinderVolumes = append(cinderVolumes, cinderv1.CinderExtraVolMounts{
122-
Name: ev.Name,
123-
Region: ev.Region,
124-
VolMounts: ev.VolMounts,
125-
})
126-
}
127-
cinder.Spec.ExtraMounts = cinderVolumes
114+
// Append globally defined extraMounts to the service's own list.
115+
for _, ev := range instance.Spec.ExtraMounts {
116+
cinder.Spec.ExtraMounts = append(cinder.Spec.ExtraMounts, cinderv1.CinderExtraVolMounts{
117+
Name: ev.Name,
118+
Region: ev.Region,
119+
VolMounts: ev.VolMounts,
120+
})
128121
}
129122
err := controllerutil.SetControllerReference(helper.GetBeforeObject(), cinder, helper.GetScheme())
130123
if err != nil {

pkg/openstack/glance.go

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -150,20 +150,13 @@ func ReconcileGlance(ctx context.Context, instance *corev1beta1.OpenStackControl
150150
if glance.Spec.StorageClass == "" {
151151
glance.Spec.StorageClass = instance.Spec.StorageClass
152152
}
153-
// if already defined at service level (template section), we don't merge
154-
// with the global defined extra volumes
155-
if len(glance.Spec.ExtraMounts) == 0 {
156-
157-
var glanceVolumes []glancev1.GlanceExtraVolMounts
158-
159-
for _, ev := range instance.Spec.ExtraMounts {
160-
glanceVolumes = append(glanceVolumes, glancev1.GlanceExtraVolMounts{
161-
Name: ev.Name,
162-
Region: ev.Region,
163-
VolMounts: ev.VolMounts,
164-
})
165-
}
166-
glance.Spec.ExtraMounts = glanceVolumes
153+
// Append globally defined extraMounts to the service's own list.
154+
for _, ev := range instance.Spec.ExtraMounts {
155+
glance.Spec.ExtraMounts = append(glance.Spec.ExtraMounts, glancev1.GlanceExtraVolMounts{
156+
Name: ev.Name,
157+
Region: ev.Region,
158+
VolMounts: ev.VolMounts,
159+
})
167160
}
168161

169162
err := controllerutil.SetControllerReference(helper.GetBeforeObject(), glance, helper.GetScheme())

pkg/openstack/manila.go

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -112,20 +112,13 @@ func ReconcileManila(ctx context.Context, instance *corev1beta1.OpenStackControl
112112
//manila.Spec.DatabaseInstance = instance.Name // name of MariaDB we create here
113113
manila.Spec.DatabaseInstance = "openstack" //FIXME: see above
114114
}
115-
// if already defined at service level (template section), we don't merge
116-
// with the global defined extra volumes
117-
if len(manila.Spec.ExtraMounts) == 0 {
118-
119-
var manilaVolumes []manilav1.ManilaExtraVolMounts
120-
121-
for _, ev := range instance.Spec.ExtraMounts {
122-
manilaVolumes = append(manilaVolumes, manilav1.ManilaExtraVolMounts{
123-
Name: ev.Name,
124-
Region: ev.Region,
125-
VolMounts: ev.VolMounts,
126-
})
127-
}
128-
manila.Spec.ExtraMounts = manilaVolumes
115+
// Append globally defined extraMounts to the service's own list.
116+
for _, ev := range instance.Spec.ExtraMounts {
117+
manila.Spec.ExtraMounts = append(manila.Spec.ExtraMounts, manilav1.ManilaExtraVolMounts{
118+
Name: ev.Name,
119+
Region: ev.Region,
120+
VolMounts: ev.VolMounts,
121+
})
129122
}
130123
err := controllerutil.SetControllerReference(helper.GetBeforeObject(), manila, helper.GetScheme())
131124
if err != nil {

pkg/openstack/neutron.go

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -143,20 +143,13 @@ func ReconcileNeutron(ctx context.Context, instance *corev1beta1.OpenStackContro
143143
neutronAPI.Spec.DatabaseInstance = "openstack"
144144
}
145145

146-
// if already defined at service level (template section), we don't merge
147-
// with the global defined extra volumes
148-
if len(neutronAPI.Spec.ExtraMounts) == 0 {
149-
150-
var neutronVolumes []neutronv1.NeutronExtraVolMounts
151-
152-
for _, ev := range instance.Spec.ExtraMounts {
153-
neutronVolumes = append(neutronVolumes, neutronv1.NeutronExtraVolMounts{
154-
Name: ev.Name,
155-
Region: ev.Region,
156-
VolMounts: ev.VolMounts,
157-
})
158-
}
159-
neutronAPI.Spec.ExtraMounts = neutronVolumes
146+
// Append globally defined extraMounts to the service's own list.
147+
for _, ev := range instance.Spec.ExtraMounts {
148+
neutronAPI.Spec.ExtraMounts = append(neutronAPI.Spec.ExtraMounts, neutronv1.NeutronExtraVolMounts{
149+
Name: ev.Name,
150+
Region: ev.Region,
151+
VolMounts: ev.VolMounts,
152+
})
160153
}
161154
err := controllerutil.SetControllerReference(helper.GetBeforeObject(), neutronAPI, helper.GetScheme())
162155
if err != nil {

0 commit comments

Comments
 (0)