Skip to content

Commit 50020cb

Browse files
kpedro88nsmith-
andauthored
bind all files/paths needed for host condor config (#36)
* bind all files/paths needed for host condor config * remove unneeded line * turn off -e after installation * define CONDOR_CONFIG globally * bind a fake python3 script * add top-level .condor_config file that includes lpc global condor config. it disables use of the local config file specified by /usr/local/bin/cmslpc-local-conf.py; cmslpc-local-conf still runs, but the attribute it adds (location of local config file) will now be ignored by condor. this avoids "ERROR: Can't read config source" from condor commands (because the /storage area has wrong ownership inside the container) the local config file is not actually created until the custom /usr/local/bin/condor_submit is used, and it is never used here. * hide fake python3 * don't actually need to bind /storage anymore * keep existing bindpath values * fake cmslpc-local-conf.py instead of fake python3 * further simplification: just suppress unwanted output from cmslpc-local-conf * Guard against misisng env var * Better user instructions for updating --------- Co-authored-by: Nick Smith <nick.smith@cern.ch>
1 parent 2f4f325 commit 50020cb

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

bootstrap.sh

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/usr/bin/env bash
22

3+
LPC_CONDOR_CONFIG=/etc/condor/config.d/01_cmslpc_interactive
4+
LPC_CONDOR_LOCAL=/usr/local/bin/cmslpc-local-conf.py
5+
36
cat <<EOF > shell
47
#!/usr/bin/env bash
58
@@ -18,15 +21,18 @@ else
1821
export COFFEA_IMAGE=\$1
1922
fi
2023
21-
grep -v '^include' /etc/condor/config.d/01_cmslpc_interactive > .condor_config
22-
23-
export APPTAINER_BINDPATH=/uscmst1b_scratch,/cvmfs,/cvmfs/grid.cern.ch/etc/grid-security:/etc/grid-security
24+
export APPTAINER_BINDPATH=${APPTAINER_BINDPATH}${APPTAINER_BINDPATH:+,}/uscmst1b_scratch,/cvmfs,/cvmfs/grid.cern.ch/etc/grid-security:/etc/grid-security,${LPC_CONDOR_CONFIG},${LPC_CONDOR_LOCAL}:${LPC_CONDOR_LOCAL}.orig,.cmslpc-local-conf:${LPC_CONDOR_LOCAL}
2425
2526
APPTAINER_SHELL=\$(which bash) apptainer exec -B \${PWD}:/srv --pwd /srv \\
2627
/cvmfs/unpacked.cern.ch/registry.hub.docker.com/\${COFFEA_IMAGE} \\
2728
/bin/bash --rcfile /srv/.bashrc
2829
EOF
2930

31+
cat <<EOF > .cmslpc-local-conf
32+
#!/bin/bash
33+
python3 ${LPC_CONDOR_LOCAL}.orig | grep -v "LOCAL_CONFIG_FILE"
34+
EOF
35+
3036
cat <<EOF > .bashrc
3137
LPCJQ_VERSION="0.3.1"
3238
install_env() {
@@ -40,8 +46,10 @@ install_env() {
4046
rm -rf \$TMPDIR && unset TMPDIR
4147
.env/bin/python -m pip install -q git+https://github.com/CoffeaTeam/lpcjobqueue.git@v\${LPCJQ_VERSION}
4248
echo "done."
49+
set +e
4350
}
4451
52+
export CONDOR_CONFIG=${LPC_CONDOR_CONFIG}
4553
export JUPYTER_PATH=/srv/.jupyter
4654
export JUPYTER_RUNTIME_DIR=/srv/.local/share/jupyter/runtime
4755
export JUPYTER_DATA_DIR=/srv/.local/share/jupyter
@@ -54,5 +62,5 @@ alias pip="python -m pip"
5462
pip show lpcjobqueue 2>/dev/null | grep -q "Version: \${LPCJQ_VERSION}" || pip install -q git+https://github.com/CoffeaTeam/lpcjobqueue.git@v\${LPCJQ_VERSION}
5563
EOF
5664

57-
chmod u+x shell .bashrc
65+
chmod u+x shell .bashrc .cmslpc-local-conf
5866
echo "Wrote shell and .bashrc to current directory. You can delete this file. Run ./shell to start the apptainer shell"

src/lpcjobqueue/schedd.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
import re
66

77
logger = logging.getLogger(__name__)
8-
os.environ["CONDOR_CONFIG"] = os.path.join("/srv/.condor_config")
9-
if not os.path.isfile(os.environ['CONDOR_CONFIG']):
10-
logger.warn(f"Condor configuration not found! run the following command outside the apptainer instance")
11-
logger.warn(f"grep -v '^include' /etc/condor/config.d/01_cmslpc_interactive > .condor_config")
8+
if "CONDOR_CONFIG" not in os.environ or not os.path.isfile(os.environ["CONDOR_CONFIG"]):
9+
raise RuntimeError(
10+
f"Condor configuration {os.environ.get('CONDOR_CONFIG', '')} not found!\n"
11+
"Please download and run bootstrap.sh again to update the shell with:\n"
12+
"curl -OL https://raw.githubusercontent.com/CoffeaTeam/lpcjobqueue/main/bootstrap.sh; bash bootstrap.sh"
13+
)
1214
import htcondor # noqa: E402
1315

1416

0 commit comments

Comments
 (0)