From 8feebe6c0a5c3b150c8d8e203006d777ddadced8 Mon Sep 17 00:00:00 2001 From: Kate Goldenring Date: Tue, 3 Dec 2024 16:06:03 -0800 Subject: [PATCH] fix: enable configuring state_dir with runtime configuration Signed-off-by: Kate Goldenring --- containerd-shim-spin/src/constants.rs | 2 -- containerd-shim-spin/src/trigger.rs | 14 +++++--------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/containerd-shim-spin/src/constants.rs b/containerd-shim-spin/src/constants.rs index 81d13569..7be5fc4a 100644 --- a/containerd-shim-spin/src/constants.rs +++ b/containerd-shim-spin/src/constants.rs @@ -21,5 +21,3 @@ pub(crate) const SPIN_TRIGGER_WORKING_DIR: &str = "/"; /// Defines the subset of application components that should be executable by the shim /// If empty or DNE, all components will be supported pub(crate) const SPIN_COMPONENTS_TO_RETAIN_ENV: &str = "SPIN_COMPONENTS_TO_RETAIN"; -/// The default state directory for the triggers. -pub(crate) const SPIN_DEFAULT_STATE_DIR: &str = ".spin"; diff --git a/containerd-shim-spin/src/trigger.rs b/containerd-shim-spin/src/trigger.rs index f2c736c7..76784f04 100644 --- a/containerd-shim-spin/src/trigger.rs +++ b/containerd-shim-spin/src/trigger.rs @@ -1,9 +1,4 @@ -use std::{ - collections::HashSet, - future::Future, - path::{Path, PathBuf}, - pin::Pin, -}; +use std::{collections::HashSet, future::Future, path::Path, pin::Pin}; use log::info; use spin_app::{locked::LockedApp, App}; @@ -19,7 +14,7 @@ use trigger_command::CommandTrigger; use trigger_mqtt::MqttTrigger; use trigger_sqs::SqsTrigger; -use crate::constants::{RUNTIME_CONFIG_PATH, SPIN_DEFAULT_STATE_DIR, SPIN_TRIGGER_WORKING_DIR}; +use crate::constants::{RUNTIME_CONFIG_PATH, SPIN_TRIGGER_WORKING_DIR}; pub(crate) const HTTP_TRIGGER_TYPE: &str = >::TYPE; pub(crate) const REDIS_TRIGGER_TYPE: &str = >::TYPE; @@ -54,11 +49,12 @@ fn factors_config() -> FactorsConfig { .then(|| RUNTIME_CONFIG_PATH.into()); // Configure the application state directory path. This is used in the default // locations for logs, key value stores, etc. - let state_dir = PathBuf::from(SPIN_TRIGGER_WORKING_DIR).join(SPIN_DEFAULT_STATE_DIR); FactorsConfig { working_dir: SPIN_TRIGGER_WORKING_DIR.into(), runtime_config_file, - state_dir: UserProvidedPath::Provided(state_dir), + // This is the default base for the state_dir (.spin) unless it is + // explicitly configured via the runtime config. + local_app_dir: Some(SPIN_TRIGGER_WORKING_DIR.to_string()), // Explicitly do not set log dir in order to force logs to be displayed to stdout. // Otherwise, would default to the state directory. log_dir: UserProvidedPath::Unset,