config: Overrides for system and user scopes#26735
Conversation
e90e73c to
aa389f6
Compare
|
FWIW, I'm all for this. Admittedly I would prefer that it go further, especially making it possible to make a spack self-contained with a file on disk, but any step in this direction seems like a good one to me. |
|
I've been submitting pull requests for several years about this issue and would be happy to see something done about it. I haven't understood the reluctance of the Spack team to make the user config path overridable by an environment variable - this is a defector standard way of customizing applications in the Linux/HPC worlds. I've got two comments on this specific PR:
|
Please read the first paragraph, the PR is simple to get it in, hopefully before 0.17 branches off, for which the window is narrowing. Adding
See the reply above, there are plans to gradually get rid of all the spack globals and put them in some config/context object, which allows us to do unit testing of its initialization without side effects. Your test works too and is side effect free but starting a python subprocess was again something I feared would spark discussion blocking the actual contribution. Unit testing |
|
Thanks for the reply @haampie - I'll just register my opinion that I think pulling in I still maintain this fork of spack and many dozen users at Sandia use it - once this issue is resolved we will all happily ditch the fork and use the mainline spack. |
|
Calling it a step back is not helpful if you really want something along these lines to be merged. And it really is not, cause: (a) it's enabling you to opt out of For further discussion please resort to #12892. |
aa389f6 to
5e4f648
Compare
Spack's `system` and `user` scopes provide ways for administrators and
users to set global defaults for all Spack instances, but for use cases
where one wants a clean Spack installation, these scopes can be undesirable.
For example, users may want to opt out of global system configuration, or
they may want to ignore their own home directory settings when running in
a continuous integration environment.
Spack also, by default, keeps various caches and user data in `~/.spack`,
but users may want to override these locations.
Spack provides three environment variables that allow you to override or
opt out of configuration locations:
* `SPACK_USER_CONFIG_PATH`: Override the path to use for the
`user` (`~/.spack`) scope.
* `SPACK_SYSTEM_CONFIG_PATH`: Override the path to use for the
`system` (`/etc/spack`) scope.
* `SPACK_DISABLE_LOCAL_CONFIG`: set this environment variable to completely
disable *both* the system and user configuration directories. Spack will
only consider its own defaults and `site` configuration locations.
And one that allows you to move the default cache location:
* `SPACK_USER_CACHE_PATH`: Override the default path to use for user data
(misc_cache, tests, reports, etc.)
With these settings, if you want to isolate Spack in a CI environment, you can do this:
export SPACK_DISABLE_LOCAL_CONFIG=true
export SPACK_USER_CACHE_PATH=/tmp/spack
This is a stop-gap approach until we have figured out how to deal with
the system and user config scopes more generally, as there are plans to
potentially / eventually get rid of them.
**User config**
Spack is a bit of a pain when you have:
- a shared $HOME folder across different systems.
- multiple Spack versions on the same system.
**System config**
- On shared systems with a versioned programming environment / toolkit,
system administrators want to provide config for each version (e.g.
21.09, 21.10) of the programming environment, and the user Spack
instance should be able to pick this up without a steep learning
curve.
- On shared systems the user should be able to opt out of the
hard-coded config scope in /etc/spack, since it may be incompatible
with their particular instance. Currently Spack can only opt out of all
config scopes through overrides with `"config:":`, `"packages:":`, but that
also drops the defaults config, which would have to be repeated, which
is undesirable, especially the lengthy packages.yaml.
An example use case is: having config in this folder:
```
/path/to/programming/environment/{version}/{compilers,packages}.yaml
```
and have `module load spack-system-config` set the variable
```
SPACK_SYSTEM_CONFIG_PATH=/path/to/programming/environment/{version}
```
where the user no longer has to worry about what `{version}` they are
on.
**Continuous integration**
Finally, there is the use case of continuous integration, which may
clone an arbitrary Spack version, which optimally should not pick up
system or user config from the previous run (like may happen in
classical bare metal non-containerized filesystem side effect ridden
jenkins pipelines). In fact this is very similar to how spack itself
tries to avoid picking up system dependencies during builds...
**But environments solve this?**
- You could do `include`s in environment files to get similar behavior
to the spack_system_config_path example, but environments require you
to:
1) require paths to individual config files, not directories.
2) fail if the listed config file does not exist
- They allow you to override config scopes, but this is generally too
rigurous, as it requires you to repeat the default config, in
particular packages.yaml, and just defies the point of layered config.
Co-authored-by: Tom Scogland <[email protected]>
Co-authored-by: Tim Fuller <[email protected]>
Co-authored-by: Steve Leak <[email protected]>
Co-authored-by: Todd Gamblin <[email protected]>
109e35e to
5d66b08
Compare
|
github actions doesn't want it to be merged, maybe just drop the pr? same issue in another pr of mine |
|
It’s done y’all! |
|
yay |
|
So I tested this out while also linking So there are still bits that want to touch |
|
@mathstuf Did you use both SPACK_DISABLE_LOCAL_CONFIG and SPACK_USER_CACHE_PATH? If you don’t use the latter, caches like bootstrap store will still default to the home directory. |
|
Yep: SPACK_USER_CACHE_PATH: "$GIT_CLONE_PATH/.gitlab/spack-cache"
SPACK_DISABLE_LOCAL_CONFIG: "true" |
|
So, this is because This means that you still have to override all config settings that use I think the better solution now is to get rid of Instead stick to |
|
@mathstuf: can you send a debug trace for the failure you mentioned above? (run with Do you refer to |
|
My guess would be it's this biting us: https://github.com/spack/spack/pull/26735/files#diff-24ac473c44f26728fd3da17d5dd741c4073fa0d8aec651971c2aaf7d17747c9fR7 That still needs to go somewhere, probably fall back to the next config scope like the rest of spack does? |
I'll try and get a run with this in.
Not that I know of. The entirety of the Spack on the machine (besides the Spack setup scriptEnvironment: SPACK_USER_CACHE_PATH: "$GIT_CLONE_PATH/.gitlab/spack-cache"
SPACK_DISABLE_LOCAL_CONFIG: "true"#!/bin/sh
set -e
readonly spackroot="$CI_PROJECT_DIR/.gitlab/spack"
# Clone Spack itself.
git clone --depth 1 https://github.com/spack/spack "$spackroot/src"
export SPACK_ROOT="$spackroot/src"
export PATH="$PATH:$SPACK_ROOT/bin"
# Search for the compiler.
spack compiler find
# Clone mochi package repository.
git clone --depth 1 https://github.com/mochi-hpc/mochi-spack-packages "$spackroot/mochi"
# Add mochi repo to Spack.
spack repo add "$spackroot/mochi"
# Inject CI tools to avoid builds.
mkdir -p "$spackroot/config"
cat > "$spackroot/config/packages.yaml" <<EOF
packages:
all:
target: [$( uname -m )]
cmake:
buildable: false
externals:
- spec: cmake@$( cmake --version | head -n1 | cut -d' ' -f3 )
prefix: $CI_PROJECT_DIR/.gitlab/cmake
EOF
readonly spec="mochi-thallium@main^libfabric fabrics=tcp,rxm"
# Install thallium.
spack -C "$spackroot/config" install $spec
# Clean up the directory.
spack -C "$spackroot/config" clean |
There were some loose ends left in ##26735 that cause errors when using `SPACK_DISABLE_LOCAL_CONFIG`. - [x] Fix hard-coded `~/.spack` references in `install_test.py` and `monitor.py` Also, if `SPACK_DISABLE_LOCAL_CONFIG` is used, there is the issue that `$user_config_path`, when used in configuration files, makes no sense, because there is no user config scope. Since we already have `$user_cache_path` in configuration files, and since there really shouldn't be *any* data stored in a configuration scope (which is what you'd configure in `config.yaml`/`bootstrap.yaml`/etc., this just removes `$user_config_path`. There will *always* be a `$user_cache_path`, as Spack needs to write files, but we shouldn't rely on the existence of a particular configuration scope in the Spack code, as scopes are configurable, both in number and location. - [x] Remove `$user_config_path` substitution. - [x] Fix reference to `$user_config_path` in `etc/spack/deaults/bootstrap.yaml` to refer to `$user_cache_path`, which is where it was intended to be.
There were some loose ends left in ##26735 that cause errors when using `SPACK_DISABLE_LOCAL_CONFIG`. - [x] Fix hard-coded `~/.spack` references in `install_test.py` and `monitor.py` Also, if `SPACK_DISABLE_LOCAL_CONFIG` is used, there is the issue that `$user_config_path`, when used in configuration files, makes no sense, because there is no user config scope. Since we already have `$user_cache_path` in configuration files, and since there really shouldn't be *any* data stored in a configuration scope (which is what you'd configure in `config.yaml`/`bootstrap.yaml`/etc., this just removes `$user_config_path`. There will *always* be a `$user_cache_path`, as Spack needs to write files, but we shouldn't rely on the existence of a particular configuration scope in the Spack code, as scopes are configurable, both in number and location. - [x] Remove `$user_config_path` substitution. - [x] Fix reference to `$user_config_path` in `etc/spack/deaults/bootstrap.yaml` to refer to `$user_cache_path`, which is where it was intended to be.
…27022) There were some loose ends left in ##26735 that cause errors when using `SPACK_DISABLE_LOCAL_CONFIG`. - [x] Fix hard-coded `~/.spack` references in `install_test.py` and `monitor.py` Also, if `SPACK_DISABLE_LOCAL_CONFIG` is used, there is the issue that `$user_config_path`, when used in configuration files, makes no sense, because there is no user config scope. Since we already have `$user_cache_path` in configuration files, and since there really shouldn't be *any* data stored in a configuration scope (which is what you'd configure in `config.yaml`/`bootstrap.yaml`/etc., this just removes `$user_config_path`. There will *always* be a `$user_cache_path`, as Spack needs to write files, but we shouldn't rely on the existence of a particular configuration scope in the Spack code, as scopes are configurable, both in number and location. - [x] Remove `$user_config_path` substitution. - [x] Fix reference to `$user_config_path` in `etc/spack/deaults/bootstrap.yaml` to refer to `$user_cache_path`, which is where it was intended to be.
Closes #11919.
Closes #11951.
Closes #13057.
Closes #12892.
Closes #26341.
Closes #23760.
Closes #23596.
Closes #25547.
Closes #26833.
Short story:
This PR is the effective minimal and hopefully least controversial changeset to
address common complaints voiced many times on Slack and Github about
hard-coded config paths in Spack without a way to opt out.
Pinging @trws, @healther, @tjfulle, @jw500, @sleak-lbl, @bartlettroscoe, @dremerb,
@huqy, @eugeneswalker, @mathstuf, @mpbelhorn, @mamelara, @marcmengel who
all contributed to issues and prs addressing something along these lines.
It makes it possible for the user to change the default location of
the user config
~/.spackand system config/etc/spackfolders.This is a stop-gap approach until we have figured out how to deal with
the system and user config scopes more generally, as there are plans to
potentially / eventually get rid of them.
Why make this change?
User config
Spack is a bit of a pain when you have:
System config
system administrators want to provide config for each version (e.g.
21.09, 21.10) of the programming environment, and the user Spack
instance should be able to pick this up without a steep learning
curve.
hard-coded config scope in /etc/spack, since it may be incompatible with their
particular instance. Currently Spack can only opt out of all config
scopes through overrides with
"config:":,"packages:":, but thatalso drops the defaults config, which would have to be repeated, which
is undesirable, especially the lengthy packages.yaml.
An example use case is: having config in this folder:
and have
module load spack-system-configset the variablewhere the user no longer has to worry about what
{version}they areon.
Continuous integration
Finally, there is the use case of continuous integration, which may
clone an arbitrary Spack version, which optimally should not pick up
system or user config from the previous run (like may happen in
classical bare metal non-containerized filesystem stateful
jenkins pipelines). In fact this is very similar to how spack itself
tries to avoid picking up system dependencies during builds...
But environments solve this?
includes in environment files to get similar behaviorto the spack_system_config_path example, but environments
rigorous, as it requires you to repeat the default config, in
particular packages.yaml, and just defies the point of layered config.