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

Implement semi-atomic push #2689

Merged
merged 8 commits into from
Feb 22, 2022
Merged

Implement semi-atomic push #2689

merged 8 commits into from
Feb 22, 2022

Conversation

dimaryaz
Copy link
Contributor

@dimaryaz dimaryaz commented Feb 18, 2022

Make Package.push fail if the destination already contains a package with a top hash that's different from the current package's parent.

Make Package.push fail if the destination already contains a package with a top hash that's different from the current package's parent.

TODO: Fix unit tests
@dimaryaz dimaryaz changed the title WIP: Semi-atomic push Implement semi-atomic push Feb 19, 2022
@codecov
Copy link

codecov bot commented Feb 19, 2022

Codecov Report

Merging #2689 (f850716) into master (12b23cb) will increase coverage by 0.09%.
The diff coverage is 98.38%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2689      +/-   ##
==========================================
+ Coverage   41.45%   41.54%   +0.09%     
==========================================
  Files         536      536              
  Lines       24791    24831      +40     
  Branches     3380     3380              
==========================================
+ Hits        10276    10315      +39     
- Misses      13742    13743       +1     
  Partials      773      773              
Flag Coverage Δ
api-python 90.66% <98.38%> (+0.04%) ⬆️
catalog 13.20% <ø> (ø)
lambda 88.05% <ø> (ø)

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

Impacted Files Coverage Δ
api/python/quilt3/packages.py 92.89% <95.65%> (+0.01%) ⬆️
api/python/quilt3/util.py 83.27% <100.00%> (+0.11%) ⬆️
api/python/tests/integration/test_packages.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

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

raise

if self._origin is None or latest_hash != self._origin.top_hash:
raise QuiltException(
Copy link
Member

Choose a reason for hiding this comment

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

Might make sense to add specific subclass of QuiltException for that.


if self._origin is None or latest_hash != self._origin.top_hash:
raise QuiltException(
f"Package with an unexpected hash {latest_hash} already exists at the destination; "
Copy link
Member

Choose a reason for hiding this comment

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

Might make sense to specify both expected and actual hashes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok

@@ -462,7 +474,7 @@ def add_pkg_file(pkg, lk, filename, data, *, version):
)
with patch('time.time', return_value=timestamp1), \
patch('quilt3.data_transfer.MAX_CONCURRENCY', 1):
remote_pkg = new_pkg.push(pkg_name, registry)
remote_pkg = new_pkg.push(pkg_name, registry, force=True)
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need force=True here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because otherwise, it makes extra S3 calls, so I'd need to mock those. I guess setup_s3_stubber_push_manifest could be updated to mock them by default, but force=True plus a new unit test for push conflicts seemed simpler.

Copy link
Member

Choose a reason for hiding this comment

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

but force=True plus a new unit test for push conflicts seemed simpler

Well, yes, it's simpler, but are we going to use force=True in every new test?

@sir-sigurd sir-sigurd merged commit 59c3aa1 into master Feb 22, 2022
@sir-sigurd sir-sigurd deleted the semiatomic_push branch February 22, 2022 08:50
sir-sigurd added a commit that referenced this pull request Feb 22, 2022
sir-sigurd added a commit that referenced this pull request Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants