Skip to content

Commit

Permalink
feat (SingularityCE): propagate more env variable inside the container
Browse files Browse the repository at this point in the history
  • Loading branch information
chaen committed Jul 27, 2023
1 parent 3999e15 commit aa5f5b4
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/DIRAC/Resources/Computing/SingularityComputingElement.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import io
import json
import os
import re
import shutil
import sys
import tempfile
Expand Down Expand Up @@ -85,6 +86,18 @@
"""


ENV_VAR_WHITELIST = [
r"TERM",
r"VOMS_.*",
r"X509_.*",
r"XRD_.*",
r"Xrd.*",
r"DIRAC.*", # will take also DIRAC and DIRACOS
r"BEARER_TOKEN.*",
]
ENV_VAR_WHITELIST = re.compile(r"^(" + r"|".join(ENV_VAR_WHITELIST) + r")$")


class SingularityComputingElement(ComputingElement):
"""A Computing Element for running a job within a Singularity container."""

Expand Down Expand Up @@ -311,9 +324,8 @@ def __getEnv(self):
"""Gets the environment for use within the container.
We blank almost everything to prevent contamination from the host system.
"""
payloadEnv = {}
if "TERM" in os.environ:
payloadEnv["TERM"] = os.environ["TERM"]

payloadEnv = {k: v for k, v in os.environ.items() if ENV_VAR_WHITELIST.match(k)}
payloadEnv["TMP"] = "/tmp"
payloadEnv["TMPDIR"] = "/tmp"
payloadEnv["X509_USER_PROXY"] = os.path.join(self.__innerdir, "proxy")
Expand Down

0 comments on commit aa5f5b4

Please sign in to comment.