Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Alert handing changes: #168

Conversation

wagmarcel
Copy link
Member

* Alerts are ignored if the related rule is not active
* Alerts of resetType "Manual" trigger only actions if there is no existing unsuppressed alert with state "New"
* If Alerts are not triggering but valid, they are stored in DB as suppressed events
* GUI is only showing active, i.e. non-suppressed event
* URI parameter "active=true" can be used to get only non-suppressed event. Default behavior is to provide all events.

Signed-off-by: Marcel Wagner wagmarcel@web.de

@wagmarcel
Copy link
Member Author

@oguzcankirmemis I streamlined the createDB script to make it succeding (I need it for the Helm Hook PR in Platformlauncher). But I think there is some rework needed, especially on the testdb usage and creation.

@wagmarcel
Copy link
Member Author

@oguzcankirmemis dont merge it -- I found an issue with it.

@wagmarcel wagmarcel force-pushed the add-manual-alert-type-PR branch from 25a93d4 to f371440 Compare October 27, 2019 20:13
@oguzcankirmemis
Copy link
Member

@wagmarcel there is a small thing I noticed in the createDB script: If I am not mistaken, with superuser account the initial database is created and then the superuser that is already there is created again. Is this intended?

Here is the line where it is happening.

I could also see that the script trying to grant permission to normal user before it is ever created. Normally what should happen is:

  • Superuser connects to postgres
  • Creates the main and the test databases
  • Creates the normal user
  • Grants permissions to user for the created databases

@oguzcankirmemis
Copy link
Member

@wagmarcel Sequelize cannot take model definitions from postgres or migration files and migration files can't take vice versa (here is the issue). The best solution that comes to my mind:

  • Copy the current model definitions as an initial migration file
  • Create the migration file for alerts
  • Update the model definition for alerts
  • Remove createDatabase and initSchema functions entirely, frontend should never attempt to create or update the database itself
  • Rewrite admin/createDB script to use sequelize migratons (and update/remove other admin/*.js scripts if necessary)
  • For future changes, create a new migration file, also update the model to be up to date.

If frontend version is newer or older than migration, then it should fail and crash. So we only have to make sure that each frontend version is consistent in terms of its model definitions and migration files.

@oguzcankirmemis
Copy link
Member

oguzcankirmemis commented Oct 28, 2019

We should actually also remove admin/createDB entirely, and use updateDB for database creation and updates, because it does not make any sense if we have the initial migration file. The resetDB should delete the whole database and use updateDB afterwards to create and bring the database up to date.

@wagmarcel wagmarcel force-pushed the add-manual-alert-type-PR branch from f371440 to 8b467c7 Compare October 28, 2019 16:54
@wagmarcel
Copy link
Member Author

@oguzcankirmemis: not sure about skipping createDB. Then we need to differentiate whether updateDB is creating from scratch or only apply migration scripts. The way it is done in this PR (actually with the related PR in platform-launcher) is that helm install is applying createDB and updateDB and help upgrade is only applying the migration scripts.

@oguzcankirmemis
Copy link
Member

@wagmarcel Seems reasonable, but then createDB still should not depend on models and only apply the initial migration. Otherwise we would have problems.

@wagmarcel wagmarcel force-pushed the add-manual-alert-type-PR branch from 46a1b2f to ea90d5f Compare October 29, 2019 09:36
@wagmarcel
Copy link
Member Author

@oguzcankirmemis: The PR is now ready for review. Besides the Alert changes, the db migrations works now as follows: createDB is using the "base" Alerts model (migrations/models). The updates are in migrations/migrations. With that, the install can be done by using createDB && updateDB. The upgrade can be done by only using updateDB.

    * Alerts are ignored if the related rule is not active
    * Alerts of resetType "Manual" trigger only actions if there is no existing unsuppressed alert with state "New"
    * If Alerts are not triggering but valid, they are stored in DB as suppressed events
    * GUI is only showing active, i.e. non-suppressed event
    * URI parameter "active=true" can be used to get only non-suppressed event. Default behavior is to provide all events.
    * First draft of DB migrations for Alerts:
      - Introduced new DB upgrade logic with sequelize migrations
      - Updated createDB script to terminate correctly
      - Added updateDB script which can be used by Helm to upgrade DB
      - Added revertDB script to revert most recent migration
      - Added revertAllDB script to revert all migrations
      - Now the base model for Alerts is stored in migrations/models to make sure that createDB is using the base model. This allows seamless upgrades with the migrations scripts.

Signed-off-by: Marcel Wagner <wagmarcel@web.de>
@wagmarcel wagmarcel force-pushed the add-manual-alert-type-PR branch from ea90d5f to 2ff3d8f Compare October 29, 2019 14:51
@oguzcankirmemis oguzcankirmemis merged commit a637d09 into Open-IoT-Service-Platform:develop Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants