-
-
Notifications
You must be signed in to change notification settings - Fork 157
Proper Error Message if the Storage is in an invalid state #623
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 5 commits
98d7a43
a5306f6
e5581b0
691e932
3be5d05
90ae9ba
421f89d
fb50327
22a6acd
ae44f8d
e2fe24d
5f1fc55
5f5137f
f0370e8
d43728c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,7 +27,7 @@ use std::sync::Arc; | |
| use url::Url; | ||
|
|
||
| use crate::oidc::{self, OpenidConfig}; | ||
| use crate::storage::{FSConfig, ObjectStorageProvider, S3Config}; | ||
| use crate::storage::{FSConfig, ObjectStorageError, ObjectStorageProvider, S3Config}; | ||
| use crate::utils::validate_path_is_writeable; | ||
|
|
||
| pub const MIN_CACHE_SIZE_BYTES: u64 = 1000u64.pow(3); // 1 GiB | ||
|
|
@@ -104,6 +104,37 @@ impl Config { | |
| validate_path_is_writeable(staging_path) | ||
| } | ||
|
|
||
| pub async fn validate_storage(&self) -> Result<(), ObjectStorageError> { | ||
| let obj_store = self.storage.get_object_store(); | ||
| let rel_path = relative_path::RelativePathBuf::from(".parseable.json"); | ||
|
|
||
| let has_parseable_json = obj_store.get_object(&rel_path).await.is_ok(); | ||
|
|
||
| let has_dirs = match obj_store.list_dirs_in_storage().await { | ||
| Ok(dirs) => dirs.is_empty(), | ||
| Err(_) => false, | ||
| }; | ||
|
|
||
| let has_streams = obj_store.list_streams().await.is_ok(); | ||
|
|
||
| if has_dirs || has_parseable_json && has_streams { | ||
| Ok(()) | ||
| } else if has_parseable_json && !has_streams { | ||
| Err(ObjectStorageError::Custom( | ||
| "Parseable config found, but the Storage contains some stale data.".to_owned(), | ||
| )) | ||
| } else if !has_parseable_json && !has_streams && !has_dirs { | ||
| Err(ObjectStorageError::Custom( | ||
| "Storage contains some stale data, Please provide an Empty Storage".to_owned(), | ||
|
||
| )) | ||
| } else { | ||
| Err(ObjectStorageError::Custom( | ||
| "Parseable config is missing, but streams are present in Storage.\nJoin us on Parseable Slack" | ||
|
||
| .to_owned() | ||
| )) | ||
| } | ||
| } | ||
|
|
||
| pub fn storage(&self) -> Arc<dyn ObjectStorageProvider + Send + Sync> { | ||
| self.storage.clone() | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please correct the error to -
Could not start the server because storage contains stale data from previous deployment, please choose an empty storage and restart the server. Join us on Parseable Slack to report this incident : https://launchpass.com/parseable
Also, Parseable.json file gets created in storage, staging directory gets created, parseable.json gets created in staging -- none of these should happen in case of error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error will be triggered if someone added some data to the storage where parseable stores data.
This case is the least likeliest to happen.