Skip to content

Commit 90c38d1

Browse files
feat: run dirac legacy cs-sync on CS commit
1 parent 6af749c commit 90c38d1

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

src/DIRAC/ConfigurationSystem/private/Modificator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from diraccfg import CFG
88

9-
from DIRAC import gLogger
9+
from DIRAC import S_ERROR
1010
from DIRAC.ConfigurationSystem.Client.ConfigurationData import gConfigurationData
1111
from DIRAC.Core.Security.ProxyInfo import getProxyInfo
1212
from DIRAC.Core.Utilities import List
@@ -244,7 +244,7 @@ def __str__(self):
244244
def commit(self):
245245
resVerif = diracxVerifyConfig(self.cfgData)
246246
if not resVerif["OK"]:
247-
gLogger.warn(resVerif["Message"])
247+
return S_ERROR(resVerif["Message"])
248248
compressedData = zlib.compress(str(self.cfgData).encode(), 9)
249249
return self.rpcClient.commitNewData(compressedData)
250250

src/DIRAC/FrameworkSystem/Utilities/diracx.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1+
import os
2+
import re
3+
import subprocess
14
from collections.abc import Generator
25
from contextlib import contextmanager
36
from pathlib import Path
47
from tempfile import NamedTemporaryFile
8+
import tempfile
59
from typing import Any
610

711
import requests
812
from cachetools import LRUCache, TTLCache, cached
913
from cachetools.keys import hashkey
14+
from diracx.cli.internal.legacy import _apply_fixes
1015
from diracx.core.config.schema import Config as DiracxConfig
1116
from diracx.core.models import TokenResponse
1217
from diracx.core.preferences import DiracxPreferences
@@ -115,9 +120,17 @@ def diracxVerifyConfig(cfgData):
115120
Returns:
116121
S_OK | S_ERROR: Value: diracx Config validation
117122
"""
118-
cfg = cfgData.getAsDict()
119-
try:
120-
validation = DiracxConfig.model_validate(cfg)
121-
except ValidationError as exc:
122-
return S_ERROR(exc)
123-
return S_OK(validation)
123+
os.environ["DIRAC_COMPAT_ENABLE_CS_CONVERSION"] = "true"
124+
with tempfile.NamedTemporaryFile() as temp_cfg:
125+
with tempfile.NamedTemporaryFile() as temp_diracx_cfg:
126+
cfgData.writeToFile(temp_cfg)
127+
cmd = ["dirac", "internal", "legacy", "cs-sync", temp_cfg, temp_diracx_cfg]
128+
res = subprocess.run(cmd, capture_output=True, text=True, timeout=15)
129+
os.environ.pop("DIRAC_COMPAT_ENABLE_CS_CONVERSION")
130+
if res.returncode == 0:
131+
return S_OK(res.stdout)
132+
else:
133+
err = res.stderr.strip()
134+
match = re.search(r"(ValidationError:.*)", err, flags=re.DOTALL)
135+
if match:
136+
return S_ERROR(match.group(1))

0 commit comments

Comments
 (0)