Skip to content

Commit b33bd24

Browse files
fix: configure Spin state dir
Signed-off-by: Kate Goldenring <[email protected]>
1 parent 71c8351 commit b33bd24

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

containerd-shim-spin/src/constants.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@ pub(crate) const SPIN_TRIGGER_WORKING_DIR: &str = "/";
2121
/// Defines the subset of application components that should be executable by the shim
2222
/// If empty or DNE, all components will be supported
2323
pub(crate) const SPIN_COMPONENTS_TO_RETAIN_ENV: &str = "SPIN_COMPONENTS_TO_RETAIN";
24+
/// The default state directory for the triggers.
25+
pub(crate) const SPIN_DEFAULT_STATE_DIR: &str = ".spin";

containerd-shim-spin/src/trigger.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
use std::{collections::HashSet, future::Future, path::Path, pin::Pin};
1+
use std::{
2+
collections::HashSet,
3+
future::Future,
4+
path::{Path, PathBuf},
5+
pin::Pin,
6+
};
27

38
use log::info;
49
use spin_app::{locked::LockedApp, App};
@@ -14,7 +19,7 @@ use trigger_command::CommandTrigger;
1419
use trigger_mqtt::MqttTrigger;
1520
use trigger_sqs::SqsTrigger;
1621

17-
use crate::constants::{RUNTIME_CONFIG_PATH, SPIN_TRIGGER_WORKING_DIR};
22+
use crate::constants::{RUNTIME_CONFIG_PATH, SPIN_DEFAULT_STATE_DIR, SPIN_TRIGGER_WORKING_DIR};
1823

1924
pub(crate) const HTTP_TRIGGER_TYPE: &str = <HttpTrigger as Trigger<TriggerFactors>>::TYPE;
2025
pub(crate) const REDIS_TRIGGER_TYPE: &str = <RedisTrigger as Trigger<TriggerFactors>>::TYPE;
@@ -47,9 +52,13 @@ fn factors_config() -> FactorsConfig {
4752
let runtime_config_file = Path::new(RUNTIME_CONFIG_PATH)
4853
.exists()
4954
.then(|| RUNTIME_CONFIG_PATH.into());
55+
// Configure the application state directory path. This is used in the default
56+
// locations for logs, key value stores, etc.
57+
let state_dir = PathBuf::from(SPIN_TRIGGER_WORKING_DIR).join(SPIN_DEFAULT_STATE_DIR);
5058
FactorsConfig {
5159
working_dir: SPIN_TRIGGER_WORKING_DIR.into(),
5260
runtime_config_file,
61+
state_dir: spin_trigger::cli::UserProvidedPath::Provided(state_dir),
5362
..Default::default()
5463
}
5564
}

0 commit comments

Comments
 (0)