From db6c2fd5e42cb387c78bcdd9899597b9ba120357 Mon Sep 17 00:00:00 2001 From: Will Murphy Date: Tue, 30 Jul 2024 17:04:16 -0400 Subject: [PATCH 1/2] chore: shrink listing file to speed download times The listing file is large enough and frequently enough downloaded that we expect better performance with a smaller listing database file. Signed-off-by: Will Murphy --- manager/src/grype_db_manager/distribution.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manager/src/grype_db_manager/distribution.py b/manager/src/grype_db_manager/distribution.py index ffc486c5..135ee8ff 100644 --- a/manager/src/grype_db_manager/distribution.py +++ b/manager/src/grype_db_manager/distribution.py @@ -17,8 +17,8 @@ from collections.abc import Generator DB_SUFFIXES = {".tar.gz", ".tar.zst"} -MAX_DB_AGE = 120 # ~4 months in days -MINIMUM_DB_COUNT = MAX_DB_AGE # number of db entries per schema +MAX_DB_AGE = 7 # old db listings are making the file large and slowing download times +MINIMUM_DB_COUNT = 2 # always include at least 2 databases, no matter how old def listing_entries_dbs_in_s3( From b56697d657797440ba4608afdfe3bebab2a5ed23 Mon Sep 17 00:00:00 2001 From: Will Murphy Date: Fri, 2 Aug 2024 14:19:21 -0400 Subject: [PATCH 2/2] chore: fix units on MAX_DB_AGE Signed-off-by: Will Murphy --- manager/src/grype_db_manager/distribution.py | 4 ++-- manager/tests/unit/cli/test_listing.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/manager/src/grype_db_manager/distribution.py b/manager/src/grype_db_manager/distribution.py index 135ee8ff..a4a7a66e 100644 --- a/manager/src/grype_db_manager/distribution.py +++ b/manager/src/grype_db_manager/distribution.py @@ -17,8 +17,8 @@ from collections.abc import Generator DB_SUFFIXES = {".tar.gz", ".tar.zst"} -MAX_DB_AGE = 7 # old db listings are making the file large and slowing download times -MINIMUM_DB_COUNT = 2 # always include at least 2 databases, no matter how old +MAX_DB_AGE = 3 # old db listings are making the file large and slowing download times +MINIMUM_DB_COUNT = 3 # always include at least 2 databases, no matter how old def listing_entries_dbs_in_s3( diff --git a/manager/tests/unit/cli/test_listing.py b/manager/tests/unit/cli/test_listing.py index e570f158..3d92b34f 100644 --- a/manager/tests/unit/cli/test_listing.py +++ b/manager/tests/unit/cli/test_listing.py @@ -137,7 +137,7 @@ def test_create_listing( # contains an application config file config_dir_path = test_dir_path(f"fixtures/listing/{case_dir}") listing_s3_mock(config_dir_path, extra_dbs=extra_dbs) - mock_file_age.return_value = 42 # needs to be less than distribution.MAX_DB_AGE + mock_file_age.return_value = 2 # needs to be less than distribution.MAX_DB_AGE with utils.set_directory(config_dir_path): with open("expected-listing.json") as f: