Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-10 08:39:07

0001 """
0002 Checking DB schema version for PanDA Server.
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 pandaserver.config import panda_config
0010 from pandaserver.srvcore.MailUtils import MailUtils
0011 from pandaserver.taskbuffer import PandaDBSchemaInfo
0012 from pandaserver.taskbuffer.OraDBProxy import DBProxy
0013 
0014 proxyS = DBProxy()
0015 proxyS.connect(panda_config.dbhost, panda_config.dbpasswd, panda_config.dbuser, panda_config.dbname)
0016 
0017 sql = "select major || '.' || minor || '.' || patch from ATLAS_PANDA.pandadb_version where component = 'PanDA'"
0018 
0019 res = proxyS.querySQL(sql)
0020 dbVersion = res[0][0]
0021 
0022 serverDBVersion = PandaDBSchemaInfo.PandaDBSchemaInfo().method()
0023 
0024 if version.parse(dbVersion) >= version.parse(serverDBVersion):
0025     print("DB schema check: OK")
0026 else:
0027     message_body = (
0028         f"There is an issue with {panda_config.pserveralias}. "
0029         f"PanDA DB schema installed is {dbVersion} while PanDA Server requires "
0030         f"version {serverDBVersion} to be installed. Please check the official docs "
0031         f"for instructions on how to upgrade the schema."
0032     )
0033     print(message_body)
0034 
0035     if "pandaEmailNotification" in panda_config.__dict__:
0036         MailUtils().send(
0037             panda_config.pandaEmailNotification,
0038             f"PanDA DB Version installed is not correct for {panda_config.pserveralias}",
0039             message_body,
0040         )