Skip to content

Commit d0535e1

Browse files
authored
Merge pull request #8005 from fstagni/90_use_containerized_certs_creation
[9.0] use containerized certs creation
2 parents e359eb3 + 678ef62 commit d0535e1

File tree

58 files changed

+362
-1069
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+362
-1069
lines changed

.github/workflows/integration.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,8 @@ jobs:
3333
include:
3434
- TEST_NAME: "MariaDB 11.4"
3535
ARGS: MYSQL_VER=mariadb:11.4.3
36-
- TEST_NAME: "HTTPS and MySQL8"
37-
ARGS: TEST_HTTPS=Yes MYSQL_VER=mysql:8.0.40
38-
- TEST_NAME: "Force DEncode"
39-
ARGS: DIRAC_USE_JSON_ENCODE=NO
36+
- TEST_NAME: "Force DEncode and MySQL8"
37+
ARGS: DIRAC_USE_JSON_ENCODE=NO MYSQL_VER=mysql:8.0.40
4038
- TEST_NAME: "Backward Compatibility"
4139
ARGS: CLIENT_INSTALLATION_BRANCH=rel-v8r0
4240

docs/source/DeveloperGuide/DevelopmentEnvironment/DeveloperInstallation/stuffThatRun.rst

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,9 @@ the private key. You will need two different sets certificates and the CA certif
9393
The following commands should do the trick for you, by creating a fake CA, a fake user certificate, and a fake host certificate::
9494

9595
cd $DEVROOT/DIRAC
96-
git checkout release/integration
97-
source tests/Jenkins/utilities.sh
98-
generateCA
99-
generateCertificates 365
100-
generateUserCredentials 365
96+
docker run ghcr.io/diracgrid/diracx/certificates-generation:latest
10197
mkdir -p ~/.globus/
102-
cp $DEVROOT/user/*.{pem,key} ~/.globus/
98+
docker cp certificates-generation:/ca/certs/client.{pem,key} ~/.globus/
10399
mv ~/.globus/client.key ~/.globus/userkey.pem
104100
mv ~/.globus/client.pem ~/.globus/usercert.pem
105101

integration_tests.py

Lines changed: 1 addition & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ def install_server():
378378
# for the diracx container to use
379379
# It needs to be started and running before the DIRAC server installation
380380
# because after installing the databases, the install server script
381-
# calls dirac-login.
381+
# calls dirac-proxy-init.
382382
# At this point we need the new CS to have been updated
383383
# already else the token exchange fails.
384384

@@ -396,91 +396,6 @@ def install_server():
396396
check=True,
397397
)
398398

399-
typer.secho("Copying credentials and certificates", fg=c.GREEN)
400-
base_cmd = _build_docker_cmd("client", tty=False)
401-
subprocess.run(
402-
base_cmd
403-
+ [
404-
"mkdir",
405-
"-p",
406-
"/home/dirac/ServerInstallDIR/user",
407-
"/home/dirac/ClientInstallDIR/etc",
408-
"/home/dirac/.globus",
409-
],
410-
check=True,
411-
)
412-
for path in [
413-
"etc/grid-security",
414-
"user/client.pem",
415-
"user/client.key",
416-
f"/tmp/x509up_u{os.getuid()}",
417-
]:
418-
source = os.path.join("/home/dirac/ServerInstallDIR", path)
419-
ret = subprocess.run(
420-
["docker", "cp", f"server:{source}", "-"],
421-
check=True,
422-
text=False,
423-
stdout=subprocess.PIPE,
424-
)
425-
if path.startswith("user/"):
426-
dest = f"client:/home/dirac/ServerInstallDIR/{os.path.dirname(path)}"
427-
elif path.startswith("/"):
428-
dest = f"client:{os.path.dirname(path)}"
429-
else:
430-
dest = f"client:/home/dirac/ClientInstallDIR/{os.path.dirname(path)}"
431-
subprocess.run(["docker", "cp", "-", dest], check=True, text=False, input=ret.stdout)
432-
subprocess.run(
433-
base_cmd
434-
+ [
435-
"bash",
436-
"-c",
437-
"cp /home/dirac/ServerInstallDIR/user/client.* /home/dirac/.globus/",
438-
],
439-
check=True,
440-
)
441-
442-
base_cmd = _build_docker_cmd("pilot", tty=False)
443-
subprocess.run(
444-
base_cmd
445-
+ [
446-
"mkdir",
447-
"-p",
448-
"/home/dirac/ServerInstallDIR/user",
449-
"/home/dirac/PilotInstallDIR/etc",
450-
"/home/dirac/.globus",
451-
],
452-
check=True,
453-
)
454-
for path in [
455-
"etc/grid-security",
456-
"user/client.pem",
457-
"user/client.key",
458-
f"/tmp/x509up_u{os.getuid()}",
459-
]:
460-
source = os.path.join("/home/dirac/ServerInstallDIR", path)
461-
ret = subprocess.run(
462-
["docker", "cp", f"server:{source}", "-"],
463-
check=True,
464-
text=False,
465-
stdout=subprocess.PIPE,
466-
)
467-
if path.startswith("user/"):
468-
dest = f"pilot:/home/dirac/ServerInstallDIR/{os.path.dirname(path)}"
469-
elif path.startswith("/"):
470-
dest = f"pilot:{os.path.dirname(path)}"
471-
else:
472-
dest = f"pilot:/home/dirac/PilotInstallDIR/{os.path.dirname(path)}"
473-
subprocess.run(["docker", "cp", "-", dest], check=True, text=False, input=ret.stdout)
474-
subprocess.run(
475-
base_cmd
476-
+ [
477-
"bash",
478-
"-c",
479-
"cp /home/dirac/ServerInstallDIR/user/client.* /home/dirac/.globus/",
480-
],
481-
check=True,
482-
)
483-
484399

485400
@app.command()
486401
def install_client():

src/DIRAC/Core/scripts/dirac_install_db.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
"""
33
Create a new DB in the MySQL server
44
"""
5+
from DIRAC import exit as DIRACExit
6+
from DIRAC import gConfig, gLogger
57
from DIRAC.Core.Base.Script import Script
68

79

@@ -12,24 +14,40 @@ def main():
1214
_, args = Script.parseCommandLine()
1315

1416
# Script imports
15-
from DIRAC import gConfig
17+
from DIRAC.ConfigurationSystem.Client.Helpers.CSGlobals import useServerCertificate
18+
from DIRAC.Core.Security.ProxyInfo import getProxyInfo
1619
from DIRAC.FrameworkSystem.Client.ComponentInstaller import gComponentInstaller
1720
from DIRAC.FrameworkSystem.Utilities import MonitoringUtilities
1821

22+
user = "DIRAC"
23+
1924
gComponentInstaller.exitOnError = True
2025
gComponentInstaller.getMySQLPasswords()
2126
for db in args:
2227
result = gComponentInstaller.installDatabase(db)
2328
if not result["OK"]:
24-
print(f"ERROR: failed to correctly install {db}", result["Message"])
25-
continue
29+
gLogger.error(f"Failed to correctly install {db}:", result["Message"])
30+
DIRACExit(1)
2631
extension, system = result["Value"]
27-
gComponentInstaller.addDatabaseOptionsToCS(gConfig, system, db, overwrite=True)
32+
result = gComponentInstaller.addDatabaseOptionsToCS(gConfig, system, db, overwrite=True)
33+
if not result["OK"]:
34+
gLogger.error("Failed to add database options to CS:", result["Message"])
35+
DIRACExit(1)
2836

2937
if db != "InstalledComponentsDB":
30-
result = MonitoringUtilities.monitorInstallation("DB", system, db)
38+
# get the user that installed the DB
39+
if not useServerCertificate():
40+
result = getProxyInfo()
41+
if not result["OK"]:
42+
return result
43+
proxyInfo = result["Value"]
44+
if "username" in proxyInfo:
45+
user = proxyInfo["username"]
46+
47+
result = MonitoringUtilities.monitorInstallation("DB", system, db, user=user)
3148
if not result["OK"]:
32-
print(f"ERROR: failed to register installation in database: {result['Message']}")
49+
gLogger.error("Failed to register installation in database:", result["Message"])
50+
DIRACExit(1)
3351

3452

3553
if __name__ == "__main__":

src/DIRAC/DataManagementSystem/scripts/dirac_admin_allow_se.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def main():
1717
remove = False
1818
site = ""
1919
mute = False
20+
userName = ""
2021

2122
Script.registerSwitch("r", "AllowRead", " Allow only reading from the storage element")
2223
Script.registerSwitch("w", "AllowWrite", " Allow only writing to the storage element")
@@ -25,6 +26,7 @@ def main():
2526
Script.registerSwitch("a", "All", " Allow all access to the storage element")
2627
Script.registerSwitch("m", "Mute", " Do not send email")
2728
Script.registerSwitch("S:", "Site=", " Allow all SEs associated to site")
29+
Script.registerSwitch("t:", "tokenOwner=", " Optional Name of the token owner")
2830
# Registering arguments will automatically add their description to the help menu
2931
Script.registerArgument(["seGroupList: list of SEs or comma-separated SEs"])
3032

@@ -48,6 +50,8 @@ def main():
4850
mute = True
4951
if switch[0].lower() in ("s", "site"):
5052
site = switch[1]
53+
if switch[0] in ("t", "tokenOwner"):
54+
userName = switch[1]
5155

5256
# imports
5357
from DIRAC import gLogger
@@ -69,15 +73,16 @@ def main():
6973
ses = resolveSEGroup(ses)
7074
diracAdmin = DiracAdmin()
7175

72-
res = getProxyInfo()
73-
if not res["OK"]:
74-
gLogger.error("Failed to get proxy information", res["Message"])
75-
DIRAC.exit(2)
76-
77-
userName = res["Value"].get("username")
7876
if not userName:
79-
gLogger.error("Failed to get username for proxy")
80-
DIRAC.exit(2)
77+
res = getProxyInfo()
78+
if not res["OK"]:
79+
gLogger.error("Failed to get proxy information", res["Message"])
80+
DIRAC.exit(2)
81+
82+
userName = res["Value"].get("username")
83+
if not userName:
84+
gLogger.error("Failed to get username for proxy")
85+
DIRAC.exit(2)
8186

8287
if site:
8388
res = getSites()

src/DIRAC/DataManagementSystem/scripts/dirac_admin_ban_se.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def main():
1818
remove = True
1919
sites = []
2020
mute = False
21+
userName = ""
2122

2223
Script.registerSwitch("r", "BanRead", " Ban only reading from the storage element")
2324
Script.registerSwitch("w", "BanWrite", " Ban writing to the storage element")
@@ -28,6 +29,7 @@ def main():
2829
Script.registerSwitch(
2930
"S:", "Site=", " Ban all SEs associate to site (note that if writing is allowed, check is always allowed)"
3031
)
32+
Script.registerSwitch("t:", "tokenOwner=", " Optional Name of the token owner")
3133
# Registering arguments will automatically add their description to the help menu
3234
Script.registerArgument(["seGroupList: list of SEs or comma-separated SEs"])
3335

@@ -56,6 +58,8 @@ def main():
5658
mute = True
5759
if switch[0].lower() in ("s", "site"):
5860
sites = switch[1].split(",")
61+
if switch[0] in ("t", "tokenOwner"):
62+
userName = switch[1]
5963

6064
# from DIRAC.ConfigurationSystem.Client.CSAPI import CSAPI
6165
from DIRAC import gLogger
@@ -68,15 +72,16 @@ def main():
6872
ses = resolveSEGroup(ses)
6973
diracAdmin = DiracAdmin()
7074

71-
res = getProxyInfo()
72-
if not res["OK"]:
73-
gLogger.error("Failed to get proxy information", res["Message"])
74-
DIRAC.exit(2)
75-
76-
userName = res["Value"].get("username")
7775
if not userName:
78-
gLogger.error("Failed to get username for proxy")
79-
DIRAC.exit(2)
76+
res = getProxyInfo()
77+
if not res["OK"]:
78+
gLogger.error("Failed to get proxy information", res["Message"])
79+
DIRAC.exit(2)
80+
81+
userName = res["Value"].get("username")
82+
if not userName:
83+
gLogger.error("Failed to get username for proxy")
84+
DIRAC.exit(2)
8085

8186
for site in sites:
8287
res = DMSHelpers().getSEsForSite(site)

src/DIRAC/FrameworkSystem/Client/ComponentInstaller.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
from DIRAC.ConfigurationSystem.Client import PathFinder
7070
from DIRAC.ConfigurationSystem.Client.CSAPI import CSAPI
7171
from DIRAC.ConfigurationSystem.Client.Helpers import (
72-
CSGlobals,
7372
cfgInstallPath,
7473
cfgInstallSection,
7574
cfgPath,
@@ -85,6 +84,7 @@
8584
PRODUCTION_MANAGEMENT,
8685
PROXY_MANAGEMENT,
8786
SERVICE_ADMINISTRATOR,
87+
SITE_MANAGER,
8888
TRUSTED_HOST,
8989
)
9090
from DIRAC.Core.Utilities.Extensions import (
@@ -432,6 +432,8 @@ def _getCentralCfg(self, installCfg):
432432
defaultHostProperties = [
433433
TRUSTED_HOST,
434434
CS_ADMINISTRATOR,
435+
SERVICE_ADMINISTRATOR,
436+
SITE_MANAGER,
435437
JOB_ADMINISTRATOR,
436438
FULL_DELEGATION,
437439
PROXY_MANAGEMENT,

src/DIRAC/FrameworkSystem/Client/SystemAdministratorClientCLI.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import time
1212

1313
from DIRAC import gConfig, gLogger
14-
from DIRAC.ConfigurationSystem.Client.Helpers import CSGlobals
1514
from DIRAC.Core.Base.CLI import CLI, colorize
1615
from DIRAC.Core.Security.ProxyInfo import getProxyInfo
1716
from DIRAC.Core.Utilities import List
@@ -623,6 +622,11 @@ def do_install(self, args):
623622
install agent <system> <agent> [-m <ModuleName>] [-p <Option>=<Value>] [-p <Option>=<Value>] ...
624623
install executor <system> <executor> [-m <ModuleName>] [-p <Option>=<Value>] [-p <Option>=<Value>] ...
625624
"""
625+
result = getProxyInfo()
626+
if not result["OK"]:
627+
self._errMsg(result["Message"])
628+
user = result["Value"]["username"]
629+
626630
argss = args.split()
627631
hostSetup = extension = None
628632
if not argss:
@@ -673,7 +677,7 @@ def do_install(self, args):
673677

674678
if database != "InstalledComponentsDB":
675679
result = MonitoringUtilities.monitorInstallation(
676-
"DB", system.replace("System", ""), database, cpu=cpu, hostname=hostname
680+
"DB", system.replace("System", ""), database, cpu=cpu, hostname=hostname, user=user
677681
)
678682
if not result["OK"]:
679683
self._errMsg(result["Message"])
@@ -786,14 +790,14 @@ def do_install(self, args):
786790
return
787791

788792
result = MonitoringUtilities.monitorInstallation(
789-
"DB", system, "InstalledComponentsDB", cpu=cpu, hostname=hostname
793+
"DB", system, "InstalledComponentsDB", cpu=cpu, hostname=hostname, user=user
790794
)
791795
if not result["OK"]:
792796
self._errMsg(f"Error registering installation into database: {result['Message']}")
793797
return
794798

795799
result = MonitoringUtilities.monitorInstallation(
796-
option, system, component, module, cpu=cpu, hostname=hostname
800+
option, system, component, module, cpu=cpu, hostname=hostname, user=user
797801
)
798802
if not result["OK"]:
799803
self._errMsg(f"Error registering installation into database: {result['Message']}")
@@ -820,6 +824,7 @@ def do_uninstall(self, args):
820824
result = getProxyInfo()
821825
if not result["OK"]:
822826
self._errMsg(result["Message"])
827+
user = result["Value"]["username"]
823828

824829
option = argss[0]
825830
if option == "db":
@@ -842,7 +847,7 @@ def do_uninstall(self, args):
842847
self._errMsg(result["Message"])
843848
return
844849
system = result["Value"][component]["System"]
845-
result = MonitoringUtilities.monitorUninstallation(system, component, hostname=hostname, cpu=cpu)
850+
result = MonitoringUtilities.monitorUninstallation(system, component, hostname=hostname, cpu=cpu, user=user)
846851
if not result["OK"]:
847852
self._errMsg(result["Message"])
848853
return
@@ -937,7 +942,7 @@ def do_uninstall(self, args):
937942
else:
938943
cpu = result["Value"]["CPUModel"]
939944
hostname = self.host
940-
result = MonitoringUtilities.monitorUninstallation(system, component, hostname=hostname, cpu=cpu)
945+
result = MonitoringUtilities.monitorUninstallation(system, component, hostname=hostname, cpu=cpu, user=user)
941946
if not result["OK"]:
942947
return result
943948

src/DIRAC/FrameworkSystem/ConfigTemplate.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ Services
167167
componentExists = authenticated
168168
getComponents = authenticated
169169
hostExists = authenticated
170+
installationExists = authenticated
170171
getHosts = authenticated
171172
installationExists = authenticated
172173
getInstallations = authenticated
@@ -184,6 +185,7 @@ Services
184185
componentExists = authenticated
185186
getComponents = authenticated
186187
hostExists = authenticated
188+
installationExists = authenticated
187189
getHosts = authenticated
188190
installationExists = authenticated
189191
getInstallations = authenticated

0 commit comments

Comments
 (0)