From 6e69f335cd4a93b974cb6f37349027a96ad0a3f3 Mon Sep 17 00:00:00 2001 From: Prowler Bot Date: Fri, 12 Dec 2025 11:10:40 +0100 Subject: [PATCH] fix(api): add one second countdown to scheduled scan task to ensure transaction completion (#9528) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Adrián Peña --- api/CHANGELOG.md | 6 +++++- api/src/backend/api/specs/v1.yaml | 2 +- api/src/backend/api/v1/views.py | 2 +- api/src/backend/tasks/beat.py | 1 + api/src/backend/tasks/tests/test_beat.py | 1 + 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/api/CHANGELOG.md b/api/CHANGELOG.md index 3f8786f691..04604e023c 100644 --- a/api/CHANGELOG.md +++ b/api/CHANGELOG.md @@ -2,6 +2,11 @@ All notable changes to the **Prowler API** are documented in this file. +## [1.16.1] (Prowler v5.15.1) + +### Fixed +- Race condition in scheduled scan creation by adding countdown to task [(#9516)](https://github.com/prowler-cloud/prowler/pull/9516) + ## [1.16.0] (Prowler v5.15.0) ### Added @@ -12,7 +17,6 @@ All notable changes to the **Prowler API** are documented in this file. - Support to use admin credentials through the read replica database [(#9440)](https://github.com/prowler-cloud/prowler/pull/9440) ### Changed - - Error messages from Lighthouse celery tasks [(#9165)](https://github.com/prowler-cloud/prowler/pull/9165) - Restore the compliance overview endpoint's mandatory filters [(#9338)](https://github.com/prowler-cloud/prowler/pull/9338) diff --git a/api/src/backend/api/specs/v1.yaml b/api/src/backend/api/specs/v1.yaml index 8aa1757457..32bce0a8f9 100644 --- a/api/src/backend/api/specs/v1.yaml +++ b/api/src/backend/api/specs/v1.yaml @@ -1,7 +1,7 @@ openapi: 3.0.3 info: title: Prowler API - version: 1.16.0 + version: 1.16.1 description: |- Prowler API specification. diff --git a/api/src/backend/api/v1/views.py b/api/src/backend/api/v1/views.py index e1b68cddf1..ddead0d992 100644 --- a/api/src/backend/api/v1/views.py +++ b/api/src/backend/api/v1/views.py @@ -357,7 +357,7 @@ class SchemaView(SpectacularAPIView): def get(self, request, *args, **kwargs): spectacular_settings.TITLE = "Prowler API" - spectacular_settings.VERSION = "1.16.0" + spectacular_settings.VERSION = "1.16.1" spectacular_settings.DESCRIPTION = ( "Prowler API specification.\n\nThis file is auto-generated." ) diff --git a/api/src/backend/tasks/beat.py b/api/src/backend/tasks/beat.py index a7795e6909..a12002ac1a 100644 --- a/api/src/backend/tasks/beat.py +++ b/api/src/backend/tasks/beat.py @@ -61,4 +61,5 @@ def schedule_provider_scan(provider_instance: Provider): "tenant_id": str(provider_instance.tenant_id), "provider_id": provider_id, }, + countdown=1, # Avoid race conditions between the worker and the database ) diff --git a/api/src/backend/tasks/tests/test_beat.py b/api/src/backend/tasks/tests/test_beat.py index 7a1656553f..e231e17f6a 100644 --- a/api/src/backend/tasks/tests/test_beat.py +++ b/api/src/backend/tasks/tests/test_beat.py @@ -28,6 +28,7 @@ class TestScheduleProviderScan: "tenant_id": str(provider_instance.tenant_id), "provider_id": str(provider_instance.id), }, + countdown=1, ) task_name = f"scan-perform-scheduled-{provider_instance.id}"