Skip to content

Commit

Permalink
function for pvc.Create
Browse files Browse the repository at this point in the history
Signed-off-by: dandawg <[email protected]>
  • Loading branch information
dandawg committed Dec 19, 2024
1 parent 6a5807e commit f02f797
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions infra/feast-operator/internal/controller/services/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand All @@ -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)
}
}

Expand All @@ -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)
}
}

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f02f797

Please sign in to comment.