From 726e65556042b4b58d9bfd2d6f35fa6343340cbb Mon Sep 17 00:00:00 2001 From: Rohit Goswami Date: Mon, 16 Nov 2026 02:29:35 +0000 Subject: [PATCH] fix(target): put the attempt's module tree on MODULEPATH for verification A campaign attempt builds with --installpath set to its own prefix, /install-attempts/-/attempt-, and that flag takes precedence over the prefix EESSI-extend derives from EESSI_USER_INSTALL. Nothing put the prefix's module tree on MODULEPATH, so a verification command such as the examples' `module load {module} && ...` could not find the module the attempt had just built. On EESSI 2026.06, natsort's verification failed with Lmod's "The following module(s) are unknown"; with this change the same campaign completes and natsort is binary-verified. verification_command now runs the command through a short sh wrapper on the target that puts the module tree first on MODULEPATH and on EESSI_EXTRA_MODULEPATH, extending the values there. The EESSI init replaces MODULEPATH and keeps EESSI_EXTRA_MODULEPATH, after its own trees. The tree follows EasyBuild's install_path('mod'): EASYBUILD_INSTALLPATH_MODULES, or the install path and EASYBUILD_SUBDIR_MODULES, then EASYBUILD_SUFFIX_MODULES_PATH, by default /modules/all. Without EASYBUILD_INSTALLPATH the command is unchanged. The target reference, the campaign run reference, and the eOn on EESSI how-to now say where attempts install, and the how-to no longer says the modules land under $EESSI_USER_INSTALL. A campaign test with a fake eb and a target test of the routed command cover the module tree, with and without an EESSI-style MODULEPATH reset; both fail without the fix. --- changelog.d/+attempt-modulepath.bugfix.md | 1 + changelog.d/+attempt-prefix.doc.md | 1 + docs/orgmode/howto/eon-eessi-extend.org | 11 ++-- docs/orgmode/reference/cli.org | 5 +- docs/orgmode/reference/targets.org | 17 +++++++ llms-full.txt | 33 ++++++++++-- src/target.rs | 48 +++++++++++++++++- tests/campaign.rs | 61 +++++++++++++++++++++++ tests/target_config.rs | 61 +++++++++++++++++++++++ 9 files changed, 227 insertions(+), 11 deletions(-) create mode 100644 changelog.d/+attempt-modulepath.bugfix.md create mode 100644 changelog.d/+attempt-prefix.doc.md diff --git a/changelog.d/+attempt-modulepath.bugfix.md b/changelog.d/+attempt-modulepath.bugfix.md new file mode 100644 index 00000000..6a0825fa --- /dev/null +++ b/changelog.d/+attempt-modulepath.bugfix.md @@ -0,0 +1 @@ +A verification command runs with the module tree of the attempt's install path, `/modules/all` by default, first on `MODULEPATH` and on `EESSI_EXTRA_MODULEPATH`, so `module load {module}` finds the module the attempt built, also after the EESSI init replaces `MODULEPATH`. diff --git a/changelog.d/+attempt-prefix.doc.md b/changelog.d/+attempt-prefix.doc.md new file mode 100644 index 00000000..0f76ee53 --- /dev/null +++ b/changelog.d/+attempt-prefix.doc.md @@ -0,0 +1 @@ +The target reference and the eOn on EESSI how-to say that each campaign attempt installs into `/install-attempts/-/attempt-`, which takes precedence over the prefix EESSI-extend derives from `EESSI_USER_INSTALL`. diff --git a/docs/orgmode/howto/eon-eessi-extend.org b/docs/orgmode/howto/eon-eessi-extend.org index 900a656f..f4934900 100644 --- a/docs/orgmode/howto/eon-eessi-extend.org +++ b/docs/orgmode/howto/eon-eessi-extend.org @@ -105,10 +105,13 @@ Read the campaign while it runs, from another shell: eb-stack campaign status --state /tmp/eb-stack/bundles/eon-tutorial.campaign.json #+end_src -The modules land under -~$EESSI_USER_INSTALL/versions/2026.06/software/linux/$EESSI_SOFTWARE_SUBDIR/modules/all~, -so a second CPU target gets its own tree, and each host loads the build for -its own architecture. +The campaign installs each attempt into its own prefix, +~/install-attempts/eOn-2.17.10/attempt-~, and passes it to ~eb~ +as ~--installpath~, which takes precedence over the path ~EESSI-extend~ +derives from ~$EESSI_USER_INSTALL~. The modules land under ~modules/all~ in +that prefix, and the verification commands find them there. Unlike the +~$EESSI_USER_INSTALL~ tree, which has one directory per +~$EESSI_SOFTWARE_SUBDIR~, that path does not name the CPU target. * Develop eOn from a working tree diff --git a/docs/orgmode/reference/cli.org b/docs/orgmode/reference/cli.org index 62d7185f..a41d13c0 100644 --- a/docs/orgmode/reference/cli.org +++ b/docs/orgmode/reference/cli.org @@ -1944,7 +1944,10 @@ eb-stack campaign finding resolve \ ~campaign run~ resumes state with matching package identity, increments the attempt, stages the bundle, runs every emitted recipe, and executes each -profile's verification commands. Transport, executor, runtime, interrupted, +profile's verification commands. Each attempt installs into its own prefix +under ~/install-attempts/~, and its verification commands find +that prefix's modules first, as [[file:targets.org][the target reference]] +describes. Transport, executor, runtime, interrupted, checksum, patch, dependency, configure, compile, link, test, install, sanity, resource, timeout, and unknown failures are persisted as typed findings. diff --git a/docs/orgmode/reference/targets.org b/docs/orgmode/reference/targets.org index 94309372..a79bbd8e 100644 --- a/docs/orgmode/reference/targets.org +++ b/docs/orgmode/reference/targets.org @@ -129,6 +129,23 @@ The routed build command adds ~--robot=~ and ~--buildpath=/build~. Later robot roots override earlier recipes with the same EasyBuild identity. +A campaign gives each attempt its own prefix. It sets ~EASYBUILD_INSTALLPATH~ +to ~/install-attempts/-/attempt-~, and the +build command passes that as ~--installpath~. The flag takes precedence over +an install path from the environment, such as the one ~EESSI-extend~ derives +from ~EESSI_USER_INSTALL~, so a campaign does not install into that prefix. + +A verification command runs with the module tree of ~EASYBUILD_INSTALLPATH~ +first on ~MODULEPATH~ and on ~EESSI_EXTRA_MODULEPATH~. The tree is +~/modules/all~ unless the environment sets +~EASYBUILD_INSTALLPATH_MODULES~, ~EASYBUILD_SUBDIR_MODULES~, or +~EASYBUILD_SUFFIX_MODULES_PATH~. So ~module load {module}~ finds the attempt's +module, also after the EESSI init, which replaces ~MODULEPATH~ and keeps +~EESSI_EXTRA_MODULEPATH~. That init puts its own trees first, so a module +EESSI also provides loads from EESSI. To load the attempt's build instead, +run ~module use $EASYBUILD_INSTALLPATH/modules/all~ after the init and before +~module load EESSI-extend~, which sets ~EASYBUILD_INSTALLPATH~ again. + Treat ~EASYBUILD_PARALLEL~ and the executor allocation as one resource contract. Parallel C++ compiler processes can each consume more than a gigabyte, so CPU count alone is not a safe job count. The runnable local target diff --git a/llms-full.txt b/llms-full.txt index 5591be69..d839be6e 100644 --- a/llms-full.txt +++ b/llms-full.txt @@ -1597,10 +1597,13 @@ Read the campaign while it runs, from another shell: eb-stack campaign status --state /tmp/eb-stack/bundles/eon-tutorial.campaign.json ``` -The modules land under -`$EESSI_USER_INSTALL/versions/2026.06/software/linux/$EESSI_SOFTWARE_SUBDIR/modules/all`, -so a second CPU target gets its own tree, and each host loads the build for -its own architecture. +The campaign installs each attempt into its own prefix, +`/install-attempts/eOn-2.17.10/attempt-`, and passes it to `eb` +as `--installpath`, which takes precedence over the path `EESSI-extend` +derives from `$EESSI_USER_INSTALL`. The modules land under `modules/all` in +that prefix, and the verification commands find them there. Unlike the +`$EESSI_USER_INSTALL` tree, which has one directory per +`$EESSI_SOFTWARE_SUBDIR`, that path does not name the CPU target. # Develop eOn from a working tree @@ -8603,7 +8606,10 @@ eb-stack campaign finding resolve \ `campaign run` resumes state with matching package identity, increments the attempt, stages the bundle, runs every emitted recipe, and executes each -profile's verification commands. Transport, executor, runtime, interrupted, +profile's verification commands. Each attempt installs into its own prefix +under `/install-attempts/`, and its verification commands find +that prefix's modules first, as [the target reference](https://eb-stack.rgoswami.me/targets.html.md) +describes. Transport, executor, runtime, interrupted, checksum, patch, dependency, configure, compile, link, test, install, sanity, resource, timeout, and unknown failures are persisted as typed findings. @@ -9895,6 +9901,23 @@ The routed build command adds `--robot=` and `--buildpath=/build`. Later robot roots override earlier recipes with the same EasyBuild identity. +A campaign gives each attempt its own prefix. It sets `EASYBUILD_INSTALLPATH` +to `/install-attempts/-/attempt-`, and the +build command passes that as `--installpath`. The flag takes precedence over +an install path from the environment, such as the one `EESSI-extend` derives +from `EESSI_USER_INSTALL`, so a campaign does not install into that prefix. + +A verification command runs with the module tree of `EASYBUILD_INSTALLPATH` +first on `MODULEPATH` and on `EESSI_EXTRA_MODULEPATH`. The tree is +`/modules/all` unless the environment sets +`EASYBUILD_INSTALLPATH_MODULES`, `EASYBUILD_SUBDIR_MODULES`, or +`EASYBUILD_SUFFIX_MODULES_PATH`. So `module load {module}` finds the attempt's +module, also after the EESSI init, which replaces `MODULEPATH` and keeps +`EESSI_EXTRA_MODULEPATH`. That init puts its own trees first, so a module +EESSI also provides loads from EESSI. To load the attempt's build instead, +run `module use $EASYBUILD_INSTALLPATH/modules/all` after the init and before +`module load EESSI-extend`, which sets `EASYBUILD_INSTALLPATH` again. + Treat `EASYBUILD_PARALLEL` and the executor allocation as one resource contract. Parallel C++ compiler processes can each consume more than a gigabyte, so CPU count alone is not a safe job count. The runnable local target diff --git a/src/target.rs b/src/target.rs index ccf88ade..674f8678 100644 --- a/src/target.rs +++ b/src/target.rs @@ -541,16 +541,49 @@ impl BuildTarget { /// /// Uses the same workload prefix as a build: `EASYBUILD_TMPDIR` and the /// target environment. Wrapper variables are scrubbed only when `program` - /// is EasyBuild itself. + /// is EasyBuild itself. With `EASYBUILD_INSTALLPATH` set, the module tree + /// under it goes first on `MODULEPATH` and on `EESSI_EXTRA_MODULEPATH`, + /// so `module load` finds what the build installed there. pub fn verification_command(&self, program: &str, args: &[String]) -> CommandPlan { let scrub_wrappers = self.should_scrub_compiler_wrappers() && self.is_easybuild_program(program); let mut tokens = self.easybuild_workload_prefix(scrub_wrappers); + if let Some(tree) = self.installed_module_tree() { + tokens.extend([ + "sh".into(), + "-c".into(), + PREPEND_MODULE_TREE.into(), + "sh".into(), + tree, + ]); + } tokens.push(program.to_string()); tokens.extend(args.iter().cloned()); self.route_tokens(self.runtime_tokens(tokens), true) } + /// Where EasyBuild writes module files for `EASYBUILD_INSTALLPATH`. + /// + /// `EASYBUILD_INSTALLPATH_MODULES` replaces `/`, as + /// in EasyBuild's own `install_path('mod')`. + fn installed_module_tree(&self) -> Option { + let environment = &self.easybuild.environment; + let installpath = environment.get("EASYBUILD_INSTALLPATH")?; + let base = match environment.get("EASYBUILD_INSTALLPATH_MODULES") { + Some(modules) => modules.clone(), + None => { + let subdir = environment + .get("EASYBUILD_SUBDIR_MODULES") + .map_or("modules", String::as_str); + format!("{installpath}/{subdir}") + } + }; + let suffix = environment + .get("EASYBUILD_SUFFIX_MODULES_PATH") + .map_or("all", String::as_str); + Some(format!("{base}/{suffix}")) + } + /// `env` prefix shared by builds, verification, and the doctor EasyBuild probe. fn easybuild_workload_prefix(&self, scrub_wrappers: bool) -> Vec { let mut tokens = vec!["env".to_string()]; @@ -943,6 +976,19 @@ fn is_compiler_wrapper_env(name: &str) -> bool { || (name.starts_with("CMAKE_") && name.ends_with("_COMPILER_LAUNCHER")) } +/// Puts `$1` first on `MODULEPATH` and on `EESSI_EXTRA_MODULEPATH`, then +/// execs the remaining arguments. +/// +/// It runs on the target, so both values extend the ones there. The EESSI +/// init replaces `MODULEPATH` and keeps `EESSI_EXTRA_MODULEPATH`, after the +/// EESSI module trees. +const PREPEND_MODULE_TREE: &str = r#"tree=$1 +shift +MODULEPATH="$tree${MODULEPATH:+:$MODULEPATH}" +EESSI_EXTRA_MODULEPATH="$tree${EESSI_EXTRA_MODULEPATH:+:$EESSI_EXTRA_MODULEPATH}" +export MODULEPATH EESSI_EXTRA_MODULEPATH +exec "$@""#; + #[derive(Debug, Error)] /// Why a target could not be configured or reached. pub enum TargetError { diff --git a/tests/campaign.rs b/tests/campaign.rs index c1be30fb..4f03ced7 100644 --- a/tests/campaign.rs +++ b/tests/campaign.rs @@ -1600,3 +1600,64 @@ fn two_identical_signatures_are_stuck() { state.findings.push(finding(2)); assert!(is_stuck_on_signature(&state, &signature)); } + +/// Each attempt installs into its own prefix, so `module load {module}` +/// finds the build only through that prefix's module tree. The EESSI init +/// replaces `MODULEPATH` and keeps only `EESSI_EXTRA_MODULEPATH`. +#[test] +fn a_verification_command_loads_the_module_the_attempt_installed() { + let temp = tempfile::tempdir().expect("tempdir"); + let bundle = temp.path().join("bundle"); + let recipes = bundle.join("easyconfigs/e/eOn"); + std::fs::create_dir_all(&recipes).expect("recipes"); + std::fs::create_dir_all(bundle.join("locks")).expect("locks"); + let module_load = r#"IFS=:; for tree in $MODULEPATH; do [ -f "$tree/{module}.lua" ] && exit 0; done; echo "The following module(s) are unknown: {module}" >&2; exit 1"#; + let eessi_init = + "MODULEPATH=/cvmfs/software.eessi.io/init/modules${EESSI_EXTRA_MODULEPATH:+:$EESSI_EXTRA_MODULEPATH}"; + let manifest = serde_json::json!({ + "package": {"name": "eOn", "version": "2.16.0"}, + "build": {"toolchain": {"name": "foss", "version": "2026.1"}}, + "profiles": [{ + "name": "default", + "default": true, + "versionsuffix": [], + "verification_commands": [ + {"program": "sh", "args": ["-c", module_load]}, + {"program": "sh", "args": ["-c", format!("{eessi_init}; {module_load}")]}, + ], + }], + }); + std::fs::write( + bundle.join("package.plan.json"), + serde_json::to_string(&manifest).expect("manifest JSON"), + ) + .expect("manifest"); + std::fs::write( + bundle.join("locks/default.lock.json"), + r#"{"profile":"default","solver":"resolvo"}"#, + ) + .expect("lock"); + write_valid_recipe(&recipes.join("eOn.eb"), "eOn", "2.16.0"); + let eb = temp.path().join("fake-eb"); + write_executable( + &eb, + "#!/bin/sh\nfor arg do\n case $arg in --installpath=*) prefix=${arg#--installpath=} ;; esac\ndone\nmkdir -p \"$prefix/modules/all/eOn\"\necho 'whatis(\"eOn\")' > \"$prefix/modules/all/eOn/2.16.0-foss-2026.1.lua\"\n", + ) + .expect("fake eb"); + let mut builder = target(eb.to_str().expect("eb path")); + builder.easybuild.work_root = temp.path().join("work").display().to_string(); + + let state = run_campaign(&CampaignRequest { + bundle, + target: builder, + state_path: temp.path().join("campaign.json"), + }) + .expect("campaign"); + assert_eq!( + state.status, + CampaignStatus::Completed, + "{:#?}", + state.findings + ); + assert!(state.claims.binary_verified); +} diff --git a/tests/target_config.rs b/tests/target_config.rs index 05df60d6..02c482db 100644 --- a/tests/target_config.rs +++ b/tests/target_config.rs @@ -241,6 +241,67 @@ fn verification_command_sets_tmpdir_and_workload_environment() { assert_eq!(plan.args.get(module + 1).map(String::as_str), Some("load")); } +#[test] +fn verification_command_puts_the_installed_module_tree_first() { + let paths = |environment: &[(&str, &str)]| { + let target = BuildTarget { + name: "local".into(), + transport: TargetTransport::Local, + executor: TargetExecutor::Direct, + runtime: TargetRuntime::Host, + easybuild: EasyBuildWorkload { + command: "eb".into(), + robot_paths: Vec::new(), + work_root: "/work".into(), + tmp_root: "/tmp".into(), + environment: environment + .iter() + .map(|(name, value)| (name.to_string(), value.to_string())) + .collect(), + }, + }; + let plan = target.verification_command( + "sh", + &[ + "-c".into(), + r#"printf '%s\n' "$MODULEPATH" "$EESSI_EXTRA_MODULEPATH""#.into(), + ], + ); + let output = plan.execute().expect("verification command"); + assert!(output.status.success(), "{plan:?}"); + String::from_utf8(output.stdout).expect("utf-8") + }; + let site = [ + ("MODULEPATH", "/site/modules"), + ("EESSI_EXTRA_MODULEPATH", "/site/extra"), + ]; + let with = |extra: &[(&'static str, &'static str)]| { + let mut environment = site.to_vec(); + environment.extend_from_slice(extra); + paths(&environment) + }; + assert_eq!( + with(&[("EASYBUILD_INSTALLPATH", "/work/attempt-1")]), + "/work/attempt-1/modules/all:/site/modules\n/work/attempt-1/modules/all:/site/extra\n" + ); + assert_eq!( + with(&[ + ("EASYBUILD_INSTALLPATH", "/work/attempt-1"), + ("EASYBUILD_SUBDIR_MODULES", "mods"), + ("EASYBUILD_SUFFIX_MODULES_PATH", "collection"), + ]), + "/work/attempt-1/mods/collection:/site/modules\n/work/attempt-1/mods/collection:/site/extra\n" + ); + assert_eq!( + with(&[ + ("EASYBUILD_INSTALLPATH", "/work/attempt-1"), + ("EASYBUILD_INSTALLPATH_MODULES", "/work/modules"), + ]), + "/work/modules/all:/site/modules\n/work/modules/all:/site/extra\n" + ); + assert_eq!(with(&[]), "/site/modules\n/site/extra\n"); +} + #[test] fn doctor_easybuild_probe_sets_tmpdir_and_workload_environment() { let mut environment = BTreeMap::new();