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

Fix federated group shares when no longer found in remote server #44587

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

danxuliu
Copy link
Member

When a federated group share with another server is deleted a notification is sent to the remote server to delete the share. If that notification is not received then when the remote server tries to access the share again it will not be found in the sharer server, so it will be locally unshared in the remote server.

This works fine for user shares, as in that case the share is deleted in the remote server, but locally unsharing a received federated group share only marks it as pending again for the user that tried to access it. Due to that the received federated group share is left dangling in the remote server, and it is kept forever in the list of pending shares for the users in the group.

To solve that now the received federated group share is fully removed instead of simply unshared when no longer available in the sharer server; if the share was a user share it will be locally unshared like before, but if it is a group share it will be fully deleted.

Note that all of the above applies only when the sharer server is still available and it returns a "not found" error when the remote server tries to access the share. If the sharer server is not available accessing the received share just fails, as in that case it is not possible to know if the sharer server is temporarily unavailable or gone forever.

Besides the fix this pull request also adds an integration test to verify the behaviour (Delete federated group share with another server when temporary unreachable) as well as several other integration tests for deletion scenarios. Unit tests were also added for removeShare with group shares.

TODO / Open questions:

  • Besides when no longer found in the sharer server the received group share is also removed if a ForbiddenException is received. I did that for consistency with the behaviour of user shares, but is that right or should the removal be limited to NotFoundException?
  • Right now for simplicity removeShare was reused by adding a boolean $force parameter (which I am not a fan of). Should a different, explicit method be introduced instead?
  • In the integration tests, although groups are removed after each scenario it seems that their remote group shares are not, which causes weird issues in (some) following tests due to the existing remote group shares in the database. To address that the share_external table is explicitly cleared before running a scenario. But... could that be a bug in itself? Should the remote group shares be automatically removed if the group they belong to is removed?
  • Should there be (or does it exist but I am not aware of it) an OCC command or something similar to clear remote shares from a specific server to remove them if the remote server is gone forever?
  • Reshares do not seem to be properly removed when a federated share is removed, even if both instances are up (it happens also with user shares, it is unrelated to the changes in this pull request)

This will be needed to add tests with unavailable servers, as the local
server is started by the script that runs the tests rather than from the
test features themselves, so only the remote server can be stopped and
started again.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
…server

Once the receiver server is up again trying to access the federated
share should cause it to be removed in the receiver server as well, as
it will be no longer found in the sharer server.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
…server

Once the sharer server is up again the federated share will be still
there, as the sharer server missed the notification from the receiver
server about deleting the share.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Although groups are removed after each scenario it seems that their
remote group shares are not, so there might be dangling remote group
shares that could interfere with the following scenarios. To solve that
a new endpoint is added to the "testing" app to explicitly clear the
remote shares.

Note that any dangling remote storage was already removed with the OCC
command, so only the "share_external" table is cleared.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
…remote

When a member of the group that received a federated group share removes
it the share is just removed for that specific user, but it does not
affect other users in the group. Due to that the share is simply marked
again as pending for that user.

This even applies when the remote server is no longer reachable, as it
is not possible to know if the server is just temporarily down or gone
forever.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
…remote

When the sharer removes a federated group share it is removed for all
the members of the group that received it. Due to that, if the remote
server was temporary down when the share was removed but once it is
running again a user tries to access the share should be removed for all
of them, rather than being marked as pending for that user (which is not
the current behaviour and will need to be fixed in a follow up commit).

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
When a federated group share with another server is deleted a
notification is sent to the remote server to delete the share. If that
notification is not received then when the remote server tries to access
the share again it will not be found in the sharer server, so it will be
locally unshared in the remote server.

This works fine for user shares, as in that case the share is deleted in
the remote server, but locally unsharing a received federated group
share only marks it as pending again for the user that tried to access
it. Due to that the received federated group share is left dangling in
the remote server, and it is kept forever in the list of pending shares
for the users in the group.

To solve that now the received federated group share is fully removed
instead of simply unshared when no longer available in the sharer server.

Note that all of the above applies only when the sharer server is still
available and it returns a "not found" (or "forbidden") error when the
remote server tries to access the share. If the sharer server is not
available accessing the received share does not fully remove the group
share, as in that case it is not possible to know if the sharer server
is temporarily unavailable or gone forever.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This will be needed to test group shares with several users, as the
external share managers returned by "createManagerForUser" use the group
manager stored in the test case attribute.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant