@@ -65,6 +65,14 @@ pub struct ObjectStoreMetastore {
6565 pub storage : Arc < dyn ObjectStorage > ,
6666}
6767
68+ fn is_missing_optional_dir ( err : & ObjectStorageError ) -> bool {
69+ match err {
70+ ObjectStorageError :: NoSuchKey ( _) => true ,
71+ ObjectStorageError :: IoError ( err) => err. kind ( ) == std:: io:: ErrorKind :: NotFound ,
72+ _ => false ,
73+ }
74+ }
75+
6876#[ async_trait]
6977impl Metastore for ObjectStoreMetastore {
7078 /// Since Parseable already starts with a connection to an object store, no need to implement this
@@ -263,7 +271,7 @@ impl Metastore for ObjectStoreMetastore {
263271 let mut all_alerts = HashMap :: new ( ) ;
264272 for mut tenant in base_paths {
265273 let alerts_path = RelativePathBuf :: from_iter ( [ & tenant, ALERTS_ROOT_DIRECTORY ] ) ;
266- let alerts = self
274+ let alerts = match self
267275 . storage
268276 . get_objects (
269277 Some ( & alerts_path) ,
@@ -272,7 +280,12 @@ impl Metastore for ObjectStoreMetastore {
272280 } ) ,
273281 & Some ( tenant. clone ( ) ) ,
274282 )
275- . await ?;
283+ . await
284+ {
285+ Ok ( alerts) => alerts,
286+ Err ( err) if is_missing_optional_dir ( & err) => Vec :: new ( ) ,
287+ Err ( err) => return Err ( MetastoreError :: ObjectStorageError ( err) ) ,
288+ } ;
276289 if tenant. is_empty ( ) {
277290 tenant. clone_from ( & DEFAULT_TENANT . to_string ( ) ) ;
278291 }
@@ -1122,14 +1135,20 @@ impl Metastore for ObjectStoreMetastore {
11221135 SETTINGS_ROOT_DIRECTORY ,
11231136 TARGETS_ROOT_DIRECTORY ,
11241137 ] ) ;
1125- let targets = self
1138+ let target_bytes = match self
11261139 . storage
11271140 . get_objects (
11281141 Some ( & targets_path) ,
11291142 Box :: new ( |file_name| file_name. ends_with ( ".json" ) ) ,
11301143 & Some ( tenant. clone ( ) ) ,
11311144 )
1132- . await ?
1145+ . await
1146+ {
1147+ Ok ( targets) => targets,
1148+ Err ( err) if is_missing_optional_dir ( & err) => Vec :: new ( ) ,
1149+ Err ( err) => return Err ( MetastoreError :: ObjectStorageError ( err) ) ,
1150+ } ;
1151+ let targets = target_bytes
11331152 . iter ( )
11341153 . filter_map ( |bytes| {
11351154 serde_json:: from_slice ( bytes)
0 commit comments