Skip to content

🐛 Concurrent S3 bucket creation attempt #8045

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

giancarloromeo
Copy link
Contributor

@giancarloromeo giancarloromeo commented Jul 4, 2025

What do these changes do?

This PR makes the setup of S3 in storage more robust, especially when trying to create the Bucket.

It would be ideal to move the creation out of the service, in a script, and not in the service logic.

Related issue/s

How to test

Dev-ops

@giancarloromeo giancarloromeo added this to the Engage milestone Jul 4, 2025
@giancarloromeo giancarloromeo self-assigned this Jul 4, 2025
@giancarloromeo giancarloromeo added the a:storage issue related to storage service label Jul 4, 2025
Copy link

codecov bot commented Jul 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 68.19%. Comparing base (4289fb0) to head (5af89e2).

❗ There is a different number of reports uploaded between BASE (4289fb0) and HEAD (5af89e2). Click for more details.

HEAD has 32 uploads less than BASE
Flag BASE (4289fb0) HEAD (5af89e2)
unittests 33 1
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #8045       +/-   ##
===========================================
- Coverage   87.89%   68.19%   -19.71%     
===========================================
  Files        1853      751     -1102     
  Lines       71495    35214    -36281     
  Branches     1258      176     -1082     
===========================================
- Hits        62843    24015    -38828     
- Misses       8287    11141     +2854     
+ Partials      365       58      -307     
Flag Coverage Δ
integrationtests 64.22% <ø> (-0.02%) ⬇️
unittests 86.30% <100.00%> (-0.24%) ⬇️
Components Coverage Δ
api ∅ <ø> (∅)
pkg_aws_library ∅ <ø> (∅)
pkg_celery_library ∅ <ø> (∅)
pkg_dask_task_models_library ∅ <ø> (∅)
pkg_models_library ∅ <ø> (∅)
pkg_notifications_library ∅ <ø> (∅)
pkg_postgres_database ∅ <ø> (∅)
pkg_service_integration ∅ <ø> (∅)
pkg_service_library ∅ <ø> (∅)
pkg_settings_library ∅ <ø> (∅)
pkg_simcore_sdk 76.92% <ø> (-8.13%) ⬇️
agent ∅ <ø> (∅)
api_server ∅ <ø> (∅)
autoscaling ∅ <ø> (∅)
catalog ∅ <ø> (∅)
clusters_keeper ∅ <ø> (∅)
dask_sidecar ∅ <ø> (∅)
datcore_adapter ∅ <ø> (∅)
director ∅ <ø> (∅)
director_v2 77.79% <ø> (-13.18%) ⬇️
dynamic_scheduler ∅ <ø> (∅)
dynamic_sidecar 88.33% <ø> (-1.77%) ⬇️
efs_guardian ∅ <ø> (∅)
invitations ∅ <ø> (∅)
payments ∅ <ø> (∅)
resource_usage_tracker ∅ <ø> (∅)
storage 86.30% <100.00%> (-0.06%) ⬇️
webclient ∅ <ø> (∅)
webserver 58.88% <ø> (-28.86%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4289fb0...5af89e2. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@giancarloromeo giancarloromeo changed the title 🐛 Concurrent S3 bucket creation 🐛 Concurrent S3 bucket creation attempt Jul 4, 2025
@giancarloromeo giancarloromeo marked this pull request as ready for review July 4, 2025 10:18
@giancarloromeo giancarloromeo requested a review from sanderegg as a code owner July 4, 2025 10:18
Copy link
Member

@sanderegg sanderegg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check my comments.

Also I do not agree with the "it should be done in a separate script". Why?

Comment on lines 57 to 64
if await client.bucket_exists(
bucket=settings.STORAGE_S3.S3_BUCKET_NAME
):
_logger.info(
"S3 bucket %s exists already, skipping creation",
settings.STORAGE_S3.S3_BUCKET_NAME,
)
break
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not needed, why do you add it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: the before_sleep_log is alreayd logging. If you want a different message per attempt, you can also customize it there. Check tenacity doc

log_context(
                _logger, logging.DEBUG, msg="setup.s3_bucket.cleanup_ctx"
            )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sanderegg well, the behavior seems clear: we want to ensure that S3 bucket has been created. Why not check if the bucket already exists before trying to blindly create it, that for 99% will end in an exception?

Comment on lines 57 to 64
if await client.bucket_exists(
bucket=settings.STORAGE_S3.S3_BUCKET_NAME
):
_logger.info(
"S3 bucket %s exists already, skipping creation",
settings.STORAGE_S3.S3_BUCKET_NAME,
)
break
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: the before_sleep_log is alreayd logging. If you want a different message per attempt, you can also customize it there. Check tenacity doc

log_context(
                _logger, logging.DEBUG, msg="setup.s3_bucket.cleanup_ctx"
            )

Copy link

sonarqubecloud bot commented Jul 4, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:storage issue related to storage service
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The sto-worker service fails to start due to concurrent S3 bucket creation during startup
4 participants