Skip to content

Commit a73514c

Browse files
authored
feat: Added pvc accessModes support (feast-dev#4851)
* added pvc accessModes support Signed-off-by: dandawg <12484302+dandawg@users.noreply.github.com> * made accessModes doc line more clear for users Signed-off-by: dandawg <12484302+dandawg@users.noreply.github.com> * Added multiple accessModes to PVC accessModes test Signed-off-by: dandawg <12484302+dandawg@users.noreply.github.com> * function for pvc.Create Signed-off-by: dandawg <12484302+dandawg@users.noreply.github.com> --------- Signed-off-by: dandawg <12484302+dandawg@users.noreply.github.com>
1 parent ae2a521 commit a73514c

File tree

8 files changed

+117
-14
lines changed

8 files changed

+117
-14
lines changed

infra/feast-operator/api/v1alpha1/featurestore_types.go

+2
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,8 @@ type PvcConfig struct {
242242
// The PVC name is the same as the associated deployment name.
243243
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="PvcCreate is immutable"
244244
type PvcCreate struct {
245+
// AccessModes k8s persistent volume access modes. Defaults to ["ReadWriteOnce"].
246+
AccessModes []corev1.PersistentVolumeAccessMode `json:"accessModes,omitempty"`
245247
// StorageClassName is the name of an existing StorageClass to which this persistent volume belongs. Empty value
246248
// means that this volume does not belong to any StorageClass and the cluster default will be used.
247249
StorageClassName *string `json:"storageClassName,omitempty"`

infra/feast-operator/api/v1alpha1/zz_generated.deepcopy.go

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

infra/feast-operator/config/crd/bases/feast.dev_featurestores.yaml

+37
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,12 @@ spec:
254254
create:
255255
description: Settings for creating a new PVC
256256
properties:
257+
accessModes:
258+
description: AccessModes k8s persistent volume
259+
access modes. Defaults to ["ReadWriteOnce"].
260+
items:
261+
type: string
262+
type: array
257263
resources:
258264
description: |-
259265
Resources describes the storage resource requirements for a volume.
@@ -622,6 +628,12 @@ spec:
622628
create:
623629
description: Settings for creating a new PVC
624630
properties:
631+
accessModes:
632+
description: AccessModes k8s persistent volume
633+
access modes. Defaults to ["ReadWriteOnce"].
634+
items:
635+
type: string
636+
type: array
625637
resources:
626638
description: |-
627639
Resources describes the storage resource requirements for a volume.
@@ -1006,6 +1018,12 @@ spec:
10061018
create:
10071019
description: Settings for creating a new PVC
10081020
properties:
1021+
accessModes:
1022+
description: AccessModes k8s persistent
1023+
volume access modes. Defaults to ["ReadWriteOnce"].
1024+
items:
1025+
type: string
1026+
type: array
10091027
resources:
10101028
description: |-
10111029
Resources describes the storage resource requirements for a volume.
@@ -1506,6 +1524,12 @@ spec:
15061524
create:
15071525
description: Settings for creating a new PVC
15081526
properties:
1527+
accessModes:
1528+
description: AccessModes k8s persistent
1529+
volume access modes. Defaults to ["ReadWriteOnce"].
1530+
items:
1531+
type: string
1532+
type: array
15091533
resources:
15101534
description: |-
15111535
Resources describes the storage resource requirements for a volume.
@@ -1879,6 +1903,12 @@ spec:
18791903
create:
18801904
description: Settings for creating a new PVC
18811905
properties:
1906+
accessModes:
1907+
description: AccessModes k8s persistent
1908+
volume access modes. Defaults to ["ReadWriteOnce"].
1909+
items:
1910+
type: string
1911+
type: array
18821912
resources:
18831913
description: |-
18841914
Resources describes the storage resource requirements for a volume.
@@ -2272,6 +2302,13 @@ spec:
22722302
description: Settings for creating a new
22732303
PVC
22742304
properties:
2305+
accessModes:
2306+
description: AccessModes k8s persistent
2307+
volume access modes. Defaults to
2308+
["ReadWriteOnce"].
2309+
items:
2310+
type: string
2311+
type: array
22752312
resources:
22762313
description: |-
22772314
Resources describes the storage resource requirements for a volume.

infra/feast-operator/dist/install.yaml

+37
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,12 @@ spec:
262262
create:
263263
description: Settings for creating a new PVC
264264
properties:
265+
accessModes:
266+
description: AccessModes k8s persistent volume
267+
access modes. Defaults to ["ReadWriteOnce"].
268+
items:
269+
type: string
270+
type: array
265271
resources:
266272
description: |-
267273
Resources describes the storage resource requirements for a volume.
@@ -630,6 +636,12 @@ spec:
630636
create:
631637
description: Settings for creating a new PVC
632638
properties:
639+
accessModes:
640+
description: AccessModes k8s persistent volume
641+
access modes. Defaults to ["ReadWriteOnce"].
642+
items:
643+
type: string
644+
type: array
633645
resources:
634646
description: |-
635647
Resources describes the storage resource requirements for a volume.
@@ -1014,6 +1026,12 @@ spec:
10141026
create:
10151027
description: Settings for creating a new PVC
10161028
properties:
1029+
accessModes:
1030+
description: AccessModes k8s persistent
1031+
volume access modes. Defaults to ["ReadWriteOnce"].
1032+
items:
1033+
type: string
1034+
type: array
10171035
resources:
10181036
description: |-
10191037
Resources describes the storage resource requirements for a volume.
@@ -1514,6 +1532,12 @@ spec:
15141532
create:
15151533
description: Settings for creating a new PVC
15161534
properties:
1535+
accessModes:
1536+
description: AccessModes k8s persistent
1537+
volume access modes. Defaults to ["ReadWriteOnce"].
1538+
items:
1539+
type: string
1540+
type: array
15171541
resources:
15181542
description: |-
15191543
Resources describes the storage resource requirements for a volume.
@@ -1887,6 +1911,12 @@ spec:
18871911
create:
18881912
description: Settings for creating a new PVC
18891913
properties:
1914+
accessModes:
1915+
description: AccessModes k8s persistent
1916+
volume access modes. Defaults to ["ReadWriteOnce"].
1917+
items:
1918+
type: string
1919+
type: array
18901920
resources:
18911921
description: |-
18921922
Resources describes the storage resource requirements for a volume.
@@ -2280,6 +2310,13 @@ spec:
22802310
description: Settings for creating a new
22812311
PVC
22822312
properties:
2313+
accessModes:
2314+
description: AccessModes k8s persistent
2315+
volume access modes. Defaults to
2316+
["ReadWriteOnce"].
2317+
items:
2318+
type: string
2319+
type: array
22832320
resources:
22842321
description: |-
22852322
Resources describes the storage resource requirements for a volume.

infra/feast-operator/internal/controller/featurestore_controller_pvc_test.go

+8
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ var _ = Describe("FeatureStore Controller-Ephemeral services", func() {
6969
onlineStoreMountPath := "/online"
7070
registryMountPath := "/registry"
7171

72+
accessModes := []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce, corev1.ReadWriteMany}
7273
storageClassName := "test"
7374

7475
onlineStoreMountedPath := path.Join(onlineStoreMountPath, onlineStorePath)
@@ -85,6 +86,7 @@ var _ = Describe("FeatureStore Controller-Ephemeral services", func() {
8586
Type: offlineType,
8687
PvcConfig: &feastdevv1alpha1.PvcConfig{
8788
Create: &feastdevv1alpha1.PvcCreate{
89+
AccessModes: accessModes,
8890
StorageClassName: &storageClassName,
8991
},
9092
MountPath: offlineStoreMountPath,
@@ -162,6 +164,7 @@ var _ = Describe("FeatureStore Controller-Ephemeral services", func() {
162164
Expect(resource.Status.Applied.Services.OfflineStore.Persistence.FilePersistence.Type).To(Equal(offlineType))
163165
Expect(resource.Status.Applied.Services.OfflineStore.Persistence.FilePersistence.PvcConfig).NotTo(BeNil())
164166
Expect(resource.Status.Applied.Services.OfflineStore.Persistence.FilePersistence.PvcConfig.Create).NotTo(BeNil())
167+
Expect(resource.Status.Applied.Services.OfflineStore.Persistence.FilePersistence.PvcConfig.Create.AccessModes).To(Equal(accessModes))
165168
Expect(resource.Status.Applied.Services.OfflineStore.Persistence.FilePersistence.PvcConfig.Create.StorageClassName).To(Equal(&storageClassName))
166169
expectedResources := corev1.VolumeResourceRequirements{
167170
Requests: corev1.ResourceList{
@@ -179,6 +182,7 @@ var _ = Describe("FeatureStore Controller-Ephemeral services", func() {
179182
Expect(resource.Status.Applied.Services.OnlineStore.Persistence.FilePersistence.Path).To(Equal(onlineStorePath))
180183
Expect(resource.Status.Applied.Services.OnlineStore.Persistence.FilePersistence.PvcConfig).NotTo(BeNil())
181184
Expect(resource.Status.Applied.Services.OnlineStore.Persistence.FilePersistence.PvcConfig.Create).NotTo(BeNil())
185+
Expect(resource.Status.Applied.Services.OnlineStore.Persistence.FilePersistence.PvcConfig.Create.AccessModes).To(Equal(services.DefaultPVCAccessModes))
182186
Expect(resource.Status.Applied.Services.OnlineStore.Persistence.FilePersistence.PvcConfig.Create.StorageClassName).To(BeNil())
183187
expectedResources = corev1.VolumeResourceRequirements{
184188
Requests: corev1.ResourceList{
@@ -198,6 +202,7 @@ var _ = Describe("FeatureStore Controller-Ephemeral services", func() {
198202
Expect(resource.Status.Applied.Services.Registry.Local.Persistence.FilePersistence.Path).To(Equal(registryPath))
199203
Expect(resource.Status.Applied.Services.Registry.Local.Persistence.FilePersistence.PvcConfig).NotTo(BeNil())
200204
Expect(resource.Status.Applied.Services.Registry.Local.Persistence.FilePersistence.PvcConfig.Create).NotTo(BeNil())
205+
Expect(resource.Status.Applied.Services.Registry.Local.Persistence.FilePersistence.PvcConfig.Create.AccessModes).To(Equal(services.DefaultPVCAccessModes))
201206
Expect(resource.Status.Applied.Services.Registry.Local.Persistence.FilePersistence.PvcConfig.Create.StorageClassName).To(BeNil())
202207
expectedResources = corev1.VolumeResourceRequirements{
203208
Requests: corev1.ResourceList{
@@ -283,6 +288,7 @@ var _ = Describe("FeatureStore Controller-Ephemeral services", func() {
283288
Expect(err).NotTo(HaveOccurred())
284289
Expect(pvc.Name).To(Equal(deploy.Name))
285290
Expect(pvc.Spec.StorageClassName).To(Equal(&storageClassName))
291+
Expect(pvc.Spec.AccessModes).To(Equal(accessModes))
286292
Expect(pvc.Spec.Resources.Requests.Storage().String()).To(Equal(services.DefaultOfflineStorageRequest))
287293
Expect(pvc.DeletionTimestamp).To(BeNil())
288294

@@ -313,6 +319,7 @@ var _ = Describe("FeatureStore Controller-Ephemeral services", func() {
313319
pvc)
314320
Expect(err).NotTo(HaveOccurred())
315321
Expect(pvc.Name).To(Equal(deploy.Name))
322+
Expect(pvc.Spec.AccessModes).To(Equal(services.DefaultPVCAccessModes))
316323
Expect(pvc.Spec.Resources.Requests.Storage().String()).To(Equal(services.DefaultOnlineStorageRequest))
317324
Expect(pvc.DeletionTimestamp).To(BeNil())
318325

@@ -343,6 +350,7 @@ var _ = Describe("FeatureStore Controller-Ephemeral services", func() {
343350
pvc)
344351
Expect(err).NotTo(HaveOccurred())
345352
Expect(pvc.Name).To(Equal(deploy.Name))
353+
Expect(pvc.Spec.AccessModes).To(Equal(services.DefaultPVCAccessModes))
346354
Expect(pvc.Spec.Resources.Requests.Storage().String()).To(Equal(services.DefaultRegistryStorageRequest))
347355
Expect(pvc.DeletionTimestamp).To(BeNil())
348356

infra/feast-operator/internal/controller/services/services.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ func (feast *FeastServices) createNewPVC(pvcCreate *feastdevv1alpha1.PvcCreate,
450450
pvc := feast.initPVC(feastType)
451451

452452
pvc.Spec = corev1.PersistentVolumeClaimSpec{
453-
AccessModes: []corev1.PersistentVolumeAccessMode{corev1.ReadWriteMany},
453+
AccessModes: pvcCreate.AccessModes,
454454
Resources: pvcCreate.Resources,
455455
}
456456
if pvcCreate.StorageClassName != nil {

infra/feast-operator/internal/controller/services/services_types.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"github.com/feast-dev/feast/infra/feast-operator/api/feastversion"
2121
feastdevv1alpha1 "github.com/feast-dev/feast/infra/feast-operator/api/v1alpha1"
2222
handler "github.com/feast-dev/feast/infra/feast-operator/internal/controller/handler"
23+
corev1 "k8s.io/api/core/v1"
2324
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2425
)
2526

@@ -80,10 +81,11 @@ const (
8081
)
8182

8283
var (
83-
DefaultImage = "feastdev/feature-server:" + feastversion.FeastVersion
84-
DefaultReplicas = int32(1)
85-
NameLabelKey = feastdevv1alpha1.GroupVersion.Group + "/name"
86-
ServiceTypeLabelKey = feastdevv1alpha1.GroupVersion.Group + "/service-type"
84+
DefaultImage = "feastdev/feature-server:" + feastversion.FeastVersion
85+
DefaultReplicas = int32(1)
86+
DefaultPVCAccessModes = []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce}
87+
NameLabelKey = feastdevv1alpha1.GroupVersion.Group + "/name"
88+
ServiceTypeLabelKey = feastdevv1alpha1.GroupVersion.Group + "/service-type"
8789

8890
FeastServiceConstants = map[FeastServiceType]deploymentSettings{
8991
OfflineFeastType: {

infra/feast-operator/internal/controller/services/util.go

+21-9
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,7 @@ func ApplyDefaultsToStatus(cr *feastdevv1alpha1.FeatureStore) {
9292

9393
if services.Registry.Local.Persistence.FilePersistence.PvcConfig != nil {
9494
pvc := services.Registry.Local.Persistence.FilePersistence.PvcConfig
95-
if pvc.Create != nil {
96-
ensureRequestedStorage(&pvc.Create.Resources, DefaultRegistryStorageRequest)
97-
}
95+
ensurePVCDefaults(pvc, RegistryFeastType)
9896
}
9997
}
10098

@@ -116,9 +114,7 @@ func ApplyDefaultsToStatus(cr *feastdevv1alpha1.FeatureStore) {
116114

117115
if services.OfflineStore.Persistence.FilePersistence.PvcConfig != nil {
118116
pvc := services.OfflineStore.Persistence.FilePersistence.PvcConfig
119-
if pvc.Create != nil {
120-
ensureRequestedStorage(&pvc.Create.Resources, DefaultOfflineStorageRequest)
121-
}
117+
ensurePVCDefaults(pvc, OfflineFeastType)
122118
}
123119
}
124120

@@ -141,9 +137,7 @@ func ApplyDefaultsToStatus(cr *feastdevv1alpha1.FeatureStore) {
141137

142138
if services.OnlineStore.Persistence.FilePersistence.PvcConfig != nil {
143139
pvc := services.OnlineStore.Persistence.FilePersistence.PvcConfig
144-
if pvc.Create != nil {
145-
ensureRequestedStorage(&pvc.Create.Resources, DefaultOnlineStorageRequest)
146-
}
140+
ensurePVCDefaults(pvc, OnlineFeastType)
147141
}
148142
}
149143

@@ -182,6 +176,24 @@ func ensureRequestedStorage(resources *v1.VolumeResourceRequirements, requestedS
182176
}
183177
}
184178

179+
func ensurePVCDefaults(pvc *feastdevv1alpha1.PvcConfig, feastType FeastServiceType) {
180+
var storageRequest string
181+
switch feastType {
182+
case OnlineFeastType:
183+
storageRequest = DefaultOnlineStorageRequest
184+
case OfflineFeastType:
185+
storageRequest = DefaultOfflineStorageRequest
186+
case RegistryFeastType:
187+
storageRequest = DefaultRegistryStorageRequest
188+
}
189+
if pvc.Create != nil {
190+
ensureRequestedStorage(&pvc.Create.Resources, storageRequest)
191+
if pvc.Create.AccessModes == nil {
192+
pvc.Create.AccessModes = DefaultPVCAccessModes
193+
}
194+
}
195+
}
196+
185197
func defaultOnlineStorePath(persistence *feastdevv1alpha1.OnlineStoreFilePersistence) string {
186198
if persistence.PvcConfig == nil {
187199
return DefaultOnlineStoreEphemeralPath

0 commit comments

Comments
 (0)