Skip to content
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 changelog.d/+eessi-custom-override-isolation.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Clear the default and the configured target override variables of the European
Environment for Scientific Software Installations before starting a command.
3 changes: 2 additions & 1 deletion docs/orgmode/reference/environment.org
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ The keys of =[scheduler.env]= come first, and a variable of the table below with
For an EESSI command, =eb-pipeline= removes inherited EESSI installation-mode
variables and target overrides before setting the values in this table. An
unset =cpu_target= or =accel_target= therefore uses EESSI detection instead
of a value left by the calling shell.
of a value left by the calling shell. This clears the default EESSI override
names and a custom =cpu_override_var= or =accel_override_var=.
=[licences]= is on when its =enabled= and =enforce= are not =false=.
=EESSI= stands for the European Environment for Scientific Software Installations.

Expand Down
2 changes: 1 addition & 1 deletion docs/orgmode/reference/site-file.org
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ The module wrapper starts when =init= is not empty, =unuse_path= is =true= or =s
| =cpu_override_var= | string | =EESSI_SOFTWARE_SUBDIR_OVERRIDE= | The variable that carries the target's =cpu_target=. |
| =accel_override_var= | string | =EESSI_ACCELERATOR_TARGET_OVERRIDE= | The variable that carries the target's =accel_target=. |

With the table on, every command also gets =EESSI_SITE_SOFTWARE_PREFIX=, the target's install prefix, and =check= checks the form of each target's =cpu_target= and =accel_target=. Before it starts an EESSI command, =eb-pipeline= removes inherited EESSI target overrides, so an unset target value leaves detection to EESSI.
With the table on, every command also gets =EESSI_SITE_SOFTWARE_PREFIX=, the target's install prefix, and =check= checks the form of each target's =cpu_target= and =accel_target=. Before it starts an EESSI command, =eb-pipeline= removes inherited default and configured =cpu_override_var= and =accel_override_var= names, so an unset target value leaves detection to EESSI.

** =[caches]=

Expand Down
14 changes: 12 additions & 2 deletions src/audit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,12 @@ fn probe_target_env(
.collect();
let cmd = planner.plan_role_cmd(PHASE, inner)?;
let log_path = work.join("probe.log");
let code = exec_logged(&cmd, &planner.scope.env(), &log_path)?;
let code = exec_logged(
&cmd,
&planner.scope.env(),
&planner.scope.eessi_unset_env(),
&log_path,
)?;
let bytes = std::fs::read(&out).unwrap_or_default();
let _ = std::fs::remove_file(&out);
if code != 0 || bytes.is_empty() {
Expand Down Expand Up @@ -245,7 +250,12 @@ fn run_eb_stack(planner: &Planner<'_>, tail: &[String], log_path: &Path) -> Resu
let mut argv = vec![Tool::EbStack.bin(planner.scope.site)];
argv.extend(tail.iter().cloned());
let cmd = planner.plan_role_cmd(PHASE, argv)?;
let code = exec_logged(&cmd, &planner.scope.env(), log_path)?;
let code = exec_logged(
&cmd,
&planner.scope.env(),
&planner.scope.eessi_unset_env(),
log_path,
)?;
if code != 0 {
let exit_code = match code {
exit::USAGE => exit::USAGE,
Expand Down
23 changes: 22 additions & 1 deletion src/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::exit::Fail;
use crate::schema::*;
use crate::util::{package_of, split_args};
use serde_json::{json, Value};
use std::collections::BTreeMap;
use std::collections::{BTreeMap, BTreeSet};

/// A phase role: which launch arguments a command takes from
/// `[phase_defaults]` or the target's `phases`.
Expand Down Expand Up @@ -502,6 +502,27 @@ impl<'a> Scope<'a> {
e
}

/// EESSI variables removed from a child before its configured environment
/// is applied.
pub fn eessi_unset_env(&self) -> BTreeSet<String> {
let Some(es) = self.site.eessi_on() else {
return BTreeSet::new();
};
[
"EESSI_CVMFS_INSTALL".to_string(),
"EESSI_SITE_INSTALL".to_string(),
"EESSI_PROJECT_INSTALL".to_string(),
"EESSI_USER_INSTALL".to_string(),
"EESSI_ACCELERATOR_INSTALL".to_string(),
"EESSI_SOFTWARE_SUBDIR_OVERRIDE".to_string(),
"EESSI_ACCELERATOR_TARGET_OVERRIDE".to_string(),
es.cpu_override_var.clone(),
es.accel_override_var.clone(),
]
.into_iter()
.collect()
}

/// Environment added for one build list line.
pub fn line_env(&self, easyconfig: &str) -> BTreeMap<String, String> {
let (name, version) = package_of(easyconfig);
Expand Down
62 changes: 40 additions & 22 deletions src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,12 @@ struct Exec {

/// Run one command to completion with output in a log file. A signal that
/// arrives is forwarded to the child once.
fn exec(cmd: &Cmd, base_env: &BTreeMap<String, String>, log: &Path) -> Result<Exec, Fail> {
fn exec(
cmd: &Cmd,
base_env: &BTreeMap<String, String>,
unset_env: &BTreeSet<String>,
log: &Path,
) -> Result<Exec, Fail> {
if let Some(dir) = log.parent() {
std::fs::create_dir_all(dir).map_err(|e| {
Fail::new(
Expand All @@ -247,18 +252,8 @@ fn exec(cmd: &Cmd, base_env: &BTreeMap<String, String>, log: &Path) -> Result<Ex
.try_clone()
.map_err(|e| Fail::new(exit::FAILED, format!("cannot duplicate log handle: {e}")))?;
let mut c = Command::new(&cmd.argv[0]);
if base_env.contains_key("EESSI_SITE_SOFTWARE_PREFIX") {
for name in [
"EESSI_CVMFS_INSTALL",
"EESSI_SITE_INSTALL",
"EESSI_PROJECT_INSTALL",
"EESSI_USER_INSTALL",
"EESSI_SOFTWARE_SUBDIR_OVERRIDE",
"EESSI_ACCELERATOR_TARGET_OVERRIDE",
"EESSI_ACCELERATOR_INSTALL",
] {
c.env_remove(name);
}
for name in unset_env {
c.env_remove(name);
}
c.args(&cmd.argv[1..])
.envs(base_env)
Expand Down Expand Up @@ -324,9 +319,10 @@ fn exec(cmd: &Cmd, base_env: &BTreeMap<String, String>, log: &Path) -> Result<Ex
pub fn exec_logged(
cmd: &Cmd,
base_env: &BTreeMap<String, String>,
unset_env: &BTreeSet<String>,
log: &Path,
) -> Result<i32, Fail> {
exec(cmd, base_env, log).map(|e| e.code)
exec(cmd, base_env, unset_env, log).map(|e| e.code)
}

fn last_json_line(path: &Path) -> Option<String> {
Expand Down Expand Up @@ -671,9 +667,10 @@ impl State {
phase: &str,
cmd: &Cmd,
env: &BTreeMap<String, String>,
unset_env: &BTreeSet<String>,
log: &Path,
) -> Result<Exec, Fail> {
let ex = exec(cmd, env, log)?;
let ex = exec(cmd, env, unset_env, log)?;
*self.spent.entry(phase.to_string()).or_default() += ex.elapsed;
Ok(ex)
}
Expand All @@ -687,6 +684,7 @@ pub fn run(planner: &Planner, lines: &[ListLine], opts: &Options<'_>) -> RunResu
let site = p.scope.site;
let target = p.scope.target.name.clone();
let env = p.scope.env();
let unset_env = p.scope.eessi_unset_env();
let log_dir = PathBuf::from(p.scope.log_dir());
let mut st = State {
res: RunResult {
Expand Down Expand Up @@ -1000,7 +998,8 @@ pub fn run(planner: &Planner, lines: &[ListLine], opts: &Options<'_>) -> RunResu
}
Ok(cmd) => {
let hashes = resume::hashes_path(&p.scope.log_dir());
let ex = match st.exec("shard", &cmd, &env, &log_dir.join("order.log")) {
let ex = match st.exec("shard", &cmd, &env, &unset_env, &log_dir.join("order.log"))
{
Ok(e) => e,
Err(f) => {
st.res.message = Some(f.msg);
Expand Down Expand Up @@ -1104,7 +1103,8 @@ pub fn run(planner: &Planner, lines: &[ListLine], opts: &Options<'_>) -> RunResu
&target,
&format!("planning {} shards", sh.count),
);
let ex = match st.exec("shard", &cmd, &env, &log_dir.join("shard.log")) {
let ex = match st.exec("shard", &cmd, &env, &unset_env, &log_dir.join("shard.log"))
{
Ok(e) => e,
Err(f) => {
st.res.message = Some(f.msg);
Expand Down Expand Up @@ -1191,7 +1191,8 @@ pub fn run(planner: &Planner, lines: &[ListLine], opts: &Options<'_>) -> RunResu
&target,
&format!("planning {count} shards"),
);
let ex = match st.exec("shard", &cmd, &env, &log_dir.join("shard.log")) {
let ex = match st.exec("shard", &cmd, &env, &unset_env, &log_dir.join("shard.log"))
{
Ok(e) => e,
Err(f) => {
st.res.message = Some(f.msg);
Expand Down Expand Up @@ -1341,6 +1342,7 @@ pub fn run(planner: &Planner, lines: &[ListLine], opts: &Options<'_>) -> RunResu
"sources",
cmd,
&env,
&unset_env,
&log_dir.join(format!("offline-planner-{:02}.log", i + 1)),
) {
Ok(ex) => ex,
Expand Down Expand Up @@ -1389,6 +1391,7 @@ pub fn run(planner: &Planner, lines: &[ListLine], opts: &Options<'_>) -> RunResu
"sources",
&cmd,
&env,
&unset_env,
&log_dir.join(format!("{s}.fetch.log")),
) {
Ok(e) => e,
Expand Down Expand Up @@ -1545,6 +1548,7 @@ pub fn run(planner: &Planner, lines: &[ListLine], opts: &Options<'_>) -> RunResu
"admission",
&cmd,
&env,
&unset_env,
&log_dir.join(format!("admission-{}.{attempt}.log", u.name)),
) {
Ok(e) => e,
Expand Down Expand Up @@ -1672,7 +1676,7 @@ pub fn run(planner: &Planner, lines: &[ListLine], opts: &Options<'_>) -> RunResu
log("WARN", "build", &target, &format!("{s}: {w}"));
}
log("INFO", "build", &target, &format!("{s}: start"));
let ex = match st.exec("build", &cmd, &env, Path::new(&p.log_stdout(s))) {
let ex = match st.exec("build", &cmd, &env, &unset_env, Path::new(&p.log_stdout(s))) {
Ok(e) => e,
Err(f) => {
st.res.message = Some(f.msg);
Expand Down Expand Up @@ -1740,6 +1744,7 @@ pub fn run(planner: &Planner, lines: &[ListLine], opts: &Options<'_>) -> RunResu
"logs",
&kc,
&env,
&unset_env,
&log_dir.join(format!("{s}.keep-logs.log")),
);
match kx {
Expand Down Expand Up @@ -1801,7 +1806,13 @@ pub fn run(planner: &Planner, lines: &[ListLine], opts: &Options<'_>) -> RunResu
Ok(Some(cmd)) => {
if !st.failed && !st.refused && !st.pending {
log("INFO", "checks", &target, "start");
match st.exec("checks", &cmd, &env, &log_dir.join("checks.log")) {
match st.exec(
"checks",
&cmd,
&env,
&unset_env,
&log_dir.join("checks.log"),
) {
Ok(ex) => {
if ex.code == 0 {
st.phase("checks", "ok", Some(0), None);
Expand Down Expand Up @@ -1851,6 +1862,7 @@ pub fn run(planner: &Planner, lines: &[ListLine], opts: &Options<'_>) -> RunResu
"verification",
cmd,
&env,
&unset_env,
&log_dir.join(format!("verification-{}.log", index + 1)),
) {
Ok(ex) if ex.code == 0 => {
Expand Down Expand Up @@ -1901,7 +1913,13 @@ pub fn run(planner: &Planner, lines: &[ListLine], opts: &Options<'_>) -> RunResu
match p.cache_cmd() {
Ok(Some(cmd)) => {
log("INFO", "caches", &target, "start");
match st.exec("caches", &cmd, &env, &log_dir.join("caches.log")) {
match st.exec(
"caches",
&cmd,
&env,
&unset_env,
&log_dir.join("caches.log"),
) {
Ok(ex) => {
if ex.code == 0 {
st.phase("caches", "ok", Some(0), None);
Expand Down Expand Up @@ -1975,7 +1993,7 @@ pub fn run(planner: &Planner, lines: &[ListLine], opts: &Options<'_>) -> RunResu
p.rotate_cmd(false).ok().flatten().unwrap_or(cmd)
}
};
match st.exec("logs", &cmd, &env, &log_dir.join("rotate.log")) {
match st.exec("logs", &cmd, &env, &unset_env, &log_dir.join("rotate.log")) {
Ok(ex) => match map_rotate(ex.code) {
RotateOutcome::Ok => st.phase("logs", "ok", Some(0), note),
RotateOutcome::Locked => {
Expand Down
8 changes: 4 additions & 4 deletions src/watch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ pub fn probe(p: &Planner, work: &Path) -> Result<(Probe, BTreeMap<String, String
.collect();
let cmd = p.plan_role_cmd("watch", inner)?;
let log_path = work.join("eessi-probe.log");
let code = exec_logged(&cmd, &p.scope.env(), &log_path)?;
let code = exec_logged(&cmd, &p.scope.env(), &p.scope.eessi_unset_env(), &log_path)?;
let bytes = std::fs::read(&out).unwrap_or_default();
// The dump holds the whole environment, a webhook's URL among it, and
// the work directory can outlive the run.
Expand Down Expand Up @@ -402,7 +402,7 @@ pub fn rebuild_set(
];
let cmd = p.plan_role_cmd("watch", argv)?;
let log_path = work.join(format!("{name}.log"));
let code = exec_logged(&cmd, &p.scope.env(), &log_path)?;
let code = exec_logged(&cmd, &p.scope.env(), &p.scope.eessi_unset_env(), &log_path)?;
if code != 0 {
return Err(Fail::new(
exit::FAILED,
Expand Down Expand Up @@ -960,7 +960,7 @@ pub fn abi_baseline(p: &Planner, work: &Path, conf: &AbiDrift) -> Result<AbiBase
];
let cmd = p.plan_role_cmd("watch", argv)?;
let log_path = work.join(format!("abi-{field}.log"));
let code = exec_logged(&cmd, &p.scope.env(), &log_path)?;
let code = exec_logged(&cmd, &p.scope.env(), &p.scope.eessi_unset_env(), &log_path)?;
if code != 0 {
return Err(Fail::new(
exit::TEMPFAIL,
Expand Down Expand Up @@ -1157,7 +1157,7 @@ pub fn order(
]);
let cmd = p.plan_role_cmd("watch", argv)?;
let log_path = work.join("order.log");
let code = exec_logged(&cmd, &p.scope.env(), &log_path)?;
let code = exec_logged(&cmd, &p.scope.env(), &p.scope.eessi_unset_env(), &log_path)?;
if code != 0 {
return Err(Fail::new(
exit::FAILED,
Expand Down
29 changes: 29 additions & 0 deletions tests/run_stubs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,35 @@ fn eessi_commands_do_not_inherit_another_install_mode_or_cpu_override() {
assert_eq!(calls(&env, "eb.calls").len(), 1);
}

#[test]
fn eessi_commands_do_not_inherit_default_or_custom_target_overrides() {
let env = setup(
"\n[modules.eessi]\nsite_install = true\ncpu_override_var = \"SITE_CPU_OVERRIDE\"\naccel_override_var = \"SITE_ACCEL_OVERRIDE\"\n",
);
let init = format!(
r#"
[ -z "${{EESSI_SOFTWARE_SUBDIR_OVERRIDE+x}}" ] || exit 17
[ -z "${{EESSI_ACCELERATOR_TARGET_OVERRIDE+x}}" ] || exit 18
[ -z "${{SITE_CPU_OVERRIDE+x}}" ] || exit 19
[ -z "${{SITE_ACCEL_OVERRIDE+x}}" ] || exit 20
{MODULE_FN}"#
);
with_modules(&env, &init, &["EESSI/2026.06"]);

let o = go(
&env,
"Foo-1.0-foss-2025a.eb\n",
&[
("EESSI_SOFTWARE_SUBDIR_OVERRIDE", "x86_64/amd/zen4"),
("EESSI_ACCELERATOR_TARGET_OVERRIDE", "accel/nvidia/cc90"),
("SITE_CPU_OVERRIDE", "x86_64/amd/zen4"),
("SITE_ACCEL_OVERRIDE", "accel/nvidia/cc90"),
],
);
assert_eq!(o.code, 0, "{}", o.stderr);
assert_eq!(calls(&env, "eb.calls").len(), 1);
}

#[test]
fn the_module_wrapper_sources_an_init_whose_last_test_is_false() {
let env = setup("");
Expand Down