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

dvc: use protected mode by default #3472

Merged
merged 2 commits into from
Mar 17, 2020
Merged

dvc: use protected mode by default #3472

merged 2 commits into from
Mar 17, 2020

Conversation

efiop
Copy link
Contributor

@efiop efiop commented Mar 11, 2020

Fixes #3261
Fixes #2041

  • ❗ Have you followed the guidelines in the Contributing to DVC list?

  • πŸ“– Check this box if this PR does not require documentation updates, or if it does and you have created a separate PR in dvc.org with such updates (or at least opened an issue about it in that repo). Please link below to your PR (or issue) in the dvc.org repo.

iterative/dvc.org#1058

  • ❌ Have you checked DeepSource, CodeClimate, and other sanity checks below? We consider their findings recommendatory and don't expect everything to be addressed. Please review them carefully and fix those that actually improve code or fix bugs.

Thank you for the contribution - we'll try to review it as soon as possible. πŸ™

@efiop efiop force-pushed the 3261 branch 3 times, most recently from c5aa073 to b1e523c Compare March 11, 2020 20:59
@@ -82,19 +82,24 @@ class RemoteBASE(object):
DEFAULT_NO_TRAVERSE = True
DEFAULT_VERIFY = False

CACHE_MODE = None
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Generalising it because SSH could use the same optimization a bit later.

shared = config.get("shared")
self._file_mode, self._dir_mode = self.SHARED_MODE_MAP[shared]

if self.protected:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously we kinda mixed up cache and link protection, the new patch puts the emphasis on cache protection, which is what we really want and should be much less confusing.

System.reflink(from_info, to_info)
def reflink(self, from_info, to_info):
tmp_info = to_info.parent / tmp_fname(to_info.name)
System.reflink(from_info, tmp_info)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you can change mode on reflink without affecting the source. This is because reflinks have their own inodes, so from fs perspective they are separate files that have their own perms.

Copy link
Member

Choose a reason for hiding this comment

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

@efiop, Can you mention this on a code itself as a comment?

Copy link
Member

@skshetry skshetry Mar 16, 2020

Choose a reason for hiding this comment

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

Also, can this not be done without link to temp?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@efiop, Can you mention this on a code itself as a comment?

Sure! Done.

Also, can this not be done without link to temp?

Temp file is needed to make it atomic, so the target file appears already with correct permissions, so there is no chance of something trying to use it while it is in read-only mode.

Copy link
Member

Choose a reason for hiding this comment

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

Got it, thanks.

@@ -97,7 +97,7 @@ class RelPath(str):
}
LOCAL_COMMON = {
"type": supported_cache_type,
Optional("protected", default=False): Bool,
Optional("protected", default=False): Bool, # obsoleted
Copy link
Contributor Author

Choose a reason for hiding this comment

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

So this one is effectively defunct from now on. Just keeping it in the SCHEMA to not break on older configs.

Copy link
Member

Choose a reason for hiding this comment

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

This does not respect explicit protected = False, does it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@skshetry It doesn't, as there is no clear use case for it.

@efiop
Copy link
Contributor Author

efiop commented Mar 11, 2020

Windows is failing, will check it out tomorrow.

EDIT: fixed.

@efiop efiop force-pushed the 3261 branch 12 times, most recently from 00ade4a to d40744e Compare March 13, 2020 11:34
@efiop efiop changed the title [WIP] dvc: use protected mode by default dvc: use protected mode by default Mar 13, 2020
@efiop efiop changed the title dvc: use protected mode by default [WIP] dvc: use protected mode by default Mar 13, 2020
@efiop efiop changed the title [WIP] dvc: use protected mode by default dvc: use protected mode by default Mar 16, 2020
@efiop efiop requested review from skshetry, Suor and pared March 16, 2020 09:40
@efiop efiop requested a review from gurobokum March 16, 2020 09:41
@shcheklein
Copy link
Member

Please, update docs if needed after this change.

efiop added a commit to iterative/dvc.org that referenced this pull request Mar 16, 2020
@efiop efiop force-pushed the 3261 branch 2 times, most recently from d287df6 to a1a497d Compare March 17, 2020 12:42
@efiop efiop force-pushed the 3261 branch 2 times, most recently from 517a690 to fd9b9a0 Compare March 17, 2020 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants