Skip to content

Commit

Permalink
Merge pull request #7146 from DIRACGridBot/cherry-pick-2-1cd52b085-in…
Browse files Browse the repository at this point in the history
…tegration

[sweep:integration] [v8.0]Propagate more env variable in the SingularityCE
  • Loading branch information
fstagni authored Aug 2, 2023
2 parents 7b5fedf + 52b9a6b commit de53aef
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 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_.*",
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,12 +324,17 @@ 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"]

if not self.__installDIRACInContainer:
payloadEnv = {k: v for k, v in os.environ.items() if ENV_VAR_WHITELIST.match(k)}
else:
payloadEnv = {}

payloadEnv["TMP"] = "/tmp"
payloadEnv["TMPDIR"] = "/tmp"
payloadEnv["X509_USER_PROXY"] = os.path.join(self.__innerdir, "proxy")
payloadEnv["DIRACSYSCONFIG"] = os.path.join(self.__innerdir, "pilot.cfg")

return payloadEnv

@staticmethod
Expand Down

0 comments on commit de53aef

Please sign in to comment.