-
Notifications
You must be signed in to change notification settings - Fork 4
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
Release extra files in dst after upload #150
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,6 +113,10 @@ def _remove_snapshotfile(self, snapshotfile: SnapshotFile) -> None: | |
if snapshotfile.hexdigest: | ||
self.hexdigest_to_snapshotfiles[snapshotfile.hexdigest].remove(snapshotfile) | ||
|
||
def _release_snapshotfile(self, snapshotfile: SnapshotFile) -> None: | ||
dst_path = self.dst / snapshotfile.relative_path | ||
dst_path.unlink(missing_ok=True) | ||
|
||
def _snapshotfile_from_path(self, relative_path) -> SnapshotFile: | ||
src_path = self.src / relative_path | ||
st = src_path.stat() | ||
|
@@ -273,3 +277,9 @@ def _result_cb(*, map_in: SnapshotFile, map_out: SnapshotFile) -> bool: | |
progress.add_success() | ||
|
||
return changes | ||
|
||
def release(self, hexdigest: str) -> None: | ||
assert self.lock.locked() | ||
assert self.src != self.dst | ||
for snapshotfile in self.hexdigest_to_snapshotfiles.get(hexdigest, []): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The snapshot will get out of sync with the disk here. Is that is so that we don't recompute hashes in case a file is not deleted? We will need to be careful to always re-link all files when creating a new snapshot in the SQLLite PR (if I ever get around to finishing that), also obviously if an upload is ever run after this step looks like it will skip the files. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the upload would fail (because it'll attempt to read the files), and presently we never re-upload the same snapshot (except when it fails during backup - but then it's done before the release). In the SQLite case we could mark the released rows in a more explicit fashion if needed. This logic is a bit obscure, but the alternative seems to be "snapshot more often" - which is also a bit weird, since why would we want to waste CPU cycles to compute hashes of files we'd never upload? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think the upload will fail, just skip the missing files https://github.com/Aiven-Open/astacus/blob/master/astacus/node/uploader.py#L41. I like the idea of marking released rows, I'll keep that in mind |
||
self._release_snapshotfile(snapshotfile) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
nodes_all_have_feature
could be a helper.