Skip to content

Commit

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

[sweep:integration] Supress non-UTF8 variables from pilot environment
  • Loading branch information
chrisburr authored Feb 28, 2025
2 parents 50d117d + e571726 commit 87f2d23
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/pilotWrapper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
conda create -c conda-forge -c free -n python_${{ matrix.python }} python=${{ matrix.python }}
- name: run pilot wrapper test
run: |
export INVALID_UTF8_VAR=$'\xff'
cp tests/Integration/WorkloadManagementSystem/Test_GenerateAndExecutePilotWrapper.py .
eval "$(conda shell.bash hook)" && conda activate python_${{ matrix.python }}
# use github APIs to get the artifacts URLS from https://github.com/DIRACGrid/Pilot/, for those named Pilot_${{ matrix.pilot_branch }}
Expand Down
10 changes: 9 additions & 1 deletion src/DIRAC/WorkloadManagementSystem/Utilities/PilotWrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,15 @@ def formatTime(self, record, datefmt=None):
# just logging the environment as first thing
logger.debug('===========================================================')
logger.debug('Environment of execution host\\n')
for key, val in os.environ.items():
for key, val in getattr(os, "environb", os.environ).items():
# Clean the environment of non-utf-8 characters
try:
key = key.decode("utf-8")
val = val.decode("utf-8")
except UnicodeDecodeError as e:
logger.error("Dropping %%s=%%s due to: %%s", key, val, e)
del os.environ[key]
continue
logger.debug(key + '=' + val)
logger.debug('===========================================================\\n')
Expand Down

0 comments on commit 87f2d23

Please sign in to comment.