Skip to content

✨ allowing to log back into a study when the tab was closed #2383

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

Conversation

sanderegg
Copy link
Member

@sanderegg sanderegg commented Jun 14, 2021

What do these changes do?

The backend maintain a Redis-based registry where all user-allocated resources are kept (for now only socket IDs and project IDs).
These resources are linked to the user so-called "client session id" which is given by the frontend as the Broswer Tab ID when the websocket connection is created (Socket ID).

FRom the backend side it is not possible to distinguish between a network disconnection and a tab-closed. Therefore we do use a TTL (time-to-live) field in the Redis registry of 900 seconds. During that time, the same browser tab would be able to re-open the same study in case that it reconnects.

In the case of a closed tab, re-opening a new tab creates a new Tab ID. Therefore the backend treats that as "the user opened another tab and is trying to open a study that is already opened in another tab". Therefore it appears locked, and the user must wait 15 minutes until it gets closed, and after that the user may open it again.

Changes

  • Listing the projects now will check if the user project is already opened by that very same user. If yes, it will check if a socket ID exists. If yes, then the behavior will remain the same. If not, then the project will not be defined as Locked and the user can re-open it.
  • If the project is just in the process of closing (e.g. dynamic services are saving their state and closing). then it should not be allowed to re-enter the project until the process is completed.
  • if a user is exporting a project, that project is locked until the export process is completed
  • if a user is duplicating a project, that project is locked until the cloning is completed
  • notification to any user that shares that project are in. @odeimaiz will probably vastlymprove the frontend part.

Bonus:

  • make show_endpoints shows the endpoint to some of the services on demand
  • codecov badge updated
  • improve some test reliability by insuring redis database is properly cleaned
  • importer now has a first draft of a migration system setup (see models.py)

Related issue/s

fixes #431
fixes #1952

How to test

Checklist

@sanderegg sanderegg added this to the Chinchilla milestone Jun 14, 2021
@sanderegg sanderegg self-assigned this Jun 14, 2021
@sanderegg sanderegg added the a:webserver issue related to the webserver service label Jun 14, 2021
@codecov
Copy link

codecov bot commented Jun 14, 2021

Codecov Report

Merging #2383 (260612c) into master (b452c71) will increase coverage by 0.0%.
The diff coverage is 87.6%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #2383    +/-   ##
=======================================
  Coverage    74.7%   74.7%            
=======================================
  Files         516     517     +1     
  Lines       20038   20161   +123     
  Branches     1972    2000    +28     
=======================================
+ Hits        14984   15079    +95     
- Misses       4530    4547    +17     
- Partials      524     535    +11     
Flag Coverage Δ
integrationtests 67.2% <56.7%> (-0.1%) ⬇️
unittests 68.2% <77.5%> (-0.1%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...imcore_service_webserver/exporter/export_import.py 95.2% <ø> (ø)
.../server/src/simcore_service_webserver/users_api.py 89.8% <0.0%> (-4.2%) ⬇️
...re_service_webserver/exporter/formatters/models.py 90.5% <72.7%> (-3.2%) ⬇️
...imcore_service_webserver/resource_manager/redis.py 81.8% <80.0%> (-0.5%) ⬇️
...simcore_service_webserver/projects/projects_api.py 86.3% <82.9%> (-2.7%) ⬇️
...ore_service_webserver/exporter/request_handlers.py 86.9% <91.3%> (+2.4%) ⬆️
...simcore_service_webserver/projects/project_lock.py 94.4% <94.4%> (ø)
...odels-library/src/models_library/projects_state.py 100.0% <100.0%> (ø)
...vice_webserver/exporter/formatters/formatter_v1.py 77.9% <100.0%> (ø)
...re_service_webserver/projects/projects_handlers.py 89.3% <100.0%> (-1.0%) ⬇️
... and 10 more

@sanderegg sanderegg force-pushed the enhancement/allow_relogin_in_same_account branch 2 times, most recently from 0c695eb to 915f753 Compare June 16, 2021 06:18
@odeimaiz odeimaiz modified the milestones: Chinchilla, Marmoset Jun 16, 2021
@sanderegg sanderegg changed the title WIP: ✨ allowing to log back into a study when the tab was closed ✨ allowing to log back into a study when the tab was closed Jun 16, 2021
@sanderegg sanderegg marked this pull request as ready for review June 16, 2021 21:27
@sanderegg sanderegg force-pushed the enhancement/allow_relogin_in_same_account branch from c65e149 to e5a987d Compare June 16, 2021 21:28
Copy link
Contributor

@GitHK GitHK left a comment

Choose a reason for hiding this comment

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

Nice addition! A few comments and questions below.

Copy link
Member

@odeimaiz odeimaiz left a comment

Choose a reason for hiding this comment

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

💪 Thanks for bringing the Study statuses!

@sanderegg sanderegg force-pushed the enhancement/allow_relogin_in_same_account branch from e5a987d to dbfc512 Compare June 18, 2021 08:47
@sanderegg sanderegg requested a review from pcrespov June 18, 2021 09:54
Copy link
Contributor

@GitHK GitHK left a comment

Choose a reason for hiding this comment

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

look OK, please check below suggestion before merging

(SERVICE_KEY_RE, "node-meta-v0.0.1.json", ["key"]),
],
)
def test_regex_pattern_same_in_jsonschema_and_python(
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

await notify_project_state_update(app, project)


# TODO: Once python 3.8 is in use this
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# TODO: Once python 3.8 is in use this
import sys
if sys.version_info >= (3, 8):
raise Exception("use below implementation in py3.8+")

this way you won't miss it

Copy link
Member

Choose a reason for hiding this comment

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

that is a good point ...
I enabled it in py3.8 branch

@sanderegg sanderegg merged commit e19f6c1 into ITISFoundation:master Jun 18, 2021
@sanderegg sanderegg deleted the enhancement/allow_relogin_in_same_account branch June 18, 2021 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:webserver issue related to the webserver service
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A user cannot re-open his/her study when he/she closes a tab inadvertently Give feedback on the status of a study (open, opening, closing, closed)
4 participants