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

Storage/handle file overwrite #5108

Merged

Conversation

sanderegg
Copy link
Member

@sanderegg sanderegg commented Nov 29, 2023

What do these changes do?

This PR ensures that a file uploaded again first deletes the current file in the storage micro-service (both S3 and DB) before the links for uploading are returned.
The problem arose in #5102, where a file that was already uploaded before can be uploaded again only if no calls to GET /locations/{{location_id}}/files/{{file_id}}/metadata is done. If calls are done, there is a lazy mechanism in storage that fetches the file metadata from S3 to upgrade the database. As soon as this is called, then the upload information is wiped out of the database, which causes issues for multipart uploads (see remember how multipart upload works below)

Update from last changes:

  • makes use of AWS versioning if any (which is also reflected in the tests) --> it will revert to the latest version of the file if versioning exists, and revert the database accordingly.
  • re-use the fixtures from pytest-simcore
  • upgraded local minio version from RELEASE.2020-05-16T01-33-21Z to RELEASE.2023-12-02T10-51-33Z in order to enable versioning (as agreed verbally, people will need to delete their minio docker volume docker volume rm ops_minio_data)

remember how multipart upload works

  • ask storage to get an upload link (either 1 S3 link or N presigned links)
  • in case of presigned links, storage creates the multipart upload and handles the whole procedure
  • in case of S3 link which is the interesting in this case, storage cannot handle the procedure, therefore it marks the entry in file_metadata table as being currently uploaded, and an upload expiration date
  • whenever a client asks for the file metadata, storage will find that the file is currently in upload, and will ask S3 whether the file did not arrive in between (lazy modus). if it finds the file, then it fills the database and returns it.

In this case, since there was previously a file, S3 has information even though the brand new file is not uploaded yet.

Related issue/s

How to test

Dev Checklist

DevOps Checklist

@sanderegg sanderegg added the a:storage issue related to storage service label Nov 29, 2023
@sanderegg sanderegg added this to the Kobayashi Maru milestone Nov 29, 2023
@sanderegg sanderegg self-assigned this Nov 29, 2023
@sanderegg sanderegg force-pushed the storage/handle-file-overwrite branch from b0e447f to 7faf010 Compare November 29, 2023 16:14
Copy link

codecov bot commented Nov 29, 2023

Codecov Report

Merging #5108 (2afba7a) into master (2018f37) will increase coverage by 0.0%.
The diff coverage is 100.0%.

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #5108   +/-   ##
======================================
  Coverage    87.3%   87.4%           
======================================
  Files        1269    1269           
  Lines       52149   52174   +25     
  Branches     1129    1129           
======================================
+ Hits        45572   45611   +39     
+ Misses       6337    6323   -14     
  Partials      240     240           
Flag Coverage Δ
integrationtests 64.8% <100.0%> (+<0.1%) ⬆️
unittests 85.2% <91.1%> (+<0.1%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...k/src/simcore_sdk/node_ports_common/filemanager.py 85.2% <100.0%> (+0.6%) ⬆️
...rage/src/simcore_service_storage/handlers_files.py 99.1% <ø> (ø)
...s/storage/src/simcore_service_storage/s3_client.py 98.8% <100.0%> (+0.1%) ⬆️
...rage/src/simcore_service_storage/simcore_s3_dsm.py 94.5% <100.0%> (+0.1%) ⬆️

... and 6 files with indirect coverage changes

@sanderegg sanderegg force-pushed the storage/handle-file-overwrite branch from 7faf010 to ed21a43 Compare November 30, 2023 07:56
Copy link
Contributor

@bisgaard-itis bisgaard-itis left a comment

Choose a reason for hiding this comment

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

Nice! Thanks for fixing this

Copy link
Contributor

@GitHK GitHK left a comment

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@ignapas ignapas left a comment

Choose a reason for hiding this comment

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

🥇

Copy link
Member

@pcrespov pcrespov left a comment

Choose a reason for hiding this comment

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

🎉 amazing!

@sanderegg sanderegg force-pushed the storage/handle-file-overwrite branch from e2ead8f to 81954d2 Compare December 1, 2023 08:19
@sanderegg sanderegg mentioned this pull request Dec 2, 2023
3 tasks
Copy link
Contributor

@matusdrobuliak66 matusdrobuliak66 left a comment

Choose a reason for hiding this comment

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

Thanks 👍

@sanderegg sanderegg force-pushed the storage/handle-file-overwrite branch from b12efec to 2afba7a Compare December 3, 2023 20:53
Copy link

sonarqubecloud bot commented Dec 3, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link

codeclimate bot commented Dec 3, 2023

Code Climate has analyzed commit 2afba7a and detected 0 issues on this pull request.

View more on Code Climate.

@sanderegg sanderegg merged commit a399895 into ITISFoundation:master Dec 4, 2023
65 checks passed
@sanderegg sanderegg deleted the storage/handle-file-overwrite branch December 4, 2023 08:10
@elisabettai elisabettai mentioned this pull request Dec 11, 2023
33 tasks
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.

7 participants