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: enable configuring state_dir with runtime configuration #241

Conversation

kate-goldenring
Copy link
Collaborator

@kate-goldenring kate-goldenring commented Dec 4, 2024

Instead of fixing the state_dir, we can set the local_app_dir which is a fallback if the state_dir is not set in runtime config like so:

state_dir = "/Path/to/state-dir/

Walk through

I confirmed this fix works with the following steps using a simple TODO app that creates a SQLite DB in the state store:

$ git clone [email protected]:rylev/spin-todo.git
$ cd spin-todo
# create a directory for the state store
$ mkdir foo
# configure the state dir in runtime config -- note, app root is at `/` so no volume mount needed
$ echo state_dir=\"/.configured" > runtime-config.toml
$ spin build
$ spin registry push ttl.sh/spin-sqlite-todo-123:48h 
$ spin kube scaffold --from ttl.sh/spin-sqlite-todo-123:48h --replicas 1 --runtime-config-file _scratch/runtime-config.toml | k apply -f -
# get container id
$ sudo crictl ps
# now use it to get process id (PID)
$ crictl inspect <container-id> | grep pid
12345
# ensure the SQLite DB is under the configured state dir
$ ls /proc/12345/root/.configured
sqlite_db.db

If runtime config is not set -- uses default state_dir of .spin at /

$ sudo ls /proc/12345/root/.spin
sqlite_db.db

@kate-goldenring kate-goldenring force-pushed the configuring-state-dir-with-runtime-config branch from 57b5c15 to f0ddeba Compare December 4, 2024 18:36
@kate-goldenring kate-goldenring force-pushed the configuring-state-dir-with-runtime-config branch from f0ddeba to 8feebe6 Compare December 4, 2024 18:38
@kate-goldenring kate-goldenring marked this pull request as ready for review December 4, 2024 18:38
Copy link
Member

@Mossaka Mossaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Mossaka Mossaka merged commit d6aabf2 into spinkube:main Dec 4, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants