From a04e33ceb638a3ee5fef8d642b57ffc3a4543c98 Mon Sep 17 00:00:00 2001 From: Tristan Partin Date: Wed, 9 Apr 2025 17:39:54 -0500 Subject: [PATCH] Remove --spec-json argument from compute_ctl (#11510) It isn't used by the production control plane or neon_local. The removal simplifies compute spec logic just a little bit more since we can remove any notion of whether we should allow live reconfigurations. Signed-off-by: Tristan Partin --- compute_tools/src/bin/compute_ctl.rs | 28 +++++++--------------- compute_tools/src/compute.rs | 14 ----------- compute_tools/src/http/routes/configure.rs | 7 ------ 3 files changed, 9 insertions(+), 40 deletions(-) diff --git a/compute_tools/src/bin/compute_ctl.rs b/compute_tools/src/bin/compute_ctl.rs index da11ac2860..4796a07d92 100644 --- a/compute_tools/src/bin/compute_ctl.rs +++ b/compute_tools/src/bin/compute_ctl.rs @@ -118,16 +118,18 @@ struct Cli { #[arg(long)] pub set_disk_quota_for_fs: Option, - #[arg(short = 's', long = "spec", group = "spec")] - pub spec_json: Option, - #[arg(short = 'S', long, group = "spec-path")] pub spec_path: Option, #[arg(short = 'i', long, group = "compute-id")] pub compute_id: String, - #[arg(short = 'p', long, conflicts_with_all = ["spec", "spec-path"], value_name = "CONTROL_PLANE_API_BASE_URL")] + #[arg( + short = 'p', + long, + conflicts_with = "spec-path", + value_name = "CONTROL_PLANE_API_BASE_URL" + )] pub control_plane_uri: Option, } @@ -172,7 +174,6 @@ fn main() -> Result<()> { cgroup: cli.cgroup, #[cfg(target_os = "linux")] vm_monitor_addr: cli.vm_monitor_addr, - live_config_allowed: cli_spec.live_config_allowed, }, cli_spec.spec, cli_spec.compute_ctl_config, @@ -201,23 +202,12 @@ async fn init() -> Result<()> { } fn try_spec_from_cli(cli: &Cli) -> Result { - // First, try to get cluster spec from the cli argument - if let Some(ref spec_json) = cli.spec_json { - info!("got spec from cli argument {}", spec_json); - return Ok(CliSpecParams { - spec: Some(serde_json::from_str(spec_json)?), - compute_ctl_config: ComputeCtlConfig::default(), - live_config_allowed: false, - }); - } - - // Second, try to read it from the file if path is provided + // First, read spec from the path if provided if let Some(ref spec_path) = cli.spec_path { let file = File::open(Path::new(spec_path))?; return Ok(CliSpecParams { spec: Some(serde_json::from_reader(file)?), compute_ctl_config: ComputeCtlConfig::default(), - live_config_allowed: true, }); } @@ -225,11 +215,12 @@ fn try_spec_from_cli(cli: &Cli) -> Result { panic!("must specify --control-plane-uri"); }; + // If the spec wasn't provided in the CLI arguments, then retrieve it from + // the control plane match get_spec_from_control_plane(cli.control_plane_uri.as_ref().unwrap(), &cli.compute_id) { Ok(resp) => Ok(CliSpecParams { spec: resp.0, compute_ctl_config: resp.1, - live_config_allowed: true, }), Err(e) => { error!( @@ -247,7 +238,6 @@ struct CliSpecParams { spec: Option, #[allow(dead_code)] compute_ctl_config: ComputeCtlConfig, - live_config_allowed: bool, } fn deinit_and_exit(exit_code: Option) -> ! { diff --git a/compute_tools/src/compute.rs b/compute_tools/src/compute.rs index 9dfcde1dbc..ad8925e7ab 100644 --- a/compute_tools/src/compute.rs +++ b/compute_tools/src/compute.rs @@ -93,20 +93,6 @@ pub struct ComputeNodeParams { /// the address of extension storage proxy gateway pub ext_remote_storage: Option, - - /// We should only allow live re- / configuration of the compute node if - /// it uses 'pull model', i.e. it can go to control-plane and fetch - /// the latest configuration. Otherwise, there could be a case: - /// - we start compute with some spec provided as argument - /// - we push new spec and it does reconfiguration - /// - but then something happens and compute pod / VM is destroyed, - /// so k8s controller starts it again with the **old** spec - /// - /// and the same for empty computes: - /// - we started compute without any spec - /// - we push spec and it does configuration - /// - but then it is restarted without any spec again - pub live_config_allowed: bool, } /// Compute node info shared across several `compute_ctl` threads. diff --git a/compute_tools/src/http/routes/configure.rs b/compute_tools/src/http/routes/configure.rs index 3c5a6a6d41..f7a19da611 100644 --- a/compute_tools/src/http/routes/configure.rs +++ b/compute_tools/src/http/routes/configure.rs @@ -22,13 +22,6 @@ pub(in crate::http) async fn configure( State(compute): State>, request: Json, ) -> Response { - if !compute.params.live_config_allowed { - return JsonResponse::error( - StatusCode::PRECONDITION_FAILED, - "live configuration is not allowed for this compute node".to_string(), - ); - } - let pspec = match ParsedSpec::try_from(request.spec.clone()) { Ok(p) => p, Err(e) => return JsonResponse::error(StatusCode::BAD_REQUEST, e),