From c9dcddab9613aefa2a1d21073146e62fec7d90b5 Mon Sep 17 00:00:00 2001 From: Solly Ross Date: Sun, 15 Feb 2026 04:22:31 -0800 Subject: [PATCH] fix case where setting one pingora setting removed defaults now try to merge all settings with the corresponding defaults, instead of using the settings wholesale, since zero-values are not what we want as defaults for stuff like `threads`. --- src/config.rs | 32 ++++++++++++++++++++++---------- src/config/format.proto | 20 ++++++++++---------- 2 files changed, 32 insertions(+), 20 deletions(-) diff --git a/src/config.rs b/src/config.rs index 15fcb35..bf07f63 100644 --- a/src/config.rs +++ b/src/config.rs @@ -17,31 +17,43 @@ pub mod format { impl From<&Pingora> for pingora::server::configuration::ServerConf { fn from(raw: &Pingora) -> Self { + let default = pingora::server::configuration::ServerConf::default(); Self { - version: raw.version as usize, - daemon: raw.daemon, + version: raw.version.map(|v| v as usize).unwrap_or(default.version), + daemon: raw.daemon.unwrap_or(default.daemon), error_log: raw.error_log.clone(), - pid_file: raw.pid_file.clone(), - upgrade_sock: raw.upgrade_sock.clone(), + pid_file: raw.pid_file.clone().unwrap_or(default.pid_file), + upgrade_sock: raw.upgrade_sock.clone().unwrap_or(default.upgrade_sock), user: raw.user.clone(), group: raw.group.clone(), - threads: raw.threads as usize, - listener_tasks_per_fd: raw.listener_tasks_per_fd as usize, - work_stealing: raw.work_stealing, + threads: raw.threads.map(|t| t as usize).unwrap_or(default.threads), + listener_tasks_per_fd: raw + .listener_tasks_per_fd + .map(|t| t as usize) + .unwrap_or(default.listener_tasks_per_fd), + work_stealing: raw.work_stealing.unwrap_or(default.work_stealing), ca_file: raw.ca_file.clone(), grace_period_seconds: raw.grace_period_seconds, graceful_shutdown_timeout_seconds: raw.graceful_shutdown_timeout_seconds, client_bind_to_ipv4: raw.client_bind_to_ipv4.clone(), client_bind_to_ipv6: raw.client_bind_to_ipv6.clone(), - upstream_keepalive_pool_size: raw.upstream_keepalive_pool_size as usize, + upstream_keepalive_pool_size: raw + .upstream_keepalive_pool_size + .map(|s| s as usize) + .unwrap_or(default.upstream_keepalive_pool_size), upstream_connect_offload_threadpools: raw .upstream_connect_offload_threadpools .map(|x| x as usize), upstream_connect_offload_thread_per_pool: raw .upstream_connect_offload_thread_per_pool .map(|x| x as usize), - upstream_debug_ssl_keylog: raw.upstream_debug_ssl_keylog, - max_retries: raw.max_retries as usize, + upstream_debug_ssl_keylog: raw + .upstream_debug_ssl_keylog + .unwrap_or(default.upstream_debug_ssl_keylog), + max_retries: raw + .max_retries + .map(|r| r as usize) + .unwrap_or(default.max_retries), upgrade_sock_connect_accept_max_retries: raw .upgrade_sock_connect_accept_max_retries .map(|x| x as usize), diff --git a/src/config/format.proto b/src/config/format.proto index 6fbc4a0..6968cc2 100644 --- a/src/config/format.proto +++ b/src/config/format.proto @@ -186,26 +186,26 @@ message ManageHeaders { // See [pingora](https://docs.rs/pingora/latest/pingora/server/configuration/struct.ServerConf.html) // for details on what these do message Pingora { - uint64 version = 1; - bool daemon = 2; + optional uint64 version = 1; + optional bool daemon = 2; optional string error_log = 3; - string pid_file = 4; - string upgrade_sock = 5; + optional string pid_file = 4; + optional string upgrade_sock = 5; optional string user = 6; optional string group = 7; - uint64 threads = 8; - uint64 listener_tasks_per_fd = 9; - bool work_stealing = 10; + optional uint64 threads = 8; + optional uint64 listener_tasks_per_fd = 9; + optional bool work_stealing = 10; optional string ca_file = 11; optional uint64 grace_period_seconds = 12; optional uint64 graceful_shutdown_timeout_seconds = 13; repeated string client_bind_to_ipv4 = 14; repeated string client_bind_to_ipv6 = 15; - uint64 upstream_keepalive_pool_size = 16; + optional uint64 upstream_keepalive_pool_size = 16; optional uint64 upstream_connect_offload_threadpools = 17; optional uint64 upstream_connect_offload_thread_per_pool = 18; - bool upstream_debug_ssl_keylog = 19; - uint64 max_retries = 20; + optional bool upstream_debug_ssl_keylog = 19; + optional uint64 max_retries = 20; optional uint64 upgrade_sock_connect_accept_max_retries = 21; } -- knotmirror 0.0.1