Skip to content

Commit 4bca5d7

Browse files
committed
Do not use strings.TrimPrefix to get ShareName
As done with cinder as part of [1], to make manila consistent with that work, this patch removes the need of using strings.TrimPrefix and instead relies on ShareName() function, that returns the instance name stored as label in every manilaShare instance. [1] openstack-k8s-operators/cinder-operator#463 Signed-off-by: Francesco Pantano <[email protected]>
1 parent 76179db commit 4bca5d7

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

pkg/manila/volumes.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,6 @@ func GetVolumes(name string, extraVol []manilav1.ManilaExtraVolMounts, svc []sto
4848
},
4949
},
5050
},
51-
/*{
52-
Name: "config-data-merged",
53-
VolumeSource: corev1.VolumeSource{
54-
EmptyDir: &corev1.EmptyDirVolumeSource{Medium: ""},
55-
},
56-
},*/
5751
}
5852

5953
for _, exv := range extraVol {

pkg/manilashare/statefulset.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,13 @@ func StatefulSet(
8181
volumes := GetVolumes(
8282
manila.GetOwningManilaName(instance),
8383
instance.Name,
84-
instance.Spec.ExtraMounts)
84+
instance.Spec.ExtraMounts,
85+
instance.ShareName(),
86+
)
8587

8688
volumeMounts := GetVolumeMounts(
87-
instance.Name,
8889
instance.Spec.ExtraMounts,
90+
instance.ShareName(),
8991
)
9092

9193
// Add the CA bundle

pkg/manilashare/volumes.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@ import (
55
manilav1 "github.com/openstack-k8s-operators/manila-operator/api/v1beta1"
66
"github.com/openstack-k8s-operators/manila-operator/pkg/manila"
77
corev1 "k8s.io/api/core/v1"
8-
"strings"
98
)
109

1110
// GetVolumes -
12-
func GetVolumes(parentName string, name string, extraVol []manilav1.ManilaExtraVolMounts) []corev1.Volume {
11+
func GetVolumes(
12+
parentName string,
13+
name string,
14+
extraVol []manilav1.ManilaExtraVolMounts,
15+
propagationInstanceName string,
16+
) []corev1.Volume {
1317
var config0644AccessMode int32 = 0644
1418
var dirOrCreate = corev1.HostPathDirectoryOrCreate
1519

@@ -35,12 +39,15 @@ func GetVolumes(parentName string, name string, extraVol []manilav1.ManilaExtraV
3539
}
3640

3741
// Set the propagation levels for ManilaShare, including the backend name
38-
propagation := append(manila.ManilaSharePropagation, storage.PropagationType(strings.TrimPrefix(name, "manila-share-")))
42+
propagation := append(manila.ManilaSharePropagation, storage.PropagationType(propagationInstanceName))
3943
return append(manila.GetVolumes(parentName, extraVol, propagation), shareVolumes...)
4044
}
4145

4246
// GetVolumeMounts - Manila Share VolumeMounts
43-
func GetVolumeMounts(name string, extraVol []manilav1.ManilaExtraVolMounts) []corev1.VolumeMount {
47+
func GetVolumeMounts(
48+
extraVol []manilav1.ManilaExtraVolMounts,
49+
propagationInstanceName string,
50+
) []corev1.VolumeMount {
4451
shareVolumeMounts := []corev1.VolumeMount{
4552
{
4653
Name: "config-data-custom",
@@ -59,6 +66,6 @@ func GetVolumeMounts(name string, extraVol []manilav1.ManilaExtraVolMounts) []co
5966
}
6067

6168
// Set the propagation levels for ManilaShare, including the backend name
62-
propagation := append(manila.ManilaSharePropagation, storage.PropagationType(strings.TrimPrefix(name, "manila-share-")))
69+
propagation := append(manila.ManilaSharePropagation, storage.PropagationType(propagationInstanceName))
6370
return append(manila.GetVolumeMounts(extraVol, propagation), shareVolumeMounts...)
6471
}

0 commit comments

Comments
 (0)