From 325de52e73460f4187ccee941d07008374860530 Mon Sep 17 00:00:00 2001 From: Erik Grinaker Date: Tue, 1 Oct 2024 17:35:18 +0200 Subject: [PATCH] pageserver: remove `TenantConfOpt::TryFrom` (#9219) Following #7656, `TenantConfOpt::TryFrom` appears to be dead code. This patch removes `TenantConfOpt::TryFrom`. The code does appear to be dead, since the TOML config is deserialized into `TenantConfig` (via `LocationConfig`) and then converted into `TenantConfOpt`. This was verified by adding a panic to `try_from()` and running the pageserver unit tests as well as a local end-to-end cluster (including creating a new tenant and restarting the pageserver). This did not fail, so this is not used on the common happy path at least. No explicit `try_from` or `try_into` calls were found either. Resolves #8918. --- pageserver/src/tenant/config.rs | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/pageserver/src/tenant/config.rs b/pageserver/src/tenant/config.rs index 547b43a399..502cb62fe8 100644 --- a/pageserver/src/tenant/config.rs +++ b/pageserver/src/tenant/config.rs @@ -8,7 +8,6 @@ //! We cannot use global or default config instead, because wrong settings //! may lead to a data loss. //! -use anyhow::bail; pub(crate) use pageserver_api::config::TenantConfigToml as TenantConf; use pageserver_api::models::AuxFilePolicy; use pageserver_api::models::CompactionAlgorithmSettings; @@ -441,29 +440,6 @@ impl TryFrom<&'_ models::TenantConfig> for TenantConfOpt { } } -impl TryFrom for TenantConfOpt { - type Error = anyhow::Error; - - fn try_from(item: toml_edit::Item) -> Result { - match item { - toml_edit::Item::Value(value) => { - let d = value.into_deserializer(); - return serde_path_to_error::deserialize(d) - .map_err(|e| anyhow::anyhow!("{}: {}", e.path(), e.inner().message())); - } - toml_edit::Item::Table(table) => { - let deserializer = - toml_edit::de::Deserializer::from(toml_edit::DocumentMut::from(table)); - return serde_path_to_error::deserialize(deserializer) - .map_err(|e| anyhow::anyhow!("{}: {}", e.path(), e.inner().message())); - } - _ => { - bail!("expected non-inline table but found {item}") - } - } - } -} - /// This is a conversion from our internal tenant config object to the one used /// in external APIs. impl From for models::TenantConfig {