File indexing completed on 2026-04-10 08:39:00
0001 """
0002 Checking DB schema version for PanDA JEDI.
0003 If there is an issue and the pandaEmailNotification var is
0004 defined in panda_config, it will send an email notification.
0005 """
0006
0007 from packaging import version
0008
0009 from pandajedi.jediconfig import jedi_config
0010 from pandajedi.jedicore import JediDBSchemaInfo
0011 from pandajedi.jedicore.JediDBProxy import DBProxy
0012 from pandaserver.config import panda_config
0013 from pandaserver.srvcore.MailUtils import MailUtils
0014
0015 proxyS = DBProxy()
0016 proxyS.connect(jedi_config.db.dbhost, jedi_config.db.dbpasswd, jedi_config.db.dbuser, jedi_config.db.dbname)
0017
0018 sql = "select major || '.' || minor || '.' || patch from ATLAS_PANDA.pandadb_version where component = 'PanDA'"
0019
0020 res = proxyS.querySQL(sql)
0021 dbVersion = res[0][0]
0022
0023 serverDBVersion = JediDBSchemaInfo.JediDBSchemaInfo().method()
0024
0025 if version.parse(dbVersion) >= version.parse(serverDBVersion):
0026 print("DB schema check: OK")
0027 else:
0028 msgBody = (
0029 "There is an issue with "
0030 + panda_config.pserveralias
0031 + ". PanDA DB schema installed is "
0032 + dbVersion
0033 + " while PanDA JEDI requires version "
0034 + serverDBVersion
0035 + " to be installed. Please check the official docs for instructions on how to upgrade the schema."
0036 )
0037 print(msgBody)
0038 if "pandaEmailNotification" in panda_config.__dict__:
0039 MailUtils().send(
0040 panda_config.pandaEmailNotification, "PanDA DB Version installed is not correct for JEDI running on " + panda_config.pserveralias, msgBody
0041 )