Skip to content

Commit de91c29

Browse files
committed
refactor(server): fix the provider-profile source refresh interval
Drop the unreleased provider_profile_source_refresh_interval_seconds gateway setting. Interceptor provider-profile sources refresh every 10 seconds, matching the supervisor configuration poll interval. Signed-off-by: Piotr Mlocek <pmlocek@nvidia.com>
1 parent 754e3d2 commit de91c29

8 files changed

Lines changed: 8 additions & 30 deletions

File tree

‎crates/openshell-core/src/config.rs‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ use std::time::Duration;
2020
// reference these constants instead of hardcoding literals.
2121

2222
/// Default SSH port inside sandbox containers.
23-
/// Default refresh interval for interceptor provider-profile sources. Matches
24-
/// the supervisor configuration poll interval.
25-
pub const DEFAULT_PROVIDER_PROFILE_SOURCE_REFRESH_INTERVAL_SECS: u64 = 10;
2623
pub const DEFAULT_SSH_PORT: u16 = 2222;
2724

2825
/// Default gateway server port.
@@ -261,10 +258,6 @@ pub struct Config {
261258
/// Ordered provider-profile sources used to build the effective catalog.
262259
pub provider_profile_sources: Vec<GatewayProviderProfileSourceConfig>,
263260

264-
/// How often interceptor provider-profile sources are re-fetched. Reads
265-
/// use the cached snapshot and fail closed once it is three intervals old.
266-
pub provider_profile_source_refresh_interval_secs: u64,
267-
268261
/// mTLS user authentication configuration. When enabled, a verified TLS
269262
/// client certificate can authenticate CLI/SDK callers as a
270263
/// `Principal::User`. This is for local single-user gateways only;
@@ -923,8 +916,6 @@ impl Config {
923916
enable_websocket_tunnel: false,
924917
gateway_interceptors: Vec::new(),
925918
provider_profile_sources: vec![GatewayProviderProfileSourceConfig::User],
926-
provider_profile_source_refresh_interval_secs:
927-
DEFAULT_PROVIDER_PROFILE_SOURCE_REFRESH_INTERVAL_SECS,
928919
mtls_auth: MtlsAuthConfig::default(),
929920
gateway_jwt: None,
930921
database_url: String::new(),

‎crates/openshell-server/src/cli.rs‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -533,18 +533,6 @@ fn prepare_server_config_with_drivers(
533533
{
534534
config = config.with_provider_profile_sources(sources);
535535
}
536-
if let Some(seconds) = file.as_ref().and_then(|file| {
537-
file.openshell
538-
.gateway
539-
.provider_profile_source_refresh_interval_seconds
540-
}) {
541-
if seconds == 0 {
542-
return Err(miette::miette!(
543-
"provider_profile_source_refresh_interval_seconds must be greater than zero"
544-
));
545-
}
546-
config.provider_profile_source_refresh_interval_secs = seconds;
547-
}
548536

549537
if let Some(gateway_file) = file.as_ref().map(|f| &f.openshell.gateway) {
550538
if let Some(drivers) = &gateway_file.credential_drivers {

‎crates/openshell-server/src/config_file.rs‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,6 @@ pub struct GatewayFileSection {
163163
pub interceptors: Vec<GatewayInterceptorConfig>,
164164
#[serde(default)]
165165
pub provider_profile_sources: Option<Vec<GatewayProviderProfileSourceConfig>>,
166-
/// Seconds between refreshes of interceptor provider-profile sources.
167-
#[serde(default)]
168-
pub provider_profile_source_refresh_interval_seconds: Option<u64>,
169166
#[serde(default)]
170167
pub mtls_auth: Option<MtlsAuthConfig>,
171168
#[serde(default)]

‎crates/openshell-server/src/grpc/mod.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1176,7 +1176,7 @@ pub mod test_support {
11761176
crate::provider_profile_sources::ProviderProfileSources::from_config(
11771177
&[openshell_core::GatewayProviderProfileSourceConfig::User],
11781178
None,
1179-
std::time::Duration::from_secs(10),
1179+
crate::provider_profile_sources::PROVIDER_PROFILE_SOURCE_REFRESH_INTERVAL,
11801180
)
11811181
.expect("user-only provider profile source configuration should be valid")
11821182
}

‎crates/openshell-server/src/lib.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ pub(crate) async fn run_server(
694694
let provider_profile_sources = provider_profile_sources::ProviderProfileSources::from_config(
695695
&config.provider_profile_sources,
696696
gateway_interceptors.as_ref(),
697-
Duration::from_secs(config.provider_profile_source_refresh_interval_secs),
697+
provider_profile_sources::PROVIDER_PROFILE_SOURCE_REFRESH_INTERVAL,
698698
)
699699
.map_err(|err| {
700700
Error::config(format!(

‎crates/openshell-server/src/provider_profile_sources.rs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ use crate::persistence::{ObjectListQuery, ObjectType, Store};
3232
use crate::storage_proto::StoredProviderProfile;
3333

3434
const USER_SOURCE_ID: &str = "user";
35+
/// How often the gateway re-fetches interceptor provider-profile sources.
36+
/// Matches the supervisor configuration poll interval.
37+
pub const PROVIDER_PROFILE_SOURCE_REFRESH_INTERVAL: Duration = Duration::from_secs(10);
38+
3539
/// A cached snapshot older than this many refresh intervals fails closed: a
3640
/// stale profile could keep injecting credentials for an endpoint its source
3741
/// has withdrawn.

‎docs/extensibility/gateway-interceptors.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ Include a `{ type = "user" }` entry to compose interceptor profiles with importe
153153

154154
The gateway validates snapshot structure and provider profile semantics. It treats the configured interceptor as a trusted source and does not verify interceptor-defined signature, hash, or key annotations.
155155

156-
The gateway calls `SnapshotProviderProfiles` at startup and then every `provider_profile_source_refresh_interval_seconds` (default 10), not on every profile read. A changed `revision` reaches sandboxes on the next refresh. If the interceptor stays unreachable for three intervals, reads that need the catalog fail closed until it recovers.
156+
The gateway calls `SnapshotProviderProfiles` at startup and then every 10 seconds, not on every profile read. A changed `revision` reaches sandboxes on the next refresh. If the interceptor stays unreachable for 30 seconds, reads that need the catalog fail closed until it recovers.
157157

158158
## Operate and Observe Interceptors
159159

‎docs/how-it-works/gateways/configuration.mdx‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,6 @@ grpc_rate_limit_window_seconds = 60
211211
provider_profile_sources = [
212212
{ type = "user" },
213213
]
214-
# Seconds between fetches of interceptor provider-profile snapshots.
215-
provider_profile_source_refresh_interval_seconds = 10
216214

217215
# Operator-run supervisor middleware. The gRPC endpoint must be reachable from
218216
# both the gateway and sandbox supervisors.
@@ -506,7 +504,7 @@ provider_profile_sources = [
506504

507505
The gateway validates snapshot structure and provider-profile semantics. It treats a configured interceptor as the source trust boundary and does not verify signature, hash, or key annotations in profile payloads.
508506

509-
The gateway fetches each interceptor source's snapshot at startup and then every `provider_profile_source_refresh_interval_seconds` (default 10), and serves profile reads from that copy. When the snapshot revision changes, the gateway pushes new configuration to sandboxes that receive it over their supervisor session. If refreshes keep failing, the gateway serves the last snapshot for up to three intervals, then fails reads that need the catalog with `UNAVAILABLE` until a refresh succeeds.
507+
The gateway fetches each interceptor source's snapshot at startup and then every 10 seconds, and serves profile reads from that copy. When the snapshot revision changes, the gateway pushes new configuration to sandboxes that receive it over their supervisor session. If refreshes keep failing, the gateway serves the last snapshot for up to 30 seconds, then fails reads that need the catalog with `UNAVAILABLE` until a refresh succeeds.
510508

511509
`failure_policy` accepts `fail_closed` or `fail_open`. `timeout` accepts `ms` and `s` suffixes. In `dynamic` mode, binding overrides may select a manifest binding by `id`, `rpc`, or `service` plus `method`; they can disable a binding, narrow its phases, or override its failure policy.
512510

0 commit comments

Comments
 (0)