From c5ea91f8317d22a01ebaa9e48172c117a425768d Mon Sep 17 00:00:00 2001 From: John Spray Date: Thu, 5 Oct 2023 01:31:17 +0100 Subject: [PATCH] pageserver: fix loading control plane JWT token (#5470) ## Problem In #5383 this configuration was added, but it missed the parts of the Builder class that let it actually be used. ## Summary of changes Add `control_plane_api_token` hooks to PageserverConfigBuilder --- libs/utils/src/logging.rs | 6 ++++++ pageserver/src/config.rs | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/libs/utils/src/logging.rs b/libs/utils/src/logging.rs index 7f17970c4c..502e02dc71 100644 --- a/libs/utils/src/logging.rs +++ b/libs/utils/src/logging.rs @@ -228,6 +228,12 @@ impl SecretString { } } +impl From for SecretString { + fn from(s: String) -> Self { + Self(s) + } +} + impl std::fmt::Debug for SecretString { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "[SECRET]") diff --git a/pageserver/src/config.rs b/pageserver/src/config.rs index 19c4a32bde..333d12a544 100644 --- a/pageserver/src/config.rs +++ b/pageserver/src/config.rs @@ -487,6 +487,10 @@ impl PageServerConfigBuilder { self.control_plane_api = BuilderValue::Set(api) } + pub fn control_plane_api_token(&mut self, token: Option) { + self.control_plane_api_token = BuilderValue::Set(token) + } + pub fn build(self) -> anyhow::Result { let concurrent_tenant_size_logical_size_queries = self .concurrent_tenant_size_logical_size_queries @@ -787,6 +791,14 @@ impl PageServerConf { builder.control_plane_api(Some(parsed.parse().context("failed to parse control plane URL")?)) } }, + "control_plane_api_token" => { + let parsed = parse_toml_string(key, item)?; + if parsed.is_empty() { + builder.control_plane_api_token(None) + } else { + builder.control_plane_api_token(Some(parsed.into())) + } + }, _ => bail!("unrecognized pageserver option '{key}'"), } }