Mentions légales du service

Skip to content

Resolve "Add support for periodic jobs"

RAVERDY Pierre-Guillaume requested to merge 15-periodic_jobs into dev
name: Feature
about: New features or wider changes

Closes #15

Description

This MR adds a daemon thread for background tasks such as terminating servers after their use, removing bogus servers in scaleway, sending reminder emails, ...

A Task model is added that records the tasks and their due date (persisted in the SQLAlchemy). Tasks can be PENDING, PROCESSING, COMPLETED, or FAILED. The daemon thread is activated every X seconds (30 currently) and performs several generic operations (tasks that do not need to be in the DB), as well as all the relevant pending taks recorded in the DB.

Additionnally, the UI has been updated to add date/time components for visio reservation, as well as the necessary backend code. When requesting a new visio, the user can either ask for "now" or specify a date and time. By default, the BBB server is started 13 minutes in advance (3 minutes for the preparation, 10 minutes in advance so that the link can be shared with others).

Changelog

  • Add periodic tasks processing
  • Add reservation for visio (UI and backed)
  • Add periodic tasks for cloud cleanup

How to test

  • Create a new visio for 15 minutes ("now")

  • Wait 5 minutes and create another ("now") visio

  • Wait 5 minutes, an email should arrive that notifies the first visio server is going to be terminated in 5 minutes.

  • Wait 5 minutres, the first server should be stopped and terminated, and an email received, and another reminder email should arrive for the second server

  • After another 5 minutes, the second server should also be stopped and another email received.

  • Create a visio for a due time of (now + 20 minutes), duration of 15 minutes.

  • A first email is received with the summary of the request

  • After about 17 minutes, a second email should be received (server preparation)

  • After another 3 minutes, a third email is received (server ready)

  • After 10 minutes, a fourth email is received (server about to end)

  • After 5 minutes, a fifth email is received (server terminated)

Misc

  • removed alpine flag for docker image as bash is not available on it (required for executing scripts)
  • when creating the app (create_app()), it directly set the configuration so that the scheduler is not started when in TESTING mode (otherwise, the scheduler kicks in when inserting tasks which creates issue as then cannot be executed)
  • moved to enums in Task class and added some helper methods, should be considered for the other models
  • created a RequestParameters class used in InstanceManager to hold and check the incoming request parameters (thus easier to do testing).
  • added several utility functions in the DataManager to find specific tasks (pending, ...)
  • extra scripts have been added to delete the default "superdsi" account on the running visio (to avoid global access). Since no rake task was available (like for creating an account), some ruby commands directly delete the first account (sent thru pipe to the docker/greenlight).
  • more utils functions have been added to manage date/time in utc or local timezone.
Edited by RAVERDY Pierre-Guillaume

Merge request reports