From 575040eb410f4079bb309518f8f128ebe4b4e2cd Mon Sep 17 00:00:00 2001 From: Stalin Solomon <4509346+stalingino@users.noreply.github.com> Date: Thu, 19 Nov 2026 15:45:38 +0530 Subject: [PATCH 1/2] fix(oidc): start without the OIDC provider and retry discovery ParseableServer::start awaited OIDC discovery with `?`, so an unreachable identity provider at startup made Parseable exit. Starting Parseable before its provider (common with docker compose and Kubernetes) or a provider outage kept Parseable down entirely, including ingestion and basic-auth logins that do not need OIDC, and crash-looped it under a restart policy. A failed discovery is now logged and retried in the background with capped exponential backoff (1s doubling to 60s). Everything except OIDC login works meanwhile. Login answers 503 with a clear message while discovery is pending, instead of redirecting as if OIDC were not configured, and starts working as soon as the provider answers, with no restart. --- src/handlers/http/modal/mod.rs | 60 +++++++++++++++++++++++++++++++--- src/handlers/http/oidc.rs | 11 ++++++- 2 files changed, 65 insertions(+), 6 deletions(-) diff --git a/src/handlers/http/modal/mod.rs b/src/handlers/http/modal/mod.rs index 07b5b56d8..25a1105c4 100644 --- a/src/handlers/http/modal/mod.rs +++ b/src/handlers/http/modal/mod.rs @@ -16,7 +16,15 @@ * */ -use std::{fmt, path::Path, sync::Arc, time::Duration}; +use std::{ + fmt, + path::Path, + sync::{ + Arc, + atomic::{AtomicBool, Ordering}, + }, + time::Duration, +}; use actix_web::{App, HttpServer, http::KeepAlive, middleware::from_fn, web::ServiceConfig}; use actix_web_prometheus::PrometheusMetrics; @@ -39,7 +47,7 @@ use crate::{ cli::Options, hottier::{GLOBAL_HOTTIER, HotTierManager, StreamHotTier}, metastore::metastore_traits::MetastoreObject, - oauth::{OAuthProvider, connect_oidc}, + oauth::{GlobalClient, OAuthProvider, connect_oidc}, option::Mode, parseable::{DEFAULT_TENANT, PARSEABLE}, storage::{ObjectStorageProvider, PARSEABLE_ROOT_DIRECTORY}, @@ -59,6 +67,40 @@ pub mod utils; pub static OIDC_CLIENT: OnceCell>>> = OnceCell::new(); +/// True while OIDC is configured but the provider has not been discovered yet. The login endpoint then answers +/// 503 (try again) instead of behaving as if OIDC were not configured at all. +pub static OIDC_PENDING: AtomicBool = AtomicBool::new(false); + +const OIDC_RETRY_INITIAL: Duration = Duration::from_secs(1); +const OIDC_RETRY_MAX: Duration = Duration::from_secs(60); + +fn set_oidc_client(client: GlobalClient) { + OIDC_CLIENT.get_or_init(|| Arc::new(RwLock::new(Box::new(client) as Box))); + OIDC_PENDING.store(false, Ordering::Release); +} + +/// Discovers the OIDC provider, retrying with capped exponential backoff until it answers. +/// +/// Startup used to fail outright when the provider was unreachable, so an outage of the identity provider (or +/// simply starting Parseable before it) kept Parseable down and took basic-auth logins and ingestion with it. +async fn retry_oidc_discovery(config: crate::oidc::OpenidConfig) { + let mut delay = OIDC_RETRY_INITIAL; + loop { + tokio::time::sleep(delay).await; + match connect_oidc(config.clone()).await { + Ok(client) => { + set_oidc_client(client); + info!(issuer = %config.issuer, "OIDC provider discovered; OIDC login is enabled"); + return; + } + Err(e) => { + delay = (delay * 2).min(OIDC_RETRY_MAX); + warn!(issuer = %config.issuer, retry_in_secs = delay.as_secs(), "OIDC discovery failed: {e}"); + } + } + } +} + // to be decided on what the Default version should be pub const DEFAULT_VERSION: &str = "v4"; @@ -92,9 +134,17 @@ pub trait ParseableServer { Self: Sized, { if let Some(config) = oidc_client { - let gc = connect_oidc(config).await?; - OIDC_CLIENT - .get_or_init(|| Arc::new(RwLock::new(Box::new(gc) as Box))); + match connect_oidc(config.clone()).await { + Ok(gc) => set_oidc_client(gc), + Err(e) => { + warn!( + issuer = %config.issuer, + "OIDC discovery failed: {e}; starting without OIDC login and retrying in the background" + ); + OIDC_PENDING.store(true, Ordering::Release); + tokio::spawn(retry_oidc_discovery(config)); + } + } } // get the ssl stuff diff --git a/src/handlers/http/oidc.rs b/src/handlers/http/oidc.rs index 32b8e0aeb..f91e22c19 100644 --- a/src/handlers/http/oidc.rs +++ b/src/handlers/http/oidc.rs @@ -44,7 +44,10 @@ use crate::handlers::http::modal::utils::rbac_utils::{get_metadata, put_metadata use crate::{ handlers::{ COOKIE_AGE_DAYS, SESSION_COOKIE_NAME, USER_COOKIE_NAME, USER_ID_COOKIE_NAME, - http::{cluster::sync_user_creation, modal::OIDC_CLIENT}, + http::{ + cluster::sync_user_creation, + modal::{OIDC_CLIENT, OIDC_PENDING}, + }, }, oauth::OAuthSession, parseable::{DEFAULT_TENANT, PARSEABLE}, @@ -90,6 +93,9 @@ pub async fn login( let session_key = extract_session_key_from_req(&req).ok(); let (session_key, oidc_client) = match (session_key, oidc_client) { + (None, None) if OIDC_PENDING.load(Ordering::Acquire) => { + return Err(OIDCError::ProviderUnavailable); + } (None, None) => return Ok(redirect_no_oauth_setup(query.redirect.clone())), (None, Some(client)) => { let redirect = query.into_inner().redirect.to_string(); @@ -626,6 +632,8 @@ pub enum OIDCError { BadRequest(String), #[error("Unauthorized")] Unauthorized, + #[error("The OIDC provider is not reachable yet; try again shortly")] + ProviderUnavailable, } impl actix_web::ResponseError for OIDCError { @@ -635,6 +643,7 @@ impl actix_web::ResponseError for OIDCError { Self::Serde(_) => StatusCode::INTERNAL_SERVER_ERROR, Self::BadRequest(_) => StatusCode::BAD_REQUEST, Self::Unauthorized => StatusCode::UNAUTHORIZED, + Self::ProviderUnavailable => StatusCode::SERVICE_UNAVAILABLE, } } From 8dfe295d9ec7fd3bd2e1a309d4ed74134e0d7995 Mon Sep 17 00:00:00 2001 From: Stalin Solomon <4509346+stalingino@users.noreply.github.com> Date: Thu, 19 Nov 2026 16:33:15 +0530 Subject: [PATCH 2/2] fix(oidc): read the pending flag before the client in login The retry task installs the client before clearing OIDC_PENDING. Reading the flag first means a login racing with recovery sees either the installed client or "pending", never a false "OIDC not configured" redirect. --- src/handlers/http/oidc.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/handlers/http/oidc.rs b/src/handlers/http/oidc.rs index f91e22c19..b33460e81 100644 --- a/src/handlers/http/oidc.rs +++ b/src/handlers/http/oidc.rs @@ -89,11 +89,15 @@ pub async fn login( )); } + // Read the pending flag before the client. `set_oidc_client` installs the client before clearing the flag + // (release/acquire), so a request that sees "not pending" and no client really has no OIDC configured, and one + // racing with recovery sees either the installed client or "pending", never a false "not configured". + let oidc_pending = OIDC_PENDING.load(Ordering::Acquire); let oidc_client = OIDC_CLIENT.get(); let session_key = extract_session_key_from_req(&req).ok(); let (session_key, oidc_client) = match (session_key, oidc_client) { - (None, None) if OIDC_PENDING.load(Ordering::Acquire) => { + (None, None) if oidc_pending => { return Err(OIDCError::ProviderUnavailable); } (None, None) => return Ok(redirect_no_oauth_setup(query.redirect.clone())),