Skip to content

Commit

Permalink
feat (diracx): make diracx installation mandatory
Browse files Browse the repository at this point in the history
  • Loading branch information
chaen authored and chrisburr committed Nov 27, 2023
1 parent dbf5abc commit ec316b2
Show file tree
Hide file tree
Showing 14 changed files with 54 additions and 24 deletions.
2 changes: 1 addition & 1 deletion integration_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ def _gen_docker_compose(modules, *, diracx_dist_dir=None):

module_configs = _load_module_configs(modules)
if diracx_dist_dir is not None:
for container_name in ["diracx-init-cs", "diracx-wait-for-db", "diracx"]:
for container_name in ["dirac-client", "dirac-server", "diracx-init-cs", "diracx-wait-for-db", "diracx"]:
docker_compose["services"][container_name]["volumes"].append(f"{diracx_dist_dir}:/diracx_sources")
docker_compose["services"][container_name].setdefault("environment", []).append(
"DIRACX_CUSTOM_SOURCE_PREFIXES=/diracx_sources"
Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ install_requires =
cachetools
certifi
diraccfg
diracx-client
diracx-core
db12
fts3
gfal2-python
Expand Down
4 changes: 2 additions & 2 deletions src/DIRAC/Core/Security/DiracX.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from diracx.core.preferences import DiracxPreferences
from diracx.core.utils import serialize_credentials

from DIRAC import gConfig
from DIRAC import gConfig, S_ERROR
from DIRAC.ConfigurationSystem.Client.Helpers import Registry
from DIRAC.Core.Security.Locations import getDefaultProxyLocation
from DIRAC.Core.Utilities.ReturnValues import convertToReturnValue, returnValueOrRaise
Expand All @@ -31,7 +31,7 @@


@convertToReturnValue
def addProxyToPEM(pemPath, group):
def addTokenToPEM(pemPath, group):
from DIRAC.Core.Base.Client import Client

vo = Registry.getVOMSVOForGroup(group)
Expand Down
6 changes: 3 additions & 3 deletions src/DIRAC/FrameworkSystem/Client/ProxyManagerClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from DIRAC.ConfigurationSystem.Client.Helpers import Registry
from DIRAC.Core.Utilities import ThreadSafe, DIRACSingleton
from DIRAC.Core.Utilities.DictCache import DictCache
from DIRAC.Core.Security.DiracX import addProxyToPEM
from DIRAC.Core.Security.DiracX import addTokenToPEM
from DIRAC.Core.Security.ProxyFile import multiProxyArgument, deleteMultiProxy
from DIRAC.Core.Security.X509Chain import X509Chain # pylint: disable=import-error
from DIRAC.Core.Security.X509Request import X509Request # pylint: disable=import-error
Expand Down Expand Up @@ -550,7 +550,7 @@ def dumpProxyToFile(self, chain, destinationFile=None, requiredTimeLeft=600):
filename = retVal["Value"]
if not (result := chain.getDIRACGroup())["OK"]:
return result
if not (result := addProxyToPEM(filename, result["Value"]))["OK"]:
if not (result := addTokenToPEM(filename, result["Value"]))["OK"]:
return result
self.__filesCache.add(cHash, chain.getRemainingSecs()["Value"], filename)
return S_OK(filename)
Expand Down Expand Up @@ -665,7 +665,7 @@ def renewProxy(self, proxyToBeRenewed=None, minLifeTime=3600, newProxyLifeTime=4
return result
if not (result := chain.getDIRACGroup())["OK"]:
return result
if not (result := addProxyToPEM(filename, result["Value"]))["OK"]:
if not (result := addTokenToPEM(filename, result["Value"]))["OK"]:
return result
return S_OK(filename)

Expand Down
3 changes: 1 addition & 2 deletions src/DIRAC/FrameworkSystem/Service/ProxyManagerHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from DIRAC.Core.Security import Properties
from DIRAC.Core.Utilities.ObjectLoader import ObjectLoader
from DIRAC.ConfigurationSystem.Client.Helpers import Registry

from DIRAC.FrameworkSystem.Utilities.diracx import get_token

DEFAULT_MAIL_FROM = "[email protected]"

Expand Down Expand Up @@ -412,7 +412,6 @@ def export_getVOMSProxyWithToken(self, userDN, userGroup, requestPem, requiredLi
@convertToReturnValue
def export_exchangeProxyForToken(self):
"""Exchange a proxy for an equivalent token to be used with diracx"""
from DIRAC.FrameworkSystem.Utilities.diracx import get_token

credDict = self.getRemoteCredentials()
return get_token(
Expand Down
1 change: 0 additions & 1 deletion src/DIRAC/FrameworkSystem/Utilities/diracx.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# pylint: disable=import-error
import requests

from cachetools import TTLCache, cached
Expand Down
4 changes: 2 additions & 2 deletions src/DIRAC/FrameworkSystem/scripts/dirac_admin_get_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import DIRAC
from DIRAC import gLogger, S_OK, S_ERROR
from DIRAC.Core.Base.Script import Script
from DIRAC.Core.Security.DiracX import addProxyToPEM
from DIRAC.Core.Security.DiracX import addTokenToPEM
from DIRAC.FrameworkSystem.Client.ProxyManagerClient import gProxyManager
from DIRAC.ConfigurationSystem.Client.Helpers import Registry

Expand Down Expand Up @@ -162,7 +162,7 @@ def main():
DIRAC.exit(2)
if not (result := chain.getDIRACGroup())["OK"]:
return result
if not (result := addProxyToPEM(params.proxyPath, result["Value"]))["OK"]:
if not (result := addTokenToPEM(params.proxyPath, result["Value"]))["OK"]:
return result
gLogger.notice(f"Proxy downloaded to {params.proxyPath}")
DIRAC.exit(0)
Expand Down
4 changes: 2 additions & 2 deletions src/DIRAC/FrameworkSystem/scripts/dirac_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from DIRAC import gConfig, gLogger, S_OK, S_ERROR
from DIRAC.Core.Security.Locations import getDefaultProxyLocation, getCertificateAndKeyLocation
from DIRAC.Core.Security.VOMS import VOMS
from DIRAC.Core.Security.DiracX import addProxyToPEM
from DIRAC.Core.Security.DiracX import addTokenToPEM
from DIRAC.Core.Security.ProxyFile import writeToProxyFile
from DIRAC.Core.Security.ProxyInfo import getProxyInfo, formatProxyInfoAsString
from DIRAC.Core.Security.X509Chain import X509Chain # pylint: disable=import-error
Expand Down Expand Up @@ -315,7 +315,7 @@ def loginWithCertificate(self):
return res

# Get a token for use with diracx
if not (result := addProxyToPEM(self.outputFile, self.group))["OK"]:
if not (result := addTokenToPEM(self.outputFile, self.group))["OK"]:
return result

return S_OK()
Expand Down
4 changes: 2 additions & 2 deletions src/DIRAC/FrameworkSystem/scripts/dirac_proxy_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from DIRAC.Core.Base.Script import Script
from DIRAC.FrameworkSystem.Client import ProxyGeneration, ProxyUpload
from DIRAC.Core.Security import X509Chain, ProxyInfo, VOMS
from DIRAC.Core.Security.DiracX import addProxyToPEM
from DIRAC.Core.Security.DiracX import addTokenToPEM
from DIRAC.Core.Security.Locations import getCAsLocation, getDefaultProxyLocation
from DIRAC.ConfigurationSystem.Client.Helpers import Registry
from DIRAC.FrameworkSystem.Client.BundleDeliveryClient import BundleDeliveryClient
Expand Down Expand Up @@ -223,7 +223,7 @@ def doTheMagic(self):
resultProxyWithVOMS = pI.addVOMSExtIfNeeded()

proxyLoc = self.__piParams.proxyLoc or getDefaultProxyLocation()
if not (result := addProxyToPEM(proxyLoc, self.__piParams.diracGroup))["OK"]:
if not (result := addTokenToPEM(proxyLoc, self.__piParams.diracGroup))["OK"]:
return result

if not resultProxyWithVOMS["OK"]:
Expand Down
2 changes: 1 addition & 1 deletion src/DIRAC/Interfaces/Utilities/DCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ def proxyInit(self):
# silently skip VOMS errors
pass

if not (result := addProxyToPEM(filename, params.diracGroup))["OK"]:
if not (result := addTokenToPEM(filename, params.diracGroup))["OK"]:
raise Exception(result["Message"])

def addVomsExt(self, proxy):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# pylint: disable=import-error
from diracx.client import DiracClient
from diracx.client.models import JobSearchParams


from DIRAC.Core.Utilities.ReturnValues import convertToReturnValue

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@
from DIRAC.Core.Utilities.ObjectLoader import ObjectLoader
from DIRAC.DataManagementSystem.Client.DataManager import DataManager
from DIRAC.DataManagementSystem.Service.StorageElementHandler import getDiskSpace
from DIRAC.FrameworkSystem.Utilities.diracx import TheImpersonator
from DIRAC.RequestManagementSystem.Client.File import File
from DIRAC.RequestManagementSystem.Client.Operation import Operation
from DIRAC.RequestManagementSystem.Client.ReqClient import ReqClient
from DIRAC.RequestManagementSystem.Client.Request import Request
from DIRAC.Resources.Storage.StorageElement import StorageElement
from DIRAC.Core.Utilities.File import getGlobbedTotalSize

from diracx.client.models import SandboxInfo


class SandboxStoreHandlerMixin:
__purgeCount = -1
Expand Down Expand Up @@ -113,9 +116,6 @@ def _getFromClient(self, fileId, token, fileSize, fileHelper=None, data=""):

disabledVOs = gConfig.getValue("/DiracX/DisabledVOs", [])
if self._useDiracXBackend and vo not in disabledVOs:
from DIRAC.FrameworkSystem.Utilities.diracx import TheImpersonator
from diracx.client.models import SandboxInfo # pylint: disable=import-error

gLogger.info("Forwarding to DiracX")
with tempfile.TemporaryFile(mode="w+b") as tar_fh:
result = fileHelper.networkToDataSink(tar_fh, maxFileSize=self._maxUploadBytes)
Expand Down Expand Up @@ -490,8 +490,6 @@ def _sendToClient(self, fileID, token, fileHelper=None, raw=False):
# If the PFN starts with S3, we know it has been uploaded to the
# S3 sandbox store, so download it from there before sending it
if filePath.startswith("/S3"):
from DIRAC.FrameworkSystem.Utilities.diracx import TheImpersonator

with TheImpersonator(credDict) as client:
res = client.jobs.get_sandbox_file(pfn=filePath)
r = requests.get(res.url)
Expand Down
19 changes: 18 additions & 1 deletion tests/Jenkins/dirac_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,25 @@ installSite() {
cd -


echo "==> Done installing, now configuring"
echo "==> Sourcing bashrc"
source "${SERVERINSTALLDIR}/bashrc"

echo "==> Installing main branch of diracx"
for wheel_name in core client; do
if [[ -n "${DIRACX_CUSTOM_SOURCE_PREFIXES:-}" ]]; then
wheels=("${DIRACX_CUSTOM_SOURCE_PREFIXES}/${wheel_name}"-*.whl)
if [[ ! ${wheels[#]} -eq 1 ]]; then
echo "ERROR: Multiple wheels found for ${package_name} in ${dir}"
exit 1
fi
pip install "${wheels[0]}"
else
pip install "git+https://github.com/DIRACGrid/diracx.git@main#egg=diracx-${wheel_name}&subdirectory=diracx-${wheel_name}"
fi
done


echo "==> Done installing, now configuring"
configureArgs=()
if [[ "${TEST_DIRACX:-}" = "Yes" ]]; then
configureArgs+=("--LegacyExchangeApiKey=diracx:legacy:InsecureChangeMe")
Expand Down
16 changes: 16 additions & 0 deletions tests/Jenkins/utilities.sh
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,22 @@ installDIRAC() {
done
fi



echo "==> Installing main branch of diracx"
for wheel_name in core client; do
if [[ -n "${DIRACX_CUSTOM_SOURCE_PREFIXES:-}" ]]; then
wheels=("${DIRACX_CUSTOM_SOURCE_PREFIXES}/${wheel_name}"-*.whl)
if [[ ! ${wheels[#]} -eq 1 ]]; then
echo "ERROR: Multiple wheels found for ${package_name} in ${dir}"
exit 1
fi
pip install "${wheels[0]}"
else
pip install "git+https://github.com/DIRACGrid/diracx.git@main#egg=diracx-${wheel_name}&subdirectory=diracx-${wheel_name}"
fi
done

echo "$DIRAC"
echo "$PATH"

Expand Down

0 comments on commit ec316b2

Please sign in to comment.