Skip to content

Commit e694770

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

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
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: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
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};
510
use spin_runtime_factors::{FactorsBuilder, TriggerFactors};
611
use spin_trigger::{
7-
cli::{FactorsConfig, TriggerAppBuilder},
12+
cli::{FactorsConfig, TriggerAppBuilder, UserProvidedPath},
813
loader::ComponentLoader,
914
Trigger,
1015
};
@@ -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,16 @@ 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: UserProvidedPath::Provided(state_dir),
62+
// Explicitly do not set log dir in order to force logs to be displayed to stdout.
63+
// Otherwise, would default to the state directory.
64+
log_dir: UserProvidedPath::Unset,
5365
..Default::default()
5466
}
5567
}

0 commit comments

Comments
 (0)