Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: configure Spin state dir #218

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions containerd-shim-spin/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ 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";
18 changes: 15 additions & 3 deletions containerd-shim-spin/src/trigger.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
use std::{collections::HashSet, future::Future, path::Path, pin::Pin};
use std::{
collections::HashSet,
future::Future,
path::{Path, PathBuf},
pin::Pin,
};

use log::info;
use spin_app::{locked::LockedApp, App};
use spin_runtime_factors::{FactorsBuilder, TriggerFactors};
use spin_trigger::{
cli::{FactorsConfig, TriggerAppBuilder},
cli::{FactorsConfig, TriggerAppBuilder, UserProvidedPath},
loader::ComponentLoader,
Trigger,
};
Expand All @@ -14,7 +19,7 @@ use trigger_command::CommandTrigger;
use trigger_mqtt::MqttTrigger;
use trigger_sqs::SqsTrigger;

use crate::constants::{RUNTIME_CONFIG_PATH, SPIN_TRIGGER_WORKING_DIR};
use crate::constants::{RUNTIME_CONFIG_PATH, SPIN_DEFAULT_STATE_DIR, SPIN_TRIGGER_WORKING_DIR};

pub(crate) const HTTP_TRIGGER_TYPE: &str = <HttpTrigger as Trigger<TriggerFactors>>::TYPE;
pub(crate) const REDIS_TRIGGER_TYPE: &str = <RedisTrigger as Trigger<TriggerFactors>>::TYPE;
Expand Down Expand Up @@ -47,9 +52,16 @@ fn factors_config() -> FactorsConfig {
let runtime_config_file = Path::new(RUNTIME_CONFIG_PATH)
.exists()
.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),
// 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,
..Default::default()
}
}
Expand Down
Loading