@@ -37,15 +37,18 @@ func hasPvcConfig(featureStore *feastdevv1alpha1.FeatureStore, feastType FeastSe
3737 if services != nil {
3838 switch feastType {
3939 case OnlineFeastType :
40- if services .OnlineStore != nil && services .OnlineStore .Persistence .FilePersistence != nil {
40+ if services .OnlineStore != nil && services .OnlineStore .Persistence != nil &&
41+ services .OnlineStore .Persistence .FilePersistence != nil {
4142 pvcConfig = services .OnlineStore .Persistence .FilePersistence .PvcConfig
4243 }
4344 case OfflineFeastType :
44- if services .OfflineStore != nil && services .OfflineStore .Persistence .FilePersistence != nil {
45+ if services .OfflineStore != nil && services .OfflineStore .Persistence != nil &&
46+ services .OfflineStore .Persistence .FilePersistence != nil {
4547 pvcConfig = services .OfflineStore .Persistence .FilePersistence .PvcConfig
4648 }
4749 case RegistryFeastType :
48- if IsLocalRegistry (featureStore ) && services .Registry .Local .Persistence .FilePersistence != nil {
50+ if IsLocalRegistry (featureStore ) && services .Registry .Local .Persistence != nil &&
51+ services .Registry .Local .Persistence .FilePersistence != nil {
4952 pvcConfig = services .Registry .Local .Persistence .FilePersistence .PvcConfig
5053 }
5154 }
@@ -66,18 +69,18 @@ func shouldMountEmptyDir(featureStore *feastdevv1alpha1.FeatureStore) bool {
6669}
6770
6871func getOfflineMountPath (featureStore * feastdevv1alpha1.FeatureStore ) string {
69- if featureStore .Status .Applied .Services != nil {
70- if pvcConfig , ok := hasPvcConfig (featureStore , OfflineFeastType ); ok {
71- return pvcConfig .MountPath
72- }
72+ if pvcConfig , ok := hasPvcConfig (featureStore , OfflineFeastType ); ok {
73+ return pvcConfig .MountPath
7374 }
7475 return EphemeralPath
7576}
7677
7778func ApplyDefaultsToStatus (cr * feastdevv1alpha1.FeatureStore ) {
79+ // overwrite status.applied with every reconcile
80+ cr .Spec .DeepCopyInto (& cr .Status .Applied )
7881 cr .Status .FeastVersion = feastversion .FeastVersion
79- applied := cr .Spec .DeepCopy ()
8082
83+ applied := & cr .Status .Applied
8184 if applied .Services == nil {
8285 applied .Services = & feastdevv1alpha1.FeatureStoreServices {}
8386 }
@@ -106,10 +109,7 @@ func ApplyDefaultsToStatus(cr *feastdevv1alpha1.FeatureStore) {
106109 services .Registry .Local .Persistence .FilePersistence .Path = defaultRegistryPath (cr )
107110 }
108111
109- if services .Registry .Local .Persistence .FilePersistence .PvcConfig != nil {
110- pvc := services .Registry .Local .Persistence .FilePersistence .PvcConfig
111- ensurePVCDefaults (pvc , RegistryFeastType )
112- }
112+ ensurePVCDefaults (services .Registry .Local .Persistence .FilePersistence .PvcConfig , RegistryFeastType )
113113 }
114114
115115 setServiceDefaultConfigs (& services .Registry .Local .ServiceConfigs .DefaultConfigs )
@@ -131,10 +131,7 @@ func ApplyDefaultsToStatus(cr *feastdevv1alpha1.FeatureStore) {
131131 services .OfflineStore .Persistence .FilePersistence .Type = string (OfflineFilePersistenceDaskConfigType )
132132 }
133133
134- if services .OfflineStore .Persistence .FilePersistence .PvcConfig != nil {
135- pvc := services .OfflineStore .Persistence .FilePersistence .PvcConfig
136- ensurePVCDefaults (pvc , OfflineFeastType )
137- }
134+ ensurePVCDefaults (services .OfflineStore .Persistence .FilePersistence .PvcConfig , OfflineFeastType )
138135 }
139136
140137 setServiceDefaultConfigs (& services .OfflineStore .ServiceConfigs .DefaultConfigs )
@@ -154,16 +151,11 @@ func ApplyDefaultsToStatus(cr *feastdevv1alpha1.FeatureStore) {
154151 services .OnlineStore .Persistence .FilePersistence .Path = defaultOnlineStorePath (cr )
155152 }
156153
157- if services .OnlineStore .Persistence .FilePersistence .PvcConfig != nil {
158- pvc := services .OnlineStore .Persistence .FilePersistence .PvcConfig
159- ensurePVCDefaults (pvc , OnlineFeastType )
160- }
154+ ensurePVCDefaults (services .OnlineStore .Persistence .FilePersistence .PvcConfig , OnlineFeastType )
161155 }
162156
163157 setServiceDefaultConfigs (& services .OnlineStore .ServiceConfigs .DefaultConfigs )
164158 }
165- // overwrite status.applied with every reconcile
166- applied .DeepCopyInto (& cr .Status .Applied )
167159}
168160
169161func setServiceDefaultConfigs (defaultConfigs * feastdevv1alpha1.DefaultConfigs ) {
@@ -189,19 +181,21 @@ func ensureRequestedStorage(resources *v1.VolumeResourceRequirements, requestedS
189181}
190182
191183func ensurePVCDefaults (pvc * feastdevv1alpha1.PvcConfig , feastType FeastServiceType ) {
192- var storageRequest string
193- switch feastType {
194- case OnlineFeastType :
195- storageRequest = DefaultOnlineStorageRequest
196- case OfflineFeastType :
197- storageRequest = DefaultOfflineStorageRequest
198- case RegistryFeastType :
199- storageRequest = DefaultRegistryStorageRequest
200- }
201- if pvc .Create != nil {
202- ensureRequestedStorage (& pvc .Create .Resources , storageRequest )
203- if pvc .Create .AccessModes == nil {
204- pvc .Create .AccessModes = DefaultPVCAccessModes
184+ if pvc != nil {
185+ var storageRequest string
186+ switch feastType {
187+ case OnlineFeastType :
188+ storageRequest = DefaultOnlineStorageRequest
189+ case OfflineFeastType :
190+ storageRequest = DefaultOfflineStorageRequest
191+ case RegistryFeastType :
192+ storageRequest = DefaultRegistryStorageRequest
193+ }
194+ if pvc .Create != nil {
195+ ensureRequestedStorage (& pvc .Create .Resources , storageRequest )
196+ if pvc .Create .AccessModes == nil {
197+ pvc .Create .AccessModes = DefaultPVCAccessModes
198+ }
205199 }
206200 }
207201}
0 commit comments