Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(exports): change the way to remove the local export files after s3 upload #7224

Merged
merged 2 commits into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ All notable changes to the **Prowler API** are documented in this file.

---

## [v1.5.1] (Prowler v5.4.1)

### Fixed
- Fixed a race condition when deleting export files after the S3 upload [(#7172)](https://github.com/prowler-cloud/prowler/pull/7172).

---

## [v1.5.0] (Prowler v5.4.0)

### Added
Expand Down
3 changes: 3 additions & 0 deletions api/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ description = "Prowler's API (Django/DRF)"
license = "Apache-2.0"
name = "prowler-api"
package-mode = false
version = "1.5.0"
version = "1.5.1"

[tool.poetry.dependencies]
celery = {extras = ["pytest"], version = "^5.4.0"}
Expand Down
2 changes: 1 addition & 1 deletion api/src/backend/api/specs/v1.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
openapi: 3.0.3
info:
title: Prowler API
version: 1.5.0
version: 1.5.1
description: |-
Prowler API specification.

Expand Down
2 changes: 1 addition & 1 deletion api/src/backend/api/v1/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@

def get(self, request, *args, **kwargs):
spectacular_settings.TITLE = "Prowler API"
spectacular_settings.VERSION = "1.5.0"
spectacular_settings.VERSION = "1.5.1"

Check warning on line 242 in api/src/backend/api/v1/views.py

View check run for this annotation

Codecov / codecov/patch

api/src/backend/api/v1/views.py#L242

Added line #L242 was not covered by tests
spectacular_settings.DESCRIPTION = (
"Prowler API specification.\n\nThis file is auto-generated."
)
Expand Down
9 changes: 7 additions & 2 deletions api/src/backend/tasks/tasks.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from pathlib import Path
from shutil import rmtree

from celery import chain, shared_task
Expand Down Expand Up @@ -264,10 +265,14 @@
uploaded = _upload_to_s3(tenant_id, output_directory, scan_id)

if uploaded:
# Remove the local files after upload
try:
rmtree(Path(output_directory).parent, ignore_errors=True)
except FileNotFoundError as e:
logger.error(f"Error deleting output files: {e}")

Check warning on line 272 in api/src/backend/tasks/tasks.py

View check run for this annotation

Codecov / codecov/patch

api/src/backend/tasks/tasks.py#L269-L272

Added lines #L269 - L272 were not covered by tests

output_directory = uploaded
uploaded = True
# Remove the local files after upload
rmtree(DJANGO_TMP_OUTPUT_DIRECTORY, ignore_errors=True)
else:
uploaded = False

Expand Down
Loading
Loading