-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat: File persistence definition and implementation #4742
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
d64da1a
08b1011
9b07506
db3c5c5
74c518c
da6a84f
bce16ca
15c595b
251538d
ca09666
f1134ac
8677162
3b76db9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
…use it in deploy flow Signed-off-by: Daniele Martinoli <dmartino@redhat.com>
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,8 @@ | ||
| package services | ||
|
|
||
| import ( | ||
| "fmt" | ||
|
|
||
| "github.com/feast-dev/feast/infra/feast-operator/api/feastversion" | ||
| feastdevv1alpha1 "github.com/feast-dev/feast/infra/feast-operator/api/v1alpha1" | ||
| ) | ||
|
|
@@ -10,70 +12,74 @@ func IsLocalRegistry(featureStore *feastdevv1alpha1.FeatureStore) bool { | |
| return appliedServices != nil && appliedServices.Registry != nil && appliedServices.Registry.Local != nil | ||
| } | ||
|
|
||
| func ApplyDefaultsToStatus(cr *feastdevv1alpha1.FeatureStore) error { | ||
| func ApplyDefaultsToStatus(cr *feastdevv1alpha1.FeatureStore) { | ||
| cr.Status.FeastVersion = feastversion.FeastVersion | ||
| applied := cr.Spec.DeepCopy() | ||
| if applied.Services == nil { | ||
| applied.Services = &feastdevv1alpha1.FeatureStoreServices{} | ||
| } | ||
| services := applied.Services | ||
|
|
||
| // default to registry service deployment | ||
| if applied.Services.Registry == nil { | ||
| applied.Services.Registry = &feastdevv1alpha1.Registry{} | ||
| if services.Registry == nil { | ||
| services.Registry = &feastdevv1alpha1.Registry{} | ||
| } | ||
|
dmartinol marked this conversation as resolved.
|
||
| // if remote registry not set, proceed w/ local registry defaults | ||
| if applied.Services.Registry.Remote == nil { | ||
| if services.Registry.Remote == nil { | ||
| // if local registry not set, apply an empty pointer struct | ||
| if applied.Services.Registry.Local == nil { | ||
| applied.Services.Registry.Local = &feastdevv1alpha1.LocalRegistryConfig{} | ||
| if services.Registry.Local == nil { | ||
| services.Registry.Local = &feastdevv1alpha1.LocalRegistryConfig{} | ||
| } | ||
| if applied.Services.Registry.Local.Persistence == nil { | ||
| applied.Services.Registry.Local.Persistence = &feastdevv1alpha1.RegistryPersistence{} | ||
| if services.Registry.Local.Persistence == nil { | ||
| services.Registry.Local.Persistence = &feastdevv1alpha1.RegistryPersistence{} | ||
| } | ||
| if applied.Services.Registry.Local.Persistence.FilePersistence == nil { | ||
| applied.Services.Registry.Local.Persistence.FilePersistence = &feastdevv1alpha1.RegistryFilePersistence{} | ||
| if services.Registry.Local.Persistence.FilePersistence == nil { | ||
| services.Registry.Local.Persistence.FilePersistence = &feastdevv1alpha1.RegistryFilePersistence{} | ||
| } | ||
|
dmartinol marked this conversation as resolved.
|
||
| if len(applied.Services.Registry.Local.Persistence.FilePersistence.Path) == 0 { | ||
| applied.Services.Registry.Local.Persistence.FilePersistence.Path = DefaultRegistryPath | ||
| if len(services.Registry.Local.Persistence.FilePersistence.Path) == 0 { | ||
| services.Registry.Local.Persistence.FilePersistence.Path = DefaultRegistryPath | ||
| } | ||
| setServiceDefaultConfigs(&applied.Services.Registry.Local.ServiceConfigs.DefaultConfigs) | ||
| setServiceDefaultConfigs(&services.Registry.Local.ServiceConfigs.DefaultConfigs) | ||
| } | ||
| if applied.Services.OfflineStore != nil { | ||
| setServiceDefaultConfigs(&applied.Services.OfflineStore.ServiceConfigs.DefaultConfigs) | ||
| if applied.Services.OfflineStore.Persistence == nil { | ||
| applied.Services.OfflineStore.Persistence = &feastdevv1alpha1.OfflineStorePersistence{} | ||
| if services.OfflineStore != nil { | ||
| setServiceDefaultConfigs(&services.OfflineStore.ServiceConfigs.DefaultConfigs) | ||
| if services.OfflineStore.Persistence == nil { | ||
| services.OfflineStore.Persistence = &feastdevv1alpha1.OfflineStorePersistence{} | ||
| } | ||
| if applied.Services.OfflineStore.Persistence.FilePersistence == nil { | ||
| applied.Services.OfflineStore.Persistence.FilePersistence = &feastdevv1alpha1.OfflineStoreFilePersistence{} | ||
| if services.OfflineStore.Persistence.FilePersistence == nil { | ||
| services.OfflineStore.Persistence.FilePersistence = &feastdevv1alpha1.OfflineStoreFilePersistence{} | ||
| } | ||
| if len(applied.Services.OfflineStore.Persistence.FilePersistence.Type) == 0 { | ||
| applied.Services.OfflineStore.Persistence.FilePersistence.Type = string(OfflineDaskConfigType) | ||
| } else { | ||
| _, err := feastdevv1alpha1.IsValidOfflineStoreFilePersistenceType(applied.Services.OfflineStore.Persistence.FilePersistence.Type) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| if len(services.OfflineStore.Persistence.FilePersistence.Type) == 0 { | ||
| services.OfflineStore.Persistence.FilePersistence.Type = string(OfflineDaskConfigType) | ||
| } | ||
| } | ||
|
dmartinol marked this conversation as resolved.
|
||
| if applied.Services.OnlineStore != nil { | ||
| setServiceDefaultConfigs(&applied.Services.OnlineStore.ServiceConfigs.DefaultConfigs) | ||
| if applied.Services.OnlineStore.Persistence == nil { | ||
| applied.Services.OnlineStore.Persistence = &feastdevv1alpha1.OnlineStorePersistence{} | ||
| if services.OnlineStore != nil { | ||
| setServiceDefaultConfigs(&services.OnlineStore.ServiceConfigs.DefaultConfigs) | ||
| if services.OnlineStore.Persistence == nil { | ||
| services.OnlineStore.Persistence = &feastdevv1alpha1.OnlineStorePersistence{} | ||
| } | ||
| if applied.Services.OnlineStore.Persistence.FilePersistence == nil { | ||
| applied.Services.OnlineStore.Persistence.FilePersistence = &feastdevv1alpha1.OnlineStoreFilePersistence{} | ||
| if services.OnlineStore.Persistence.FilePersistence == nil { | ||
| services.OnlineStore.Persistence.FilePersistence = &feastdevv1alpha1.OnlineStoreFilePersistence{} | ||
| } | ||
| if len(applied.Services.OnlineStore.Persistence.FilePersistence.Path) == 0 { | ||
| applied.Services.OnlineStore.Persistence.FilePersistence.Path = DefaultOnlinePath | ||
| if len(services.OnlineStore.Persistence.FilePersistence.Path) == 0 { | ||
| services.OnlineStore.Persistence.FilePersistence.Path = DefaultOnlinePath | ||
| } | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would be good to have unit tests ensuring that proper defaults are being set in status when varying pointers around service persistence are set in the spec.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This was the idea of
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that's a great addition, and necessary, but its different from ensuring the status defaults are properly being reconciled in the CR.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see what you mean, I'll add it in the next PR for PVC so there will be more cases to cover |
||
| // overwrite status.applied with every reconcile | ||
| applied.DeepCopyInto(&cr.Status.Applied) | ||
| return nil | ||
| } | ||
|
|
||
| func setServiceDefaultConfigs(defaultConfigs *feastdevv1alpha1.DefaultConfigs) { | ||
| if defaultConfigs.Image == nil { | ||
| defaultConfigs.Image = &DefaultImage | ||
| } | ||
| } | ||
|
|
||
| func isValidOfflineStoreFilePersistenceType(value string) (bool, error) { | ||
| for _, v := range feastdevv1alpha1.ValidOfflineStoreFilePersistenceTypes { | ||
| if v == value { | ||
| return true, nil | ||
| } | ||
| } | ||
| return false, fmt.Errorf("invalid file type %s for offline store", value) | ||
| } | ||
|
dmartinol marked this conversation as resolved.
Outdated
|
||
Uh oh!
There was an error while loading. Please reload this page.