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

✨ allows frontend to check if a project is inactive #4895

Merged
merged 36 commits into from
Oct 25, 2023

Conversation

GitHK
Copy link
Contributor

@GitHK GitHK commented Oct 20, 2023

What do these changes do?

Background on the feature:

  • when the user is inactive for more than "x minutes" the fronted checks if the project can be close
  • to check it looks if there are still services which are active (they are running code in a jupyter-notebook or running some meshing process)
  • when all services are inactive project can be closed automatically without any risk
  • NOTE if a service does not support the inactivity API like it will be considered inactive

Changes:

  • webserver exposes GET /v0/projects/{project_id}/inactivity which provides information whether the project should be considered inactive or not
  • director-v2 exposes GET /v2/dynamic_services/projects/{project_id}/inactivity to retrieve the project inactivity
  • dynamic-sidecar exposes GET /v1/containers/inactivity which provides information about the service's inactivity
  • ✨ extended callbacks-mapping adding support for the inactivity command which will be called to determine if a service is inactive.
  • jupyter-math now supports this interface Expose service inactivity jupyter-math#24 @mguidon @elisabettai have a look at how to add this
  • ✨ added new frontend setting userInactivityThreshold defaults to 30 minutes

Using it in your service

The service reply should replay with a json object and it will be validated by InactivityResponse.

NOTE versions starting from itisfoundation/ci-service-integration-library:v1.0.3-dev-8 and up support this feature

How to extend the runtime.yml file:

callbacks-mapping:
  ...
  inactivity:
    service: container
    command: "/path/to/your/inactivity/hook"
    timeout: 1

NOTE: timeout has to be comprised between 1 and 5 seconds, validation of the inactivity field will fail otherwise

Related issue/s

How to test

DevOps Checklist

@GitHK GitHK self-assigned this Oct 20, 2023
@GitHK GitHK changed the title 🐛 add is project inactive 🐛 adds endpoint to check if project services are inactive Oct 20, 2023
@GitHK GitHK added a:director-v2 issue related with the director-v2 service a:dynamic-sidecar dynamic-sidecar service a:webserver issue related to the webserver service labels Oct 20, 2023
@GitHK GitHK added this to the Microhistory milestone Oct 20, 2023
@codecov
Copy link

codecov bot commented Oct 20, 2023

Codecov Report

Merging #4895 (f0234fb) into master (1a37096) will increase coverage by 0.5%.
The diff coverage is 93.9%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master   #4895     +/-   ##
========================================
+ Coverage    86.7%   87.2%   +0.5%     
========================================
  Files        1154    1008    -146     
  Lines       48937   45097   -3840     
  Branches     1065     533    -532     
========================================
- Hits        42443   39339   -3104     
+ Misses       6259    5639    -620     
+ Partials      235     119    -116     
Flag Coverage Δ
integrationtests 63.8% <48.4%> (-1.4%) ⬇️
unittests 84.8% <93.9%> (+<0.1%) ⬆️

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

Files Coverage Δ
...library/api_schemas_directorv2/dynamic_services.py 96.6% <100.0%> (+0.2%) ⬆️
..._library/api_schemas_dynamic_sidecar/containers.py 100.0% <100.0%> (ø)
...ls-library/src/models_library/callbacks_mapping.py 100.0% <100.0%> (ø)
...service_director_v2/api/routes/dynamic_services.py 90.5% <100.0%> (+0.8%) ⬆️
...r_v2/modules/dynamic_sidecar/api_client/_public.py 93.2% <100.0%> (+0.1%) ⬆️
...tor_v2/modules/dynamic_sidecar/api_client/_thin.py 100.0% <100.0%> (ø)
.../simcore_service_dynamic_sidecar/api/containers.py 98.0% <100.0%> (+0.4%) ⬆️
...dynamic_sidecar/modules/long_running_tasksutils.py 60.0% <ø> (ø)
...ce_webserver/director_v2/_core_dynamic_services.py 75.5% <100.0%> (+1.8%) ⬆️
...r/src/simcore_service_webserver/director_v2/api.py 100.0% <ø> (ø)
... and 8 more

... and 238 files with indirect coverage changes

@GitHK GitHK changed the title 🐛 adds endpoint to check if project services are inactive 🐛 allows frontend to check if a project is inactive Oct 23, 2023
@GitHK GitHK changed the title 🐛 allows frontend to check if a project is inactive ✨ allows frontend to check if a project is inactive Oct 23, 2023
@GitHK GitHK requested review from ignapas and mguidon October 23, 2023 14:51
Copy link
Member

@sanderegg sanderegg left a comment

Choose a reason for hiding this comment

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

here are some initial comments. there are a few questions. One of them being:

  • you stop the whole project not service by service? why is that?

Copy link
Contributor

@matusdrobuliak66 matusdrobuliak66 left a comment

Choose a reason for hiding this comment

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

I think I got the general concept, but maybe you can explain me a bit more in person.
So the frontend will be polling for this information? Sim4life will also integrate and use this? If any of the services in the project is active nothing will be done? If all the services will be inactive for 30 minutes, we will close the project?

@GitHK
Copy link
Contributor Author

GitHK commented Oct 24, 2023

I think I got the general concept, but maybe you can explain me a bit more in person. So the frontend will be polling for this information? Sim4life will also integrate and use this? If any of the services in the project is active nothing will be done? If all the services will be inactive for 30 minutes, we will close the project?

@matusdrobuliak66 you got it right. I've updated the description of the PR with some background information on how this will be used. Hope it's better now.

Copy link
Member

@pcrespov pcrespov left a comment

Choose a reason for hiding this comment

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

thx. I added some suggestions.

@GitHK GitHK requested a review from sanderegg October 24, 2023 13:09
Copy link
Member

@sanderegg sanderegg 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 the changes!

@codeclimate
Copy link

codeclimate bot commented Oct 25, 2023

Code Climate has analyzed commit f0234fb and detected 0 issues on this pull request.

View more on Code Climate.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.1% 0.1% Duplication

@GitHK GitHK enabled auto-merge (squash) October 25, 2023 06:54
@GitHK GitHK merged commit ef08908 into ITISFoundation:master Oct 25, 2023
53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:director-v2 issue related with the director-v2 service a:dynamic-sidecar dynamic-sidecar service a:webserver issue related to the webserver service
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants