@@ -45,7 +45,6 @@ use crate::{handlers::http::base_path, option::CONFIG};
4545use actix_web:: web;
4646use actix_web:: web:: resource;
4747use actix_web:: Scope ;
48- use anyhow:: anyhow;
4948use async_trait:: async_trait;
5049use base64:: Engine ;
5150use bytes:: Bytes ;
@@ -292,9 +291,7 @@ pub async fn set_ingestor_metadata() -> anyhow::Result<()> {
292291 let path = ingestor_metadata_path ( None ) ;
293292
294293 // we are considering that we can always get from object store
295- if storage_ingestor_metadata. is_some ( ) {
296- let mut store_data = storage_ingestor_metadata. unwrap ( ) ;
297-
294+ if let Some ( mut store_data) = storage_ingestor_metadata {
298295 if store_data. domain_name != INGESTOR_META . domain_name {
299296 store_data
300297 . domain_name
@@ -304,10 +301,7 @@ pub async fn set_ingestor_metadata() -> anyhow::Result<()> {
304301 let resource = Bytes :: from ( serde_json:: to_vec ( & store_data) ?) ;
305302
306303 // if pushing to object store fails propagate the error
307- return store
308- . put_object ( & path, resource)
309- . await
310- . map_err ( |err| anyhow ! ( err) ) ;
304+ store. put_object ( & path, resource) . await ?;
311305 }
312306 } else {
313307 let resource = Bytes :: from ( serde_json:: to_vec ( & resource) ?) ;
@@ -324,18 +318,19 @@ async fn check_querier_state() -> anyhow::Result<Option<Bytes>, ObjectStorageErr
324318 // how do we check for querier state?
325319 // based on the work flow of the system, the querier will always need to start first
326320 // i.e the querier will create the `.parseable.json` file
321+ let parseable_json = CONFIG
322+ . storage ( )
323+ . get_object_store ( )
324+ . get_object ( & parseable_json_path ( ) )
325+ . await
326+ . map_err ( |_| {
327+ ObjectStorageError :: Custom (
328+ "Query Server has not been started yet. Please start the querier server first."
329+ . to_string ( ) ,
330+ )
331+ } ) ?;
327332
328- let store = CONFIG . storage ( ) . get_object_store ( ) ;
329- let path = parseable_json_path ( ) ;
330-
331- let parseable_json = store. get_object ( & path) . await ;
332- match parseable_json {
333- Ok ( _) => Ok ( Some ( parseable_json. unwrap ( ) ) ) ,
334- Err ( _) => Err ( ObjectStorageError :: Custom (
335- "Query Server has not been started yet. Please start the querier server first."
336- . to_string ( ) ,
337- ) ) ,
338- }
333+ Ok ( Some ( parseable_json) )
339334}
340335
341336async fn validate_credentials ( ) -> anyhow:: Result < ( ) > {
0 commit comments