allow empty string for SOLANA_METRICS_CONFIG sanity checking (#33515)
This commit is contained in:
parent
b36d051b51
commit
0f82662a7f
|
@ -561,6 +561,10 @@ impl Validator {
|
|||
));
|
||||
}
|
||||
|
||||
let genesis_config =
|
||||
open_genesis_config(ledger_path, config.max_genesis_archive_unpacked_size);
|
||||
metrics_config_sanity_check(genesis_config.cluster_type)?;
|
||||
|
||||
if let Some(expected_shred_version) = config.expected_shred_version {
|
||||
if let Some(wait_for_supermajority_slot) = config.wait_for_supermajority {
|
||||
*start_progress.write().unwrap() = ValidatorStartProgress::CleaningBlockStore;
|
||||
|
@ -1334,14 +1338,11 @@ impl Validator {
|
|||
config.generator_config.clone(),
|
||||
);
|
||||
|
||||
let cluster_type = bank_forks.read().unwrap().root_bank().cluster_type();
|
||||
metrics_config_sanity_check(cluster_type)?;
|
||||
|
||||
datapoint_info!(
|
||||
"validator-new",
|
||||
("id", id.to_string(), String),
|
||||
("version", solana_version::version!(), String),
|
||||
("cluster_type", cluster_type as u32, i64),
|
||||
("cluster_type", genesis_config.cluster_type as u32, i64),
|
||||
);
|
||||
|
||||
*start_progress.write().unwrap() = ValidatorStartProgress::Running;
|
||||
|
|
|
@ -25,7 +25,7 @@ type CounterMap = HashMap<(&'static str, u64), CounterPoint>;
|
|||
#[derive(Debug, Error)]
|
||||
pub enum MetricsError {
|
||||
#[error(transparent)]
|
||||
VarError(#[from] std::env::VarError),
|
||||
VarError(#[from] env::VarError),
|
||||
#[error(transparent)]
|
||||
ReqwestError(#[from] reqwest::Error),
|
||||
#[error("SOLANA_METRICS_CONFIG is invalid: '{0}'")]
|
||||
|
@ -405,6 +405,9 @@ impl MetricsConfig {
|
|||
fn get_metrics_config() -> Result<MetricsConfig, MetricsError> {
|
||||
let mut config = MetricsConfig::default();
|
||||
let config_var = env::var("SOLANA_METRICS_CONFIG")?;
|
||||
if config_var.is_empty() {
|
||||
Err(env::VarError::NotPresent)?;
|
||||
}
|
||||
|
||||
for pair in config_var.split(',') {
|
||||
let nv: Vec<_> = pair.split('=').collect();
|
||||
|
@ -431,7 +434,7 @@ fn get_metrics_config() -> Result<MetricsConfig, MetricsError> {
|
|||
pub fn metrics_config_sanity_check(cluster_type: ClusterType) -> Result<(), MetricsError> {
|
||||
let config = match get_metrics_config() {
|
||||
Ok(config) => config,
|
||||
Err(MetricsError::VarError(std::env::VarError::NotPresent)) => return Ok(()),
|
||||
Err(MetricsError::VarError(env::VarError::NotPresent)) => return Ok(()),
|
||||
Err(e) => return Err(e),
|
||||
};
|
||||
match &config.db[..] {
|
||||
|
|
Loading…
Reference in New Issue