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

[TECH] Ajout d'un job pour configurer automatiquement l'autoscaler d'applications sur Scalingo (PIX-8638) #298

Merged
merged 3 commits into from
Sep 8, 2023

Conversation

yoandl
Copy link
Contributor

@yoandl yoandl commented Aug 30, 2023

🦄 Problème

L'autoscaler de Scalingo peut mettre du temps à provisionner des containers, un pic de connexion peut donc générer des erreurs.
Cependant, nous connaissons à peu près les horaires des possibles pics de connexion.

🤖 Proposition

Ajouter un cron pour configurer automatiquement l'autoscaler à des heures définies en utilisant un service de lancement de tâches :

  • mise à jour du ScalingoClient en ajoutant la fonction pour configurer l'autoscale pour une app donnée et lui passant des valeurs min et max pour le nombre de containers web à provisionner
  • création d'un planificateur de tâches pouvant lancer une liste de tâches à planifier
  • création d'une tâche pour l'autoscale des containers web
  • création d'une liste de 2 tâches, morningAutoScale et eveningAutoScale
  • chaque peut être paramétrée via des variables d'environnement :
    • FT_AUTOSCALE_WEB
    • SCHEDULE_AUTOSCALE_UP
    • SCHEDULE_AUTOSCALE_DOWN
    • SCHEDULE_AUTOSCALE_APP_NAME
    • SCHEDULE_AUTOSCALE_REGION
    • SCHEDULE_AUTOSCALE_UP_SETTINGS_MIN
    • SCHEDULE_AUTOSCALE_UP_SETTINGS_MAX
    • SCHEDULE_AUTOSCALE_DOWN_SETTINGS_MIN
    • SCHEDULE_AUTOSCALE_DOWN_SETTINGS_MAX

🌈 Remarques

Nous pourrions à terme, rapatrier les tâches de https://github.com/1024pix/scalingo-review-app-manager/blob/master/lib/JobManager.js dans pix-pot, celle-ci etant lancées via le service ecoModeService

💯 Pour tester

🟢
Lancer le server via npm start (l'autoscale n'est pas activé par défaut) et observer l'apparition des logs suivant dans votre terminal :

{"event":"task-scheduler","message":"task morningAutoScale not scheduled","level":"info"}
{"event":"task-scheduler","message":"task eveningAutoScale not scheduled","level":"info"}

@pix-bot-github
Copy link

Une fois l'application déployée, elle sera accessible à cette adresse https://bot-pr298.review.pix.fr
Les variables d'environnement seront accessibles sur scalingo https://dashboard.scalingo.com/apps/osc-fr1/pix-bot-review-pr298/environment

@yoandl yoandl force-pushed the scheduled-scalingo-autoscaler-configurator branch 8 times, most recently from 2a8fef6 to c25d9e3 Compare August 30, 2023 13:46
@yoandl yoandl added team-captains This is your captain speaking 👀 Tech Review Needed labels Aug 30, 2023
@yoandl yoandl self-assigned this Aug 30, 2023
@emeric-martineau emeric-martineau force-pushed the scheduled-scalingo-autoscaler-configurator branch 3 times, most recently from fd298c6 to e8ffb4b Compare September 1, 2023 13:30
@annemarie35 annemarie35 force-pushed the scheduled-scalingo-autoscaler-configurator branch 2 times, most recently from c360352 to 0e83b27 Compare September 1, 2023 13:59
@emeric-martineau emeric-martineau force-pushed the scheduled-scalingo-autoscaler-configurator branch from 280d355 to 68ce51e Compare September 1, 2023 15:02
@annemarie35 annemarie35 force-pushed the scheduled-scalingo-autoscaler-configurator branch from 68ce51e to 44385c5 Compare September 1, 2023 15:27
@mickaelalibert mickaelalibert force-pushed the scheduled-scalingo-autoscaler-configurator branch 3 times, most recently from ef0bd8f to 37502f7 Compare September 4, 2023 09:33
@annemarie35 annemarie35 force-pushed the scheduled-scalingo-autoscaler-configurator branch from 5c996f5 to b1356dd Compare September 4, 2023 12:57
@mickaelalibert mickaelalibert force-pushed the scheduled-scalingo-autoscaler-configurator branch 4 times, most recently from d04cba8 to ddd500f Compare September 4, 2023 15:51
@annemarie35 annemarie35 force-pushed the scheduled-scalingo-autoscaler-configurator branch 9 times, most recently from b31673f to f21f739 Compare September 7, 2023 08:34
Co-authored-by: Mickaël Alibert <mickael.alibert@pix.fr>
Co-authored-by: Emeric Martineau <eric.martineau@pix.fr>
@annemarie35 annemarie35 force-pushed the scheduled-scalingo-autoscaler-configurator branch from f21f739 to d5c2afd Compare September 7, 2023 08:36
Co-authored-by: Anne-Marie Esteves <anne-marie.esteves@pix.fr>
Co-authored-by: Emeric Martineau <eric.martineau@pix.fr>
@annemarie35 annemarie35 force-pushed the scheduled-scalingo-autoscaler-configurator branch 3 times, most recently from 286defb to b65b1f3 Compare September 7, 2023 10:01
@annemarie35 annemarie35 changed the title Ajout d'un job pour configurer automatiquement l'autoscaler d'applications sur Scalingo [TECH] Ajout d'un job pour configurer automatiquement l'autoscaler d'applications sur Scalingo (PIX-8638) Sep 7, 2023
sample.env Outdated
#
# presence: required when autoscaling enabled
# type: number
# default: 2
Copy link
Contributor

Choose a reason for hiding this comment

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

supprimer, doit rester vide pour que scalingo throw une erreur

sample.env Outdated
#
# presence: required when autoscaling enabled
# type: number
# default: 2
Copy link
Contributor

Choose a reason for hiding this comment

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

idem

Co-authored-by: Mickael Alibert <mickael.alibert@pix.fr>
Co-authored-by: Emeric Martineau <eric.martineau@pix.fr>
@annemarie35 annemarie35 force-pushed the scheduled-scalingo-autoscaler-configurator branch from b65b1f3 to 972f884 Compare September 8, 2023 08:26
@github-actions github-actions bot merged commit bf01b91 into main Sep 8, 2023
8 of 9 checks passed
@github-actions github-actions bot deleted the scheduled-scalingo-autoscaler-configurator branch September 8, 2023 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants