From 5d91a7dae3866855d8b166a50e0d72ed6acecd2d Mon Sep 17 00:00:00 2001 From: sayalibhavsar <36536724+sayalibhavsar@users.noreply.github.com> Date: Mon, 26 Aug 2024 20:16:07 +0530 Subject: [PATCH 1/5] logging: hide entries when debuglog is set to false and add missing worker names (PROJQUAY-6562) (#3160) * deps: bump PyMySQL version (PROJQUAY-7251) (#3113) bug: bump PyMySQL version (PROJQUAY-7251) This should resolve CVE-2024-36039. * hide logs if debuglog is false * test for new allocator.py code changes * test for new allocator.py code changes --------- Co-authored-by: Ivan Bazulic --- util/migrate/allocator.py | 11 ++++++- util/migrate/test/test_backfill_allocator.py | 30 ++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/util/migrate/allocator.py b/util/migrate/allocator.py index 206bd0e2e8..a492d2e734 100644 --- a/util/migrate/allocator.py +++ b/util/migrate/allocator.py @@ -1,11 +1,20 @@ import logging +import os import random from threading import Event from bintrees import RBTree logger = logging.getLogger(__name__) -logger.setLevel(logging.DEBUG) # Set the default log level to DEBUG + +# Read the DEBUGLOG environment variable +debug_log = os.getenv("DEBUGLOG", "false").lower() == "true" + +# Set the logging level based on DEBUGLOG +if debug_log: + logging.basicConfig(level=logging.DEBUG) +else: + logging.basicConfig(level=logging.INFO) class NoAvailableKeysError(ValueError): diff --git a/util/migrate/test/test_backfill_allocator.py b/util/migrate/test/test_backfill_allocator.py index dd5e781c9b..8706df3930 100644 --- a/util/migrate/test/test_backfill_allocator.py +++ b/util/migrate/test/test_backfill_allocator.py @@ -1,5 +1,8 @@ +import logging +import os import random from datetime import datetime, timedelta +from unittest.mock import patch import pytest @@ -10,6 +13,33 @@ ) +# Utility function to configure logging based on DEBUGLOG environment variable +def configure_logging(): + debug_log = os.getenv("DEBUGLOG", "false").lower() == "true" + level = logging.DEBUG if debug_log else logging.INFO + logging.basicConfig(level=level) + + +# Test to verify logging setup +def test_logging_setup(): + with patch("logging.basicConfig") as mock_basic_config: + + # Test with DEBUGLOG set to "true" + os.environ["DEBUGLOG"] = "true" + configure_logging() + mock_basic_config.assert_called_once_with(level=logging.DEBUG) + mock_basic_config.reset_mock() # Reset mock for the next test + + # Test with DEBUGLOG set to "false" + os.environ["DEBUGLOG"] = "false" + configure_logging() + mock_basic_config.assert_called_once_with(level=logging.INFO) + mock_basic_config.reset_mock() # Reset mock for the next test + + # Clean up environment variable + os.environ.pop("DEBUGLOG") + + def test_merge_blocks_operations(): candidates = CompletedKeys(10) assert candidates.num_remaining == 10 From 6a7beacb92558f8df9acbac32285e23da6f8f259 Mon Sep 17 00:00:00 2001 From: Michaela Lang <94735640+michaelalang@users.noreply.github.com> Date: Tue, 27 Aug 2024 15:39:55 +0200 Subject: [PATCH 2/5] storage(StorageClasses): Presign v2/v4 stsfix (PROJQUAY-7689) (#3154) fixing the error seen with signature_v2/v4 patch #3041 when using STSS3Storage. The STSS3Storage Class is using the connect_kwargs dictionary to initialze the S3Storage Class where all other use that dict for the connection parameters which is misleading and I did not catch that when submitting the patch for the signature v2/v4 --- storage/cloud.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/storage/cloud.py b/storage/cloud.py index 349f81880c..5b268240fe 100644 --- a/storage/cloud.py +++ b/storage/cloud.py @@ -1243,7 +1243,7 @@ def __init__( s3_region=None, endpoint_url=None, maximum_chunk_size_gb=None, - signature_version=None, + signature_version="s3v4", ): sts_client = boto3.client( "sts", aws_access_key_id=sts_user_access_key, aws_secret_access_key=sts_user_secret_key @@ -1257,6 +1257,7 @@ def __init__( method="sts-assume-role", ) + # !! NOTE !! connect_kwargs here initializes the S3Storage Class not the s3 connection (mis leading re-use of the name) connect_kwargs = { "s3_access_key": credentials["AccessKeyId"], "s3_secret_key": credentials["SecretAccessKey"], @@ -1265,7 +1266,7 @@ def __init__( "endpoint_url": endpoint_url, "maximum_chunk_size_gb": maximum_chunk_size_gb, "deferred_refreshable_credentials": deferred_refreshable_credentials, - "config": Config(signature_version=signature_version), + "signature_version": signature_version, } super().__init__(context, storage_path, s3_bucket, **connect_kwargs) From 06a816dd448819e7191b1420d4d7ddae206bfa7f Mon Sep 17 00:00:00 2001 From: Sunandadadi Date: Thu, 29 Aug 2024 11:41:36 -0400 Subject: [PATCH 3/5] ui: removing image expiry trigger option for old ui (PROJQUAY-7735) (#3173) * ui: removing image expiry trigger option for old ui (PROJQUAY-7735) * remove trailing whitespace --- static/directives/create-external-notification.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/static/directives/create-external-notification.html b/static/directives/create-external-notification.html index 115205a9bd..9a83e5988b 100644 --- a/static/directives/create-external-notification.html +++ b/static/directives/create-external-notification.html @@ -16,7 +16,8 @@