From 264f2cdd2293361aca0a0d99c5546230561be2dc Mon Sep 17 00:00:00 2001 From: Thanayut Seethongchuen Date: Fri, 6 Oct 2023 16:04:08 +0200 Subject: [PATCH] Fix PreDAG.py to always use user proxy for rucio client (#7897) --- src/python/RucioUtils.py | 6 ++++-- src/python/TaskWorker/Actions/PreDAG.py | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/python/RucioUtils.py b/src/python/RucioUtils.py index 7e2ea03445..23527f3580 100644 --- a/src/python/RucioUtils.py +++ b/src/python/RucioUtils.py @@ -24,8 +24,10 @@ def getNativeRucioClient(config=None, logger=None): cl = logging.getLogger('charset_normalizer') cl.setLevel(logging.ERROR) - rucio_cert = getattr(config.Services, "Rucio_cert", config.TaskWorker.cmscert) - rucio_key = getattr(config.Services, "Rucio_key", config.TaskWorker.cmskey) + # Need to use config from `config.TaskWorker` object instead to switch to + # user cert in PreDag.py + rucio_cert = getattr(config.TaskWorker, "Rucio_cert", config.TaskWorker.cmscert) + rucio_key = getattr(config.TaskWorker, "Rucio_key", config.TaskWorker.cmskey) logger.debug("Using cert [%s]\n and key [%s] for rucio client.", rucio_cert, rucio_key) nativeClient = Client( rucio_host=config.Services.Rucio_host, diff --git a/src/python/TaskWorker/Actions/PreDAG.py b/src/python/TaskWorker/Actions/PreDAG.py index b1a830e2c8..3f7a9b5c11 100644 --- a/src/python/TaskWorker/Actions/PreDAG.py +++ b/src/python/TaskWorker/Actions/PreDAG.py @@ -206,6 +206,10 @@ def executeInternal(self, *args): config.TaskWorker.cmskey = os.environ.get('X509_USER_PROXY') config.TaskWorker.envForCMSWEB = newX509env(X509_USER_CERT=config.TaskWorker.cmscert, X509_USER_KEY=config.TaskWorker.cmskey) + # also for talking with rucio + config.TaskWorker.Rucio_cert = os.environ.get('X509_USER_PROXY') + config.TaskWorker.Rucio_key = os.environ.get('X509_USER_PROXY') + # need to get username from classAd to setup for Rucio access task_ad = classad.parseOne(open(os.environ['_CONDOR_JOB_AD']))