From af4acbf1a937767b1954cb54c5fb611e7c17f671 Mon Sep 17 00:00:00 2001 From: dandawg <12484302+dandawg@users.noreply.github.com> Date: Fri, 13 Dec 2024 12:41:19 -0700 Subject: [PATCH 1/4] added pvc accessModes support Signed-off-by: dandawg <12484302+dandawg@users.noreply.github.com> --- .../api/v1alpha1/featurestore_types.go | 2 ++ .../api/v1alpha1/zz_generated.deepcopy.go | 5 +++ .../crd/bases/feast.dev_featurestores.yaml | 36 +++++++++++++++++++ infra/feast-operator/dist/install.yaml | 36 +++++++++++++++++++ .../featurestore_controller_pvc_test.go | 8 +++++ .../internal/controller/services/services.go | 2 +- .../controller/services/services_types.go | 10 +++--- .../internal/controller/services/util.go | 9 +++++ 8 files changed, 103 insertions(+), 5 deletions(-) diff --git a/infra/feast-operator/api/v1alpha1/featurestore_types.go b/infra/feast-operator/api/v1alpha1/featurestore_types.go index 84b4d8e841..bb3a6a78f4 100644 --- a/infra/feast-operator/api/v1alpha1/featurestore_types.go +++ b/infra/feast-operator/api/v1alpha1/featurestore_types.go @@ -242,6 +242,8 @@ type PvcConfig struct { // The PVC name is the same as the associated deployment name. // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="PvcCreate is immutable" type PvcCreate struct { + // AccessModes k8s persistent volume access modes. Default []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce}. + AccessModes []corev1.PersistentVolumeAccessMode `json:"accessModes,omitempty"` // StorageClassName is the name of an existing StorageClass to which this persistent volume belongs. Empty value // means that this volume does not belong to any StorageClass and the cluster default will be used. StorageClassName *string `json:"storageClassName,omitempty"` diff --git a/infra/feast-operator/api/v1alpha1/zz_generated.deepcopy.go b/infra/feast-operator/api/v1alpha1/zz_generated.deepcopy.go index 6cba8e5923..3241dff775 100644 --- a/infra/feast-operator/api/v1alpha1/zz_generated.deepcopy.go +++ b/infra/feast-operator/api/v1alpha1/zz_generated.deepcopy.go @@ -524,6 +524,11 @@ func (in *PvcConfig) DeepCopy() *PvcConfig { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PvcCreate) DeepCopyInto(out *PvcCreate) { *out = *in + if in.AccessModes != nil { + in, out := &in.AccessModes, &out.AccessModes + *out = make([]v1.PersistentVolumeAccessMode, len(*in)) + copy(*out, *in) + } if in.StorageClassName != nil { in, out := &in.StorageClassName, &out.StorageClassName *out = new(string) diff --git a/infra/feast-operator/config/crd/bases/feast.dev_featurestores.yaml b/infra/feast-operator/config/crd/bases/feast.dev_featurestores.yaml index 7fbd38ed31..a9ddeddfeb 100644 --- a/infra/feast-operator/config/crd/bases/feast.dev_featurestores.yaml +++ b/infra/feast-operator/config/crd/bases/feast.dev_featurestores.yaml @@ -254,6 +254,12 @@ spec: create: description: Settings for creating a new PVC properties: + accessModes: + description: AccessModes k8s persistent volume + access modes. Default []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce}. + items: + type: string + type: array resources: description: |- Resources describes the storage resource requirements for a volume. @@ -622,6 +628,12 @@ spec: create: description: Settings for creating a new PVC properties: + accessModes: + description: AccessModes k8s persistent volume + access modes. Default []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce}. + items: + type: string + type: array resources: description: |- Resources describes the storage resource requirements for a volume. @@ -1006,6 +1018,12 @@ spec: create: description: Settings for creating a new PVC properties: + accessModes: + description: AccessModes k8s persistent + volume access modes. Default []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce}. + items: + type: string + type: array resources: description: |- Resources describes the storage resource requirements for a volume. @@ -1506,6 +1524,12 @@ spec: create: description: Settings for creating a new PVC properties: + accessModes: + description: AccessModes k8s persistent + volume access modes. Default []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce}. + items: + type: string + type: array resources: description: |- Resources describes the storage resource requirements for a volume. @@ -1879,6 +1903,12 @@ spec: create: description: Settings for creating a new PVC properties: + accessModes: + description: AccessModes k8s persistent + volume access modes. Default []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce}. + items: + type: string + type: array resources: description: |- Resources describes the storage resource requirements for a volume. @@ -2272,6 +2302,12 @@ spec: description: Settings for creating a new PVC properties: + accessModes: + description: AccessModes k8s persistent + volume access modes. Default []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce}. + items: + type: string + type: array resources: description: |- Resources describes the storage resource requirements for a volume. diff --git a/infra/feast-operator/dist/install.yaml b/infra/feast-operator/dist/install.yaml index 73abc3717b..19534b15d7 100644 --- a/infra/feast-operator/dist/install.yaml +++ b/infra/feast-operator/dist/install.yaml @@ -262,6 +262,12 @@ spec: create: description: Settings for creating a new PVC properties: + accessModes: + description: AccessModes k8s persistent volume + access modes. Default []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce}. + items: + type: string + type: array resources: description: |- Resources describes the storage resource requirements for a volume. @@ -630,6 +636,12 @@ spec: create: description: Settings for creating a new PVC properties: + accessModes: + description: AccessModes k8s persistent volume + access modes. Default []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce}. + items: + type: string + type: array resources: description: |- Resources describes the storage resource requirements for a volume. @@ -1014,6 +1026,12 @@ spec: create: description: Settings for creating a new PVC properties: + accessModes: + description: AccessModes k8s persistent + volume access modes. Default []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce}. + items: + type: string + type: array resources: description: |- Resources describes the storage resource requirements for a volume. @@ -1514,6 +1532,12 @@ spec: create: description: Settings for creating a new PVC properties: + accessModes: + description: AccessModes k8s persistent + volume access modes. Default []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce}. + items: + type: string + type: array resources: description: |- Resources describes the storage resource requirements for a volume. @@ -1887,6 +1911,12 @@ spec: create: description: Settings for creating a new PVC properties: + accessModes: + description: AccessModes k8s persistent + volume access modes. Default []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce}. + items: + type: string + type: array resources: description: |- Resources describes the storage resource requirements for a volume. @@ -2280,6 +2310,12 @@ spec: description: Settings for creating a new PVC properties: + accessModes: + description: AccessModes k8s persistent + volume access modes. Default []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce}. + items: + type: string + type: array resources: description: |- Resources describes the storage resource requirements for a volume. diff --git a/infra/feast-operator/internal/controller/featurestore_controller_pvc_test.go b/infra/feast-operator/internal/controller/featurestore_controller_pvc_test.go index fe0caa38e6..3a2dd5c1c0 100644 --- a/infra/feast-operator/internal/controller/featurestore_controller_pvc_test.go +++ b/infra/feast-operator/internal/controller/featurestore_controller_pvc_test.go @@ -69,6 +69,7 @@ var _ = Describe("FeatureStore Controller-Ephemeral services", func() { onlineStoreMountPath := "/online" registryMountPath := "/registry" + accessModes := []corev1.PersistentVolumeAccessMode{corev1.ReadWriteMany} storageClassName := "test" onlineStoreMountedPath := path.Join(onlineStoreMountPath, onlineStorePath) @@ -85,6 +86,7 @@ var _ = Describe("FeatureStore Controller-Ephemeral services", func() { Type: offlineType, PvcConfig: &feastdevv1alpha1.PvcConfig{ Create: &feastdevv1alpha1.PvcCreate{ + AccessModes: accessModes, StorageClassName: &storageClassName, }, MountPath: offlineStoreMountPath, @@ -162,6 +164,7 @@ var _ = Describe("FeatureStore Controller-Ephemeral services", func() { Expect(resource.Status.Applied.Services.OfflineStore.Persistence.FilePersistence.Type).To(Equal(offlineType)) Expect(resource.Status.Applied.Services.OfflineStore.Persistence.FilePersistence.PvcConfig).NotTo(BeNil()) Expect(resource.Status.Applied.Services.OfflineStore.Persistence.FilePersistence.PvcConfig.Create).NotTo(BeNil()) + Expect(resource.Status.Applied.Services.OfflineStore.Persistence.FilePersistence.PvcConfig.Create.AccessModes).To(Equal(accessModes)) Expect(resource.Status.Applied.Services.OfflineStore.Persistence.FilePersistence.PvcConfig.Create.StorageClassName).To(Equal(&storageClassName)) expectedResources := corev1.VolumeResourceRequirements{ Requests: corev1.ResourceList{ @@ -179,6 +182,7 @@ var _ = Describe("FeatureStore Controller-Ephemeral services", func() { Expect(resource.Status.Applied.Services.OnlineStore.Persistence.FilePersistence.Path).To(Equal(onlineStorePath)) Expect(resource.Status.Applied.Services.OnlineStore.Persistence.FilePersistence.PvcConfig).NotTo(BeNil()) Expect(resource.Status.Applied.Services.OnlineStore.Persistence.FilePersistence.PvcConfig.Create).NotTo(BeNil()) + Expect(resource.Status.Applied.Services.OnlineStore.Persistence.FilePersistence.PvcConfig.Create.AccessModes).To(Equal(services.DefaultPVCAccessModes)) Expect(resource.Status.Applied.Services.OnlineStore.Persistence.FilePersistence.PvcConfig.Create.StorageClassName).To(BeNil()) expectedResources = corev1.VolumeResourceRequirements{ Requests: corev1.ResourceList{ @@ -198,6 +202,7 @@ var _ = Describe("FeatureStore Controller-Ephemeral services", func() { Expect(resource.Status.Applied.Services.Registry.Local.Persistence.FilePersistence.Path).To(Equal(registryPath)) Expect(resource.Status.Applied.Services.Registry.Local.Persistence.FilePersistence.PvcConfig).NotTo(BeNil()) Expect(resource.Status.Applied.Services.Registry.Local.Persistence.FilePersistence.PvcConfig.Create).NotTo(BeNil()) + Expect(resource.Status.Applied.Services.Registry.Local.Persistence.FilePersistence.PvcConfig.Create.AccessModes).To(Equal(services.DefaultPVCAccessModes)) Expect(resource.Status.Applied.Services.Registry.Local.Persistence.FilePersistence.PvcConfig.Create.StorageClassName).To(BeNil()) expectedResources = corev1.VolumeResourceRequirements{ Requests: corev1.ResourceList{ @@ -283,6 +288,7 @@ var _ = Describe("FeatureStore Controller-Ephemeral services", func() { Expect(err).NotTo(HaveOccurred()) Expect(pvc.Name).To(Equal(deploy.Name)) Expect(pvc.Spec.StorageClassName).To(Equal(&storageClassName)) + Expect(pvc.Spec.AccessModes).To(Equal(accessModes)) Expect(pvc.Spec.Resources.Requests.Storage().String()).To(Equal(services.DefaultOfflineStorageRequest)) Expect(pvc.DeletionTimestamp).To(BeNil()) @@ -313,6 +319,7 @@ var _ = Describe("FeatureStore Controller-Ephemeral services", func() { pvc) Expect(err).NotTo(HaveOccurred()) Expect(pvc.Name).To(Equal(deploy.Name)) + Expect(pvc.Spec.AccessModes).To(Equal(services.DefaultPVCAccessModes)) Expect(pvc.Spec.Resources.Requests.Storage().String()).To(Equal(services.DefaultOnlineStorageRequest)) Expect(pvc.DeletionTimestamp).To(BeNil()) @@ -343,6 +350,7 @@ var _ = Describe("FeatureStore Controller-Ephemeral services", func() { pvc) Expect(err).NotTo(HaveOccurred()) Expect(pvc.Name).To(Equal(deploy.Name)) + Expect(pvc.Spec.AccessModes).To(Equal(services.DefaultPVCAccessModes)) Expect(pvc.Spec.Resources.Requests.Storage().String()).To(Equal(services.DefaultRegistryStorageRequest)) Expect(pvc.DeletionTimestamp).To(BeNil()) diff --git a/infra/feast-operator/internal/controller/services/services.go b/infra/feast-operator/internal/controller/services/services.go index f85597e648..232e3e5874 100644 --- a/infra/feast-operator/internal/controller/services/services.go +++ b/infra/feast-operator/internal/controller/services/services.go @@ -450,7 +450,7 @@ func (feast *FeastServices) createNewPVC(pvcCreate *feastdevv1alpha1.PvcCreate, pvc := feast.initPVC(feastType) pvc.Spec = corev1.PersistentVolumeClaimSpec{ - AccessModes: []corev1.PersistentVolumeAccessMode{corev1.ReadWriteMany}, + AccessModes: pvcCreate.AccessModes, Resources: pvcCreate.Resources, } if pvcCreate.StorageClassName != nil { diff --git a/infra/feast-operator/internal/controller/services/services_types.go b/infra/feast-operator/internal/controller/services/services_types.go index b7c0f5f048..b9e1a9d9d7 100644 --- a/infra/feast-operator/internal/controller/services/services_types.go +++ b/infra/feast-operator/internal/controller/services/services_types.go @@ -20,6 +20,7 @@ import ( "github.com/feast-dev/feast/infra/feast-operator/api/feastversion" feastdevv1alpha1 "github.com/feast-dev/feast/infra/feast-operator/api/v1alpha1" handler "github.com/feast-dev/feast/infra/feast-operator/internal/controller/handler" + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -80,10 +81,11 @@ const ( ) var ( - DefaultImage = "feastdev/feature-server:" + feastversion.FeastVersion - DefaultReplicas = int32(1) - NameLabelKey = feastdevv1alpha1.GroupVersion.Group + "/name" - ServiceTypeLabelKey = feastdevv1alpha1.GroupVersion.Group + "/service-type" + DefaultImage = "feastdev/feature-server:" + feastversion.FeastVersion + DefaultReplicas = int32(1) + DefaultPVCAccessModes = []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce} + NameLabelKey = feastdevv1alpha1.GroupVersion.Group + "/name" + ServiceTypeLabelKey = feastdevv1alpha1.GroupVersion.Group + "/service-type" FeastServiceConstants = map[FeastServiceType]deploymentSettings{ OfflineFeastType: { diff --git a/infra/feast-operator/internal/controller/services/util.go b/infra/feast-operator/internal/controller/services/util.go index 631709d6ba..ae62d42324 100644 --- a/infra/feast-operator/internal/controller/services/util.go +++ b/infra/feast-operator/internal/controller/services/util.go @@ -94,6 +94,9 @@ func ApplyDefaultsToStatus(cr *feastdevv1alpha1.FeatureStore) { pvc := services.Registry.Local.Persistence.FilePersistence.PvcConfig if pvc.Create != nil { ensureRequestedStorage(&pvc.Create.Resources, DefaultRegistryStorageRequest) + if pvc.Create.AccessModes == nil { + pvc.Create.AccessModes = DefaultPVCAccessModes + } } } } @@ -118,6 +121,9 @@ func ApplyDefaultsToStatus(cr *feastdevv1alpha1.FeatureStore) { pvc := services.OfflineStore.Persistence.FilePersistence.PvcConfig if pvc.Create != nil { ensureRequestedStorage(&pvc.Create.Resources, DefaultOfflineStorageRequest) + if pvc.Create.AccessModes == nil { + pvc.Create.AccessModes = DefaultPVCAccessModes + } } } } @@ -143,6 +149,9 @@ func ApplyDefaultsToStatus(cr *feastdevv1alpha1.FeatureStore) { pvc := services.OnlineStore.Persistence.FilePersistence.PvcConfig if pvc.Create != nil { ensureRequestedStorage(&pvc.Create.Resources, DefaultOnlineStorageRequest) + if pvc.Create.AccessModes == nil { + pvc.Create.AccessModes = DefaultPVCAccessModes + } } } } From f23bd04e99734038b5b05ebbf563119960305714 Mon Sep 17 00:00:00 2001 From: dandawg <12484302+dandawg@users.noreply.github.com> Date: Mon, 16 Dec 2024 10:21:21 -0700 Subject: [PATCH 2/4] made accessModes doc line more clear for users Signed-off-by: dandawg <12484302+dandawg@users.noreply.github.com> --- infra/feast-operator/api/v1alpha1/featurestore_types.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infra/feast-operator/api/v1alpha1/featurestore_types.go b/infra/feast-operator/api/v1alpha1/featurestore_types.go index bb3a6a78f4..2eb9ec8554 100644 --- a/infra/feast-operator/api/v1alpha1/featurestore_types.go +++ b/infra/feast-operator/api/v1alpha1/featurestore_types.go @@ -242,7 +242,7 @@ type PvcConfig struct { // The PVC name is the same as the associated deployment name. // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="PvcCreate is immutable" type PvcCreate struct { - // AccessModes k8s persistent volume access modes. Default []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce}. + // AccessModes k8s persistent volume access modes. Defaults to ["ReadWriteOnce"]. AccessModes []corev1.PersistentVolumeAccessMode `json:"accessModes,omitempty"` // StorageClassName is the name of an existing StorageClass to which this persistent volume belongs. Empty value // means that this volume does not belong to any StorageClass and the cluster default will be used. From 6a5807e07d3b86ef69038e3f5310ec48db461640 Mon Sep 17 00:00:00 2001 From: dandawg <12484302+dandawg@users.noreply.github.com> Date: Mon, 16 Dec 2024 10:23:56 -0700 Subject: [PATCH 3/4] Added multiple accessModes to PVC accessModes test Signed-off-by: dandawg <12484302+dandawg@users.noreply.github.com> --- .../config/crd/bases/feast.dev_featurestores.yaml | 13 +++++++------ infra/feast-operator/dist/install.yaml | 13 +++++++------ .../controller/featurestore_controller_pvc_test.go | 2 +- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/infra/feast-operator/config/crd/bases/feast.dev_featurestores.yaml b/infra/feast-operator/config/crd/bases/feast.dev_featurestores.yaml index a9ddeddfeb..fd8861cef1 100644 --- a/infra/feast-operator/config/crd/bases/feast.dev_featurestores.yaml +++ b/infra/feast-operator/config/crd/bases/feast.dev_featurestores.yaml @@ -256,7 +256,7 @@ spec: properties: accessModes: description: AccessModes k8s persistent volume - access modes. Default []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce}. + access modes. Defaults to ["ReadWriteOnce"]. items: type: string type: array @@ -630,7 +630,7 @@ spec: properties: accessModes: description: AccessModes k8s persistent volume - access modes. Default []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce}. + access modes. Defaults to ["ReadWriteOnce"]. items: type: string type: array @@ -1020,7 +1020,7 @@ spec: properties: accessModes: description: AccessModes k8s persistent - volume access modes. Default []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce}. + volume access modes. Defaults to ["ReadWriteOnce"]. items: type: string type: array @@ -1526,7 +1526,7 @@ spec: properties: accessModes: description: AccessModes k8s persistent - volume access modes. Default []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce}. + volume access modes. Defaults to ["ReadWriteOnce"]. items: type: string type: array @@ -1905,7 +1905,7 @@ spec: properties: accessModes: description: AccessModes k8s persistent - volume access modes. Default []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce}. + volume access modes. Defaults to ["ReadWriteOnce"]. items: type: string type: array @@ -2304,7 +2304,8 @@ spec: properties: accessModes: description: AccessModes k8s persistent - volume access modes. Default []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce}. + volume access modes. Defaults to + ["ReadWriteOnce"]. items: type: string type: array diff --git a/infra/feast-operator/dist/install.yaml b/infra/feast-operator/dist/install.yaml index 19534b15d7..435be789e5 100644 --- a/infra/feast-operator/dist/install.yaml +++ b/infra/feast-operator/dist/install.yaml @@ -264,7 +264,7 @@ spec: properties: accessModes: description: AccessModes k8s persistent volume - access modes. Default []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce}. + access modes. Defaults to ["ReadWriteOnce"]. items: type: string type: array @@ -638,7 +638,7 @@ spec: properties: accessModes: description: AccessModes k8s persistent volume - access modes. Default []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce}. + access modes. Defaults to ["ReadWriteOnce"]. items: type: string type: array @@ -1028,7 +1028,7 @@ spec: properties: accessModes: description: AccessModes k8s persistent - volume access modes. Default []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce}. + volume access modes. Defaults to ["ReadWriteOnce"]. items: type: string type: array @@ -1534,7 +1534,7 @@ spec: properties: accessModes: description: AccessModes k8s persistent - volume access modes. Default []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce}. + volume access modes. Defaults to ["ReadWriteOnce"]. items: type: string type: array @@ -1913,7 +1913,7 @@ spec: properties: accessModes: description: AccessModes k8s persistent - volume access modes. Default []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce}. + volume access modes. Defaults to ["ReadWriteOnce"]. items: type: string type: array @@ -2312,7 +2312,8 @@ spec: properties: accessModes: description: AccessModes k8s persistent - volume access modes. Default []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce}. + volume access modes. Defaults to + ["ReadWriteOnce"]. items: type: string type: array diff --git a/infra/feast-operator/internal/controller/featurestore_controller_pvc_test.go b/infra/feast-operator/internal/controller/featurestore_controller_pvc_test.go index 3a2dd5c1c0..e64e5cd624 100644 --- a/infra/feast-operator/internal/controller/featurestore_controller_pvc_test.go +++ b/infra/feast-operator/internal/controller/featurestore_controller_pvc_test.go @@ -69,7 +69,7 @@ var _ = Describe("FeatureStore Controller-Ephemeral services", func() { onlineStoreMountPath := "/online" registryMountPath := "/registry" - accessModes := []corev1.PersistentVolumeAccessMode{corev1.ReadWriteMany} + accessModes := []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce, corev1.ReadWriteMany} storageClassName := "test" onlineStoreMountedPath := path.Join(onlineStoreMountPath, onlineStorePath) From f02f7974cd12f3d9c3e9ba327724a3005016bccf Mon Sep 17 00:00:00 2001 From: dandawg <12484302+dandawg@users.noreply.github.com> Date: Thu, 19 Dec 2024 16:10:58 -0700 Subject: [PATCH 4/4] function for pvc.Create Signed-off-by: dandawg <12484302+dandawg@users.noreply.github.com> --- .../internal/controller/services/util.go | 39 ++++++++++--------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/infra/feast-operator/internal/controller/services/util.go b/infra/feast-operator/internal/controller/services/util.go index ae62d42324..92ee2b5752 100644 --- a/infra/feast-operator/internal/controller/services/util.go +++ b/infra/feast-operator/internal/controller/services/util.go @@ -92,12 +92,7 @@ func ApplyDefaultsToStatus(cr *feastdevv1alpha1.FeatureStore) { if services.Registry.Local.Persistence.FilePersistence.PvcConfig != nil { pvc := services.Registry.Local.Persistence.FilePersistence.PvcConfig - if pvc.Create != nil { - ensureRequestedStorage(&pvc.Create.Resources, DefaultRegistryStorageRequest) - if pvc.Create.AccessModes == nil { - pvc.Create.AccessModes = DefaultPVCAccessModes - } - } + ensurePVCDefaults(pvc, RegistryFeastType) } } @@ -119,12 +114,7 @@ func ApplyDefaultsToStatus(cr *feastdevv1alpha1.FeatureStore) { if services.OfflineStore.Persistence.FilePersistence.PvcConfig != nil { pvc := services.OfflineStore.Persistence.FilePersistence.PvcConfig - if pvc.Create != nil { - ensureRequestedStorage(&pvc.Create.Resources, DefaultOfflineStorageRequest) - if pvc.Create.AccessModes == nil { - pvc.Create.AccessModes = DefaultPVCAccessModes - } - } + ensurePVCDefaults(pvc, OfflineFeastType) } } @@ -147,12 +137,7 @@ func ApplyDefaultsToStatus(cr *feastdevv1alpha1.FeatureStore) { if services.OnlineStore.Persistence.FilePersistence.PvcConfig != nil { pvc := services.OnlineStore.Persistence.FilePersistence.PvcConfig - if pvc.Create != nil { - ensureRequestedStorage(&pvc.Create.Resources, DefaultOnlineStorageRequest) - if pvc.Create.AccessModes == nil { - pvc.Create.AccessModes = DefaultPVCAccessModes - } - } + ensurePVCDefaults(pvc, OnlineFeastType) } } @@ -191,6 +176,24 @@ func ensureRequestedStorage(resources *v1.VolumeResourceRequirements, requestedS } } +func ensurePVCDefaults(pvc *feastdevv1alpha1.PvcConfig, feastType FeastServiceType) { + var storageRequest string + switch feastType { + case OnlineFeastType: + storageRequest = DefaultOnlineStorageRequest + case OfflineFeastType: + storageRequest = DefaultOfflineStorageRequest + case RegistryFeastType: + storageRequest = DefaultRegistryStorageRequest + } + if pvc.Create != nil { + ensureRequestedStorage(&pvc.Create.Resources, storageRequest) + if pvc.Create.AccessModes == nil { + pvc.Create.AccessModes = DefaultPVCAccessModes + } + } +} + func defaultOnlineStorePath(persistence *feastdevv1alpha1.OnlineStoreFilePersistence) string { if persistence.PvcConfig == nil { return DefaultOnlineStoreEphemeralPath