Skip to content

Commit 22df4d8

Browse files
Improves logging and test debug visibility
Adds detailed debug logging to lock acquisition, enhances pytest output with DEBUG logs for CI, and clarifies mock subsystem setup for test reliability. Facilitates easier diagnosis of concurrency and storage issues.
1 parent e43e858 commit 22df4d8

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

packages/service-library/src/servicelib/redis/_decorators.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ def exclusive(
5353
lock_key -- a string as the name of the lock (good practice: app_name:lock_name)
5454
lock_value -- some additional data that can be retrieved by another client if None,
5555
it will be automatically filled with the current time and the client name
56+
blocking -- If ``blocking`` is False, always return immediately. If the lock
57+
was acquired, return True, otherwise return False.
58+
blocking_timeout -- specifies the maximum number of seconds to
59+
wait trying to acquire the lock.
5660
5761
Raises:
5862
- ValueError if used incorrectly
@@ -85,14 +89,21 @@ async def _wrapper(*args: P.args, **kwargs: P.kwargs) -> R:
8589
lock_value = f"locked since {arrow.utcnow().format()} by {client.client_name} on {socket.gethostname()}"
8690

8791
lock = client.create_lock(redis_lock_key, ttl=DEFAULT_LOCK_TTL)
92+
_logger.debug(
93+
"Acquiring lock '%s' with value '%s' for coroutine '%s'",
94+
redis_lock_key,
95+
lock_value,
96+
coro.__name__,
97+
stacklevel=3,
98+
)
8899
if not await lock.acquire(
89100
token=lock_value,
90101
blocking=blocking,
91102
blocking_timeout=(
92103
blocking_timeout.total_seconds() if blocking_timeout else None
93104
),
94105
):
95-
raise CouldNotAcquireLockError(lock=lock)
106+
raise CouldNotAcquireLockError(lock=lock) # <-- HERE
96107

97108
try:
98109
async with asyncio.TaskGroup() as tg:

scripts/common-service.Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ _run-test-ci: _check_venv_active
175175
--log-date-format="%Y-%m-%d %H:%M:%S" \
176176
--log-format="%(asctime)s %(levelname)s %(message)s" \
177177
--verbose \
178+
--log-cli-level=DEBUG \
178179
-m "not heavy_load" \
179180
$(PYTEST_ADDITIONAL_PARAMETERS) \
180181
$(TEST_TARGET)

services/web/server/src/simcore_service_webserver/projects/_projects_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1060,7 +1060,7 @@ async def _remove_service_and_its_data_folders(
10601060
)
10611061

10621062
# remove the node's data if any
1063-
await storage_service.delete_data_folders_of_project_node(
1063+
await storage_service.delete_data_folders_of_project_node( # <-- MD: this one
10641064
app, f"{project_uuid}", node_uuid, user_id
10651065
)
10661066

services/web/server/tests/unit/with_dbs/conftest.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,12 @@ async def _mock_result() -> None:
417417
return_value=TypeAdapter(ByteSize).validate_python("1Gib"),
418418
)
419419

420-
return MockedStorageSubsystem(mock, mock1, mock2, mock3)
420+
return MockedStorageSubsystem(
421+
copy_data_folders_from_project=mock,
422+
delete_project=mock1,
423+
delete_node=mock2,
424+
get_project_total_size_simcore_s3=mock3,
425+
)
421426

422427

423428
@pytest.fixture

0 commit comments

Comments
 (0)