Skip to content

Commit

Permalink
fix: server mode from All to Query (#988)
Browse files Browse the repository at this point in the history
Upon migration from Standalone to Distributed mode,
Query server should update the server mode from `All` to 
`Query` in `.parseable.json` in storage as well in staging
  • Loading branch information
nikhilsinhaparseable authored Nov 13, 2024
1 parent 46686dc commit 8d2feb9
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions server/src/storage/store_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,13 @@ pub async fn resolve_parseable_metadata(
}
};

let metadata = res.map_err(|err| {
let mut metadata = res.map_err(|err| {
let err = format!("{}. {}", err, JOIN_COMMUNITY);
let err: Box<dyn std::error::Error + Send + Sync + 'static> = err.into();
ObjectStorageError::UnhandledError(err)
})?;

metadata.server_mode = CONFIG.parseable.mode.to_string();
if overwrite_remote {
put_remote_metadata(&metadata).await?;
}
Expand All @@ -227,19 +228,19 @@ fn determine_environment(
) -> EnvChange {
match (staging_metadata, remote_metadata) {
(Some(staging), Some(remote)) => {
// if both staging and remote have same deployment id
if staging.deployment_id == remote.deployment_id {
EnvChange::None(remote)
} else if Mode::from_string(&remote.server_mode).expect("server mode is valid here")
== Mode::All
// if both staging and remote have same deployment id but different server modes
if staging.deployment_id == remote.deployment_id
&& Mode::from_string(&remote.server_mode).expect("server mode is valid here")
== Mode::All
&& (CONFIG.parseable.mode == Mode::Query || CONFIG.parseable.mode == Mode::Ingest)
{
// if you are switching to distributed mode from standalone mode
// it will create a new staging rather than a new remote
EnvChange::NewStaging(remote)
} else {
// it is a new remote
} else if staging.deployment_id != remote.deployment_id {
// if deployment id is different
EnvChange::NewRemote
} else {
// if deployment id is same
EnvChange::None(remote)
}
}
(None, Some(remote)) => EnvChange::NewStaging(remote),
Expand Down

0 comments on commit 8d2feb9

Please sign in to comment.