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

T258401: Stop deleting important objects found in commits #128

Merged
merged 7 commits into from
Jun 7, 2024

Conversation

gandie
Copy link
Member

@gandie gandie commented Jun 3, 2024

No description provided.

Copy link
Collaborator

@viktordick viktordick left a comment

Choose a reason for hiding this comment

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

We should restrict the detection to the top-level acl_users. I think it should still be possible to remove any acl_users that resides somewhere else (I might be convinced otherwise).

@jan-jockusch
Copy link
Member

We should restrict the detection to the top-level acl_users. I think it should still be possible to remove any acl_users that resides somewhere else (I might be convinced otherwise).

I thought exactly the same thing when reading the PR. The top-level acl_users is the one we need to protect.

Copy link
Member

@jan-jockusch jan-jockusch left a comment

Choose a reason for hiding this comment

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

One typo and one question, which the tests answers in the positive… I'm just having difficulty understanding the deletion process fully.

perfact/zodbsync/tests/test_sync.py Outdated Show resolved Hide resolved
perfact/zodbsync/zodbsync.py Outdated Show resolved Hide resolved
jan-jockusch
jan-jockusch previously approved these changes Jun 4, 2024
Copy link
Member

@jan-jockusch jan-jockusch left a comment

Choose a reason for hiding this comment

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

LGTM

perfact/zodbsync/zodbsync.py Outdated Show resolved Hide resolved
jan-jockusch
jan-jockusch previously approved these changes Jun 6, 2024
Copy link
Member

@jan-jockusch jan-jockusch left a comment

Choose a reason for hiding this comment

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

LGTM

@gandie gandie requested a review from viktordick June 7, 2024 10:02
self.run('playback', '/')
assert 'acl_users' not in self.app.some_module.objectIds()

def test_keep_acl_norecurse(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Tipp: If you have two very similar tests that only differ in a few lines, you can write one test with two variants using pytest.parametrize.

del_ids = [
a for a in srv_contents
if a not in contents and
(path != '/acl_users' and a != 'acl_users')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why doesn't this prevent the deletion of /some_module/acl_users in recursive mode? I'm a bit confused...

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it does prevent it, but the test does not notice because of some transaction shenanigans. I stepped with the debugger into the playback and noticed that both fs_contents and srv_contents were empty, so nothing was deleted. Not sure why the first check for the presence of acl_users in the tests does not fail though...

Copy link
Collaborator

Choose a reason for hiding this comment

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

To explain: If we simply manipulate something with directly accessing self.app, this automatically opens a transaction. When the next self.run(...) is executed, this usually also starts a transaction, aborting the already open transaction. Therefore the creation of /some_module and /some_module/acl_users was never commited, but visible in the first check (since it was still the same transaction), but no longer visible once the playback started.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess playback explicitly starts a new transaction (to be able to roll it back later) while record does not (because it does not expect to change anything inside the Data.FS).

Copy link
Collaborator

@viktordick viktordick left a comment

Choose a reason for hiding this comment

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

LGTM now, fixed the remaining problem.

@gandie gandie merged commit 6e17f77 into master Jun 7, 2024
3 checks passed
@viktordick viktordick deleted the T258401-keep-acl branch June 7, 2024 12:42
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.

None yet

3 participants