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

Delete public links on GET #1364

Merged
merged 7 commits into from
Dec 14, 2020
Merged

Delete public links on GET #1364

merged 7 commits into from
Dec 14, 2020

Conversation

refs
Copy link
Member

@refs refs commented Dec 9, 2020

Following up on #1361

Due to tunnel vision and solving one single problem, public links get deleted now on ListPublicLinks operations, but as long as we don't have background jobs they MUST also be deleted on GetPublicLink operations.

There is the scenario that a public link is expired but ListPublicLink has not run, accessing a technically expired public link is still possible.

A proposed solution is deleting the link on access.

@refs refs requested a review from labkode as a code owner December 9, 2020 11:16
@update-docs
Copy link

update-docs bot commented Dec 9, 2020

Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes.

@refs refs changed the title publicshareManagerJson: delete public links on GET Delete public links on GET Dec 9, 2020
@labkode
Copy link
Member

labkode commented Dec 9, 2020

@refs we can easily add a goroutine to the json manager to clean the links without having to do it on these ops?

@refs
Copy link
Member Author

refs commented Dec 9, 2020

@refs we can easily add a goroutine to the json manager to clean the links without having to do it on these ops?

and run launch it on every operation?

@labkode
Copy link
Member

labkode commented Dec 9, 2020

@refs when the driver is started as part of the init process for example.

@refs
Copy link
Member Author

refs commented Dec 9, 2020

@refs when the driver is started as part of the init process for example.

The only drawback I see with it is the number of unnecessary cycles that routine would do just checking whether a share is expired or not, then since we're polling the db, that also needs to work with the locks, I see that even using RWMutex won't help much since we'd need to take a write lock on the mutex.

Now even if we got the goroutine blocked polling the json "db" for expired shares there could still be the case that a share is expired the moment it's accessed or listed, this is the argument that drove me to go with this "delete on-demand" approach.

Let me spend some time using time.AfterFunc and see how far I get

@refs
Copy link
Member Author

refs commented Dec 9, 2020

@labkode have a look at 5c3c7be (#1364) if you can and share your thoughts.

The abstraction was done due to the init() being called multiple times it is impossible to synchronize every call without introducing yet more global state. Instead of adding that logic in the init() method I'd rather do it in the constructor because it's called only once.

There is no way to provide a logger since the manager has no awareness of service configuration, so at the moment the janitor is silent and runs by default every 10 seconds (this needs to be configurable).

I have not measured the performance impact of this nor with a small sample db or a large one, so the costs of locking, serializing, iterating and removing are not being accounted for, only functionality.

@refs
Copy link
Member Author

refs commented Dec 9, 2020

A small remark to add is that even with this janitor logic I'd still like to leave the on-demand checks on each method to avoid stale data.

@refs refs changed the base branch from master to unsafe December 14, 2020 08:47
@refs
Copy link
Member Author

refs commented Dec 14, 2020

ping @labkode

@labkode labkode merged commit 063b3db into cs3org:unsafe Dec 14, 2020
labkode added a commit that referenced this pull request Dec 16, 2020
Co-authored-by: Alex Unger <6905948+refs@users.noreply.github.com>
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.

2 participants