Skip to content

Commit

Permalink
Clean up references to UNF signature
Browse files Browse the repository at this point in the history
  • Loading branch information
mxsasha committed Nov 7, 2024
1 parent 3da7058 commit 3d94df0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
3 changes: 2 additions & 1 deletion irrd/integration_tests/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
SIGNED_PERSON_UPDATE_VALID,
)
from irrd.utils.whois_client import whois_query, whois_query_irrd
from ..mirroring.nrtm4 import UPDATE_NOTIFICATION_FILENAME

from ..utils.crypto import eckey_private_key_as_str, eckey_public_key_as_str
from .constants import (
Expand Down Expand Up @@ -963,7 +964,7 @@ def _start_irrds(self):
config3["irrd"]["rpki"]["roa_source"] = None
config3["irrd"]["sources"]["TEST"] = {
"keep_journal": True,
"nrtm4_client_notification_file_url": f"file://{self.nrtm4_dir2}update-notification-file.json",
"nrtm4_client_notification_file_url": f"file://{self.nrtm4_dir2}{UPDATE_NOTIFICATION_FILENAME}",
"nrtm4_client_initial_public_key": eckey_public_key_as_str(self.nrtm4_private_key),
}
with open(self.config_path3, "w") as yaml_file:
Expand Down
27 changes: 13 additions & 14 deletions irrd/mirroring/nrtm4/nrtm4_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

logger = logging.getLogger(__name__)

DANGLING_SNAPSHOT_UNF_SIGNATURE_EXPIRY_TIME = datetime.timedelta(minutes=5)
DANGLING_SNAPSHOT_EXPIRY_TIME = datetime.timedelta(minutes=5)


class NRTM4Server:
Expand Down Expand Up @@ -212,12 +212,12 @@ def _commit_status(self) -> None:
self._write_unf()

self.database_handler.record_nrtm4_server_status(self.source, self.status)
self._expire_snapshots_unf_signatures()
self._expire_snapshots()
self.database_handler.commit()

def _write_unf(self) -> None:
"""
Write the Update Notification File and signature.
Write the Update Notification File.
This is based on settings and self.status.
"""
assert self.status
Expand Down Expand Up @@ -279,22 +279,21 @@ def _expire_deltas(self) -> None:
file_path.unlink()
logger.debug(f"{self.source}: Removed dangling delta file {file_path.name}")

def _expire_snapshots_unf_signatures(self) -> None:
def _expire_snapshots(self) -> None:
"""
Expire old UNF signatures and old snapshots.
Expire old snapshots.
To avoid race conditions, these files are kept around after they
are no longer referred. This method cleans them up.
"""
assert self.status
patterns = ["update-notification-file-signature-*.sig", "nrtm-snapshot.*.json.gz"]
for pattern in patterns:
for file_path in self.path.glob(pattern):
modification_time = datetime.datetime.fromtimestamp(os.path.getmtime(file_path), tz=UTC)
if (
self.timestamp - modification_time > DANGLING_SNAPSHOT_UNF_SIGNATURE_EXPIRY_TIME
and file_path.name != self.status.last_snapshot_filename
):
file_path.unlink()
snapshot_pattern = "nrtm-snapshot.*.json.gz"
for file_path in self.path.glob(snapshot_pattern):
modification_time = datetime.datetime.fromtimestamp(os.path.getmtime(file_path), tz=UTC)
if (
self.timestamp - modification_time > DANGLING_SNAPSHOT_EXPIRY_TIME
and file_path.name != self.status.last_snapshot_filename
):
file_path.unlink()

def _write_snapshot(self, version: int) -> str:
"""
Expand Down

0 comments on commit 3d94df0

Please sign in to comment.