-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
add new localstack filesystem hierarchy #6302
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
Conversation
470db1c
to
f19873e
Compare
496da12
to
0700176
Compare
0700176
to
3e91e7b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While there are still a few failing tests and some small open questions, the changes look great. It's nice to see that we are finally migrating to a properly defined directory structure! 🥳
config.dirs.mkdirs() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above: Is this necessary? It seems to be done implicitly when loading the config.py
for most cases.
@@ -59,6 +60,7 @@ def install(package, parallel): | |||
""" | |||
console.print(f"resolving packages: {package}") | |||
installers: Dict[str, Callable] = InstallerManager().get_installers() | |||
config.dirs.mkdirs() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary? It seems to be done implicitly when loading the config.py
for most cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above, but with install
being a special case where we want the directory creation outside the runtime (although that's not clean behavior)
functions=f"{DEFAULT_VOLUME_DIR}/tmp", # FIXME: remove - this was misconceived | ||
data=f"{DEFAULT_VOLUME_DIR}/data", | ||
logs=f"{DEFAULT_VOLUME_DIR}/logs", | ||
config="/etc/localstack/conf.d", # for future use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What exactly will the future use of the config directory be? Currently, we use it to define config profiles which are only used by the CLI. With this change, the config directly in the container will be empty (since nothing will mount to /etc/localstack
for now). I also think it might be a bit confusing having an unused config dir and the CONFIG_DIR
env (where both of them would have different semantics).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fair point. i think the confusion in general comes from the conflation of a) CLI config with b) runtime config in container mode, and c) runtime config in host mode. part of what this PR addresses is the clearer separation of those. CONFIG_DIR
is purely a CLI option that holds configuration for the CLI (which in turn again can manipulate localstack config). however, there's a case for using custom configurations without the CLI.
3e91e7b
to
602c478
Compare
c035895
to
3c1bcd8
Compare
3c1bcd8
to
7b44a96
Compare
looks like there's still a quirk in the pro tests. created an ext PR and test run here: https://github.com/localstack/localstack/actions/runs/2544647881 |
looks good now: https://github.com/localstack/localstack/runs/7012412322 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 especially for having config.dirs.tmp
ephemeral! It saves quite some if
in the pods codebase.
0677e3a
to
a912b2f
Compare
a912b2f
to
41f5006
Compare
This PR finalizes the changes to the filesystem hierarchy we started in #5011 and introduces a semantically well-defined filesystem hierarchy for the localstack system. It cleanly separates directories created on the host (for CLI users or docker users mounting directories into the container), from the filesystem hierarchy in localstack. For host mode, we now use
./.filesystem
as filesystem root. The changes can be disabled by settingLEGACY_DIRECTORIES=1
.LocalStack filesystem hierarchy
The hierarchy inside the container will be as follows:
/var/lib/localstack
: the main localstack volume that stores data across localstack runs, this is what user's are interested in/var/lib/localstack/lib
: variable packages (like lazy-loaded third-party dependencies, also referred to asvar_libs
)/var/lib/localstack/logs
: logs of the recent localstack run/var/lib/localstack/state
: persistent state of third-party services (or what we sometimes call "data" or "assets", e.g., opensearch cluster data)/var/lib/localstack/tmp
: temporary data that does not survive localstack runs (is cleared when localstack starts)/var/lib/localstack/cache
: temporary data that survives localstack runs (is not cleared when localstack starts)/usr/lib/localstack
: static third-party packages installed into the container images. this was previously "localstack/infra", and is also referred to asstatic_libs
/etc/localstack
: 🚧 localstack configuration dir (for future use, currently not in use)/etc/localstack/conf.d
: localstack configuration overwrites/etc/localstack/init/
: localstack initialization hooksUser experience
From a user perspective, it should be similar to the mariadb and other database containers, where you mount a local directory into
/var/lib/localstack
, which persist all the data required across localstack runs.Currently this is achieved by this line:
localstack/docker-compose.yml
Lines 21 to 22 in 6d5671a
Users only need to change that to
/my/local/localstack/volume:/var/lib/localstack
, where the host path could still be/tmp/localstack
.DATA_DIR
andHOST_TMP_FOLDER
are no longer used:DATA_DIR
points implicitly to/my/local/localstack/volume/state
. if you want to use persistence, setPERSISTENCE=1
. if you setDATA_DIR
, then we have a deprecation path that we log a warning thatDATA_DIR
is ignored, butPERSISTENCE
is set to 1HOST_TMP_FOLDER
is determined by inspecting the volume mounts and using the source of the bind mount to/var/lib/localstack
.what they will see is something like this:
CLI users
Previously, each path was individually configurable (like
DATA_DIR
,VAR_LIBS
,STATIC_LIBS
, etc..). this is no longer supported or needed. the only variable that needs to be set isLOCALSTACK_VOLUME_DIR
, which is essentially turns into the docker flag-v ${LOCALSTACK_VOLUME_DIR}:/var/lib/localstack
. by default,LOCALSTACK_VOLUME_DIR=/tmp/localstack
, but that could change to~/.cache/localstack/volume
(~/.cache/localstack is also associated with the CLI
)Developer experience (host mode)
when running in host mode, we don't want to use
/usr/lib/localstack
or/var/lib/localstack
, etc on the host, since those are associated with the system and root permissions. instead, we simply move the filesystem hierarchy root to the environment variableFILESYSTEM_ROOT
, which is by default./.filesystem
(from the localstack project root).the hierarchy will look something like this (from the localstack project root):
Developer experience (building)
When building the docker image, we need to do some installation prep of third-party libraries on the host before invoking
docker build
.We piggy-back on the host-mode
.filesystem
directory, and simplyADD .filesystem/usr/lib/localstack /usr/lib/localstack
.This is not great IMO because it mixes concerns (host mode runtime with build time dependency management), but this is also they way it works right now.
PR Changes
Rundown of major changes:
/tmp/localstack
but/var/lib/localstack
, so/tmp/localstack:/tmp/localstack
volume mounts need to change to/tmp/localstack:/var/lib/localstack
config.dirs.tmp
is now cleared on every startup and shutdown/usr/lib/localstack
(./.filesystem/usr/lib/localstack
in host mode or when runningmake init
)/var/lib/localstack/libs
config.dirs.function
dir is no longer needed. it was conceived at the time as a directory in the container where lambda code goes (instead oftmp
), but was later used as config variable to hold theHOST_TMP_PATH
, which is not needed (since we are inspecting the container now to find the value)LEGACY_DIRECTORIES
that can be activated as feature flag to enable to old modeconfig.dirs.cache
so downloaded archives are kept in case installation was incompleteRundown of other changes
/opt/code/localstack/localstack/infra
->/usr/lib/localstack
for backwards compatibility/tmp/localstack_infra.log
to/var/lib/localstack/logs
, but create symlinks to not break peoples codeLimitations and future work
data_store = config.dirs.data or config.dirs.tmp
, these should slowly be migrated to simply useconfig.dirs.data
(which will point to a temporary directory ifPERSISTENCE=0
), or use theconfig.PERSISTENCE
flag if they want to setdata_store
(or whatever they are using) toNone
.var_libs
andstatic_libs
still have no structure to them, I think we should introduce some well defined package index (likesite-packages
,node_modules
, or maven's.m2
)