From 15f9654709c00fa1396617d9cef4fa816fb798c8 Mon Sep 17 00:00:00 2001 From: "Felipe N. Schuch" Date: Mon, 28 Oct 2024 11:30:17 -0300 Subject: [PATCH] fix(agent): avoid propagating env variables to slurm jobs (#638) --- jobbergate-agent/CHANGELOG.md | 1 + jobbergate-agent/jobbergate_agent/jobbergate/submit.py | 2 +- jobbergate-agent/jobbergate_agent/utils/sentry.py | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/jobbergate-agent/CHANGELOG.md b/jobbergate-agent/CHANGELOG.md index dfe6951ee..00104bbbc 100644 --- a/jobbergate-agent/CHANGELOG.md +++ b/jobbergate-agent/CHANGELOG.md @@ -4,6 +4,7 @@ This file keeps track of all notable changes to jobbergate-agent ## Unreleased - Changed auto-update task to reuse current scheduler instead of creating a new one +- Fixed environment variables from the machine running the agent propagating to slurm jobs (notice `--export=ALL` is the default behavior for sbatch) ## 5.3.0 -- 2024-09-09 diff --git a/jobbergate-agent/jobbergate_agent/jobbergate/submit.py b/jobbergate-agent/jobbergate_agent/jobbergate/submit.py index e89c5ac43..a5a82d28c 100644 --- a/jobbergate-agent/jobbergate_agent/jobbergate/submit.py +++ b/jobbergate-agent/jobbergate_agent/jobbergate/submit.py @@ -174,7 +174,7 @@ def __post_init__(self): self.gid = pwan.pw_gid def run(self, *args, **kwargs): - kwargs.update(user=self.uid, group=self.gid) + kwargs.update(user=self.uid, group=self.gid, env={}) # Tests indicate that the change on the working directory precedes the change of user on the subprocess. # With that, the user running the agent can face permission denied errors on cwd, # depending on the setting on the filesystem and permissions on the directory. diff --git a/jobbergate-agent/jobbergate_agent/utils/sentry.py b/jobbergate-agent/jobbergate_agent/utils/sentry.py index d3feeabe1..4fefe5efa 100644 --- a/jobbergate-agent/jobbergate_agent/utils/sentry.py +++ b/jobbergate-agent/jobbergate_agent/utils/sentry.py @@ -17,6 +17,7 @@ def init_sentry(): integrations=[sentry_logging], traces_sample_rate=1.0, environment=SETTINGS.SENTRY_ENV, + propagate_traces=False, # Do not propagate traces to child processes (e.g. sbatch subprocesses) ) logger.debug("##### Enabled Sentry since a valid DSN key was provided.")