From 8d2feb9da1f3faf073e28408749956c8534ec977 Mon Sep 17 00:00:00 2001 From: Nikhil Sinha <131262146+nikhilsinhaparseable@users.noreply.github.com> Date: Wed, 13 Nov 2024 13:27:02 +0530 Subject: [PATCH] fix: server mode from All to Query (#988) 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 --- server/src/storage/store_metadata.rs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/server/src/storage/store_metadata.rs b/server/src/storage/store_metadata.rs index f19765f0..686d7e0c 100644 --- a/server/src/storage/store_metadata.rs +++ b/server/src/storage/store_metadata.rs @@ -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 = err.into(); ObjectStorageError::UnhandledError(err) })?; + metadata.server_mode = CONFIG.parseable.mode.to_string(); if overwrite_remote { put_remote_metadata(&metadata).await?; } @@ -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),