From b0e3edda2efd3543338d07aa3f722670f0f768e6 Mon Sep 17 00:00:00 2001 From: John Spray Date: Thu, 9 May 2024 10:05:30 +0100 Subject: [PATCH] convenience ocmmand for setting threshold eviction --- Cargo.lock | 1 + control_plane/storcon_cli/Cargo.toml | 1 + control_plane/storcon_cli/src/main.rs | 52 +++++++++++++++++++++++++-- 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 85a59ec0ed..a194f2e301 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5774,6 +5774,7 @@ dependencies = [ "anyhow", "clap", "comfy-table", + "humantime", "hyper 0.14.26", "pageserver_api", "pageserver_client", diff --git a/control_plane/storcon_cli/Cargo.toml b/control_plane/storcon_cli/Cargo.toml index 61eb7fa4e4..ed3462961f 100644 --- a/control_plane/storcon_cli/Cargo.toml +++ b/control_plane/storcon_cli/Cargo.toml @@ -9,6 +9,7 @@ license.workspace = true anyhow.workspace = true clap.workspace = true comfy-table.workspace = true +humantime.workspace = true hyper.workspace = true pageserver_api.workspace = true pageserver_client.workspace = true diff --git a/control_plane/storcon_cli/src/main.rs b/control_plane/storcon_cli/src/main.rs index 1ce87613d0..9942bd519d 100644 --- a/control_plane/storcon_cli/src/main.rs +++ b/control_plane/storcon_cli/src/main.rs @@ -8,8 +8,9 @@ use pageserver_api::{ TenantDescribeResponse, TenantPolicyRequest, }, models::{ - LocationConfigSecondary, ShardParameters, TenantConfig, TenantConfigRequest, - TenantCreateRequest, TenantShardSplitRequest, TenantShardSplitResponse, + EvictionPolicy, EvictionPolicyLayerAccessThreshold, LocationConfigSecondary, + ShardParameters, TenantConfig, TenantConfigRequest, TenantCreateRequest, + TenantShardSplitRequest, TenantShardSplitResponse, }, shard::{ShardStripeSize, TenantShardId}, }; @@ -136,6 +137,14 @@ enum Command { #[arg(long)] tenant_id: TenantId, }, + TenantSetTimeBasedEviction { + #[arg(long)] + tenant_id: TenantId, + #[arg(long)] + period: humantime::Duration, + #[arg(long)] + threshold: humantime::Duration, + }, } #[derive(Parser)] @@ -724,6 +733,45 @@ async fn main() -> anyhow::Result<()> { }) .await?; } + Command::TenantSetTimeBasedEviction { + tenant_id, + period, + threshold, + } => { + vps_client + .tenant_config(&TenantConfigRequest { + tenant_id, + config: TenantConfig { + checkpoint_distance: None, + checkpoint_timeout: None, + compaction_target_size: None, + compaction_period: None, + compaction_threshold: None, + compaction_algorithm: None, + gc_horizon: None, + gc_period: None, + image_creation_threshold: None, + pitr_interval: None, + walreceiver_connect_timeout: None, + lagging_wal_timeout: None, + max_lsn_wal_lag: None, + trace_read_requests: None, + eviction_policy: Some(EvictionPolicy::LayerAccessThreshold( + EvictionPolicyLayerAccessThreshold { + period: period.into(), + threshold: threshold.into(), + }, + )), + min_resident_size_override: None, + evictions_low_residence_duration_metric_threshold: None, + heatmap_period: None, + lazy_slru_download: None, + timeline_get_throttle: None, + image_layer_creation_check_threshold: None, + }, + }) + .await?; + } } Ok(())