Skip to content

Commit 00fa1d3

Browse files
committed
fix: add querier details to parseable.json on a fresh init
1 parent 2108a34 commit 00fa1d3

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

server/src/handlers/http/cluster/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -849,8 +849,8 @@ pub async fn forward_create_stream_request(stream_name: &str) -> Result<(), Stre
849849
let staging_metadata = get_staging_metadata().unwrap().ok_or_else(|| {
850850
StreamError::Anyhow(anyhow::anyhow!("Failed to retrieve staging metadata"))
851851
})?;
852-
let querier_endpoint = to_url_string(staging_metadata.querier_endpoint.unwrap());
853-
let token = staging_metadata.querier_auth_token.unwrap();
852+
let querier_endpoint = to_url_string(staging_metadata.querier_endpoint);
853+
let token = staging_metadata.querier_auth_token;
854854

855855
if !check_liveness(&querier_endpoint).await {
856856
log::warn!("Querier {} is not live", querier_endpoint);

server/src/storage/store_metadata.rs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use std::{
2222
path::PathBuf,
2323
};
2424

25+
use base64::Engine;
2526
use bytes::Bytes;
2627
use once_cell::sync::OnceCell;
2728
use relative_path::RelativePathBuf;
@@ -63,12 +64,25 @@ pub struct StorageMetadata {
6364
pub roles: HashMap<String, Vec<DefaultPrivilege>>,
6465
#[serde(default)]
6566
pub default_role: Option<String>,
66-
pub querier_endpoint: Option<String>,
67-
pub querier_auth_token: Option<String>,
67+
pub querier_endpoint: String,
68+
pub querier_auth_token: String,
6869
}
6970

7071
impl StorageMetadata {
7172
pub fn new() -> Self {
73+
let querier_auth_token = format!(
74+
"Basic {}",
75+
base64::prelude::BASE64_STANDARD.encode(format!(
76+
"{}:{}",
77+
CONFIG.parseable.username, CONFIG.parseable.password
78+
))
79+
);
80+
81+
let (querier_endpoint, querier_auth_token) = match CONFIG.parseable.mode {
82+
Mode::All | Mode::Query => (CONFIG.parseable.address.clone(), querier_auth_token),
83+
Mode::Ingest => (String::new(), String::new()),
84+
};
85+
7286
Self {
7387
version: CURRENT_STORAGE_METADATA_VERSION.to_string(),
7488
mode: CONFIG.storage_name.to_owned(),
@@ -80,11 +94,10 @@ impl StorageMetadata {
8094
streams: Vec::new(),
8195
roles: HashMap::default(),
8296
default_role: None,
83-
querier_endpoint: None,
84-
querier_auth_token: None,
97+
querier_endpoint,
98+
querier_auth_token,
8599
}
86100
}
87-
88101
pub fn global() -> &'static StaticStorageMetadata {
89102
STORAGE_METADATA
90103
.get()

0 commit comments

Comments
 (0)