Skip to content

Commit

Permalink
Reduce SQLAlchemy warnings (#979)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxsasha authored Dec 2, 2024
1 parent e65fe70 commit e85c6f8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
19 changes: 13 additions & 6 deletions irrd/daemon/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import signal
import sys
import time
import warnings
from pathlib import Path
from typing import Optional, Tuple

Expand All @@ -22,6 +23,8 @@
logger = logging.getLogger(__name__)
sys.path.append(str(Path(__file__).resolve().parents[2]))

import sqlalchemy.exc as sa_exc

from irrd import ENV_MAIN_PROCESS_PID, ENV_MAIN_STARTUP_TIME, __version__
from irrd.conf import CONFIG_PATH_DEFAULT, config_init, get_configuration, get_setting
from irrd.mirroring.scheduler import MirrorScheduler
Expand Down Expand Up @@ -119,12 +122,16 @@ def main():
try:
with PidFile(pidname="irrd", piddir=piddir):
logger.info(f"IRRd {__version__} starting, PID {os.getpid()}, PID file in {piddir}")
run_irrd(
mirror_frequency=MIRROR_FREQUENCY,
config_file_path=args.config_file_path if args.config_file_path else CONFIG_PATH_DEFAULT,
uid=uid,
gid=gid,
)
with warnings.catch_warnings():
warnings.simplefilter("ignore", category=sa_exc.SAWarning)
run_irrd(
mirror_frequency=MIRROR_FREQUENCY,
config_file_path=(
args.config_file_path if args.config_file_path else CONFIG_PATH_DEFAULT
),
uid=uid,
gid=gid,
)
except PidFileError as pfe:
logger.error(f"Failed to start IRRd, unable to lock PID file irrd.pid in {piddir}: {pfe}")
except Exception as e:
Expand Down
5 changes: 5 additions & 0 deletions irrd/storage/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ class AuthUser(Base): # type: ignore
permissions = relationship(
"AuthPermission",
backref=sa.orm.backref("user", uselist=False),
overlaps="mntners,mntners_user_management,mntners_no_user_management",
)
webauthns = relationship(
"AuthWebAuthn",
Expand All @@ -422,20 +423,23 @@ class AuthUser(Base): # type: ignore
"join(AuthPermission, AuthMntner, and_(AuthMntner.pk==AuthPermission.mntner_id,"
" AuthMntner.migration_token.is_(None)))"
),
overlaps="permissions,user,users",
)
mntners_user_management = relationship(
"AuthMntner",
secondary=(
"join(AuthPermission, AuthMntner, and_(AuthMntner.pk==AuthPermission.mntner_id,"
" AuthMntner.migration_token.is_(None),AuthPermission.user_management==True))"
),
overlaps="user,users,mntners,mntners_no_user_management",
)
mntners_no_user_management = relationship(
"AuthMntner",
secondary=(
"join(AuthPermission, AuthMntner, and_(AuthMntner.pk==AuthPermission.mntner_id,"
" AuthMntner.migration_token.is_(None),AuthPermission.user_management==False))"
),
overlaps="user,users,mntners,mntners_user_management",
)

created = sa.Column(sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False)
Expand Down Expand Up @@ -553,6 +557,7 @@ class AuthMntner(Base): # type: ignore
permissions = relationship(
"AuthPermission",
backref=sa.orm.backref("mntner", uselist=False),
overlaps="users,mntners,mntners_user_management,mntners_no_user_management",
)

created = sa.Column(sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False)
Expand Down

0 comments on commit e85c6f8

Please sign in to comment.