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

Registre arrets: première automatisation #4428

Merged
merged 5 commits into from
Feb 10, 2025
Merged

Conversation

ptitfred
Copy link
Contributor

@ptitfred ptitfred commented Jan 29, 2025

Automatise le registre d'arrêt brut fait dans #4393. Voir l'epic #4354.

  • un module Transport.S3.AggregatesUploader responsable de l'upload sur S3 d'un fichier, l'upload de son sha256 dans un fichier voisin, et la mise à jour d'un fichier "latest" avec cette dernière version. A cette occasion un bucket dédié est alloué : transport-data-gouv-fr-aggregates-{prod|staging|dev|test}.
  • un nouveau job Transport.Jobs.StopsRegistrySnapshot qui chaine l'extraction de registre d'arrêt et l'upload S3. Ce job est quotidien à 4h du matin UTC.

Notes de design

L'uploader Transport.S3.AggregatesUploader est fait pour être réutilisé, notamment par l'extracteur IRVE. Pour l'instant il ne supporte l'upload que d'un fichier, mais on peut le généraliser à une énumération.

L'algorithme de hash est hardcodé à sha256 pour l'instant. On pourrait aisément le rendre configurable et/ou optionnel si nécessaire.

Le job du registre d'arrêt est tellement simple qu'écrire un test pour celui-ci serait à mon avis artificiellement compliqué (nécessiterait notamment de fournir des stubs sur le registre d'arrêt et le helper d'upload). Ca semble assez artificiel.

@ptitfred ptitfred force-pushed the registre-arrets/automation branch 2 times, most recently from 3c37fad to bfffbfc Compare January 29, 2025 11:42
@ptitfred ptitfred marked this pull request as ready for review January 29, 2025 13:44
@ptitfred ptitfred requested a review from a team as a code owner January 29, 2025 13:44
@ptitfred ptitfred force-pushed the registre-arrets/automation branch from bfffbfc to f7d598d Compare January 29, 2025 20:21
- Upload a timestamped file
- Update a stable copy to the latest file
@ptitfred ptitfred force-pushed the registre-arrets/automation branch from f7d598d to b6a2956 Compare January 30, 2025 16:36
@thbar
Copy link
Contributor

thbar commented Feb 3, 2025

Je vais faire un petit test en local pour bien ingérer le fonctionnement, et je reviens reviewer.

@thbar thbar self-requested a review February 3, 2025 14:23
@thbar thbar self-assigned this Feb 3, 2025
Copy link
Contributor

@thbar thbar left a comment

Choose a reason for hiding this comment

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

J'ai pu faire un test en local qui s'est bien passé (avec MinIO) 🎉

⚠️ Si je comprends bien, il faudra créer les buckets sur la recette et la production !

J'ai mis quelques remarques côté code (plutôt des ajustements).

Sur le plus long terme (hors de cette PR) je me suis dit que le code bas niveau pourrait gagner à être rendu plus composable / découplé (ex: une fonction qui fait l'upload, avec une option pour calculer le checksum, appelée une fois par fichier concerné par l'appelant, au lieu d'une fonction qui fixe le scénario "latest + historisé" elle-même), mais c'est secondaire pour le moment et on verra si ça apparaît comme besoin.

@ptitfred
Copy link
Contributor Author

⚠️ Si je comprends bien, il faudra créer les buckets sur la recette et la production !

Pas besoin, chez clever c'est automatique.

@ptitfred
Copy link
Contributor Author

Sur le plus long terme (hors de cette PR) je me suis dit que le code bas niveau pourrait gagner à être rendu plus composable / découplé (ex: une fonction qui fait l'upload, avec une option pour calculer le checksum, appelée une fois par fichier concerné par l'appelant, au lieu d'une fonction qui fixe le scénario "latest + historisé" elle-même), mais c'est secondaire pour le moment et on verra si ça apparaît comme besoin.

Ouais clairement, et d'ailleurs l'avoir fait au même endroit m'a pas aidé à tester le tout. Ca me démange fort de découper.

@ptitfred ptitfred requested a review from thbar February 10, 2025 15:42
@ptitfred
Copy link
Contributor Author

Je bougerai pas le calcul du hash dans cette PR.

@thbar note qu'actuellement ça uploade sur le bucket avec des acl privées. Je n'ai pas creusé cet aspect.

@thbar
Copy link
Contributor

thbar commented Feb 10, 2025

Je bougerai pas le calcul du hash dans cette PR.

Aucun souci, c'était juste une pensée plutôt qu'une attente.

@thbar note qu'actuellement ça uploade sur le bucket avec des acl privées. Je n'ai pas creusé cet aspect.

Alors ça m'arrange, je me posais la question d'avoir des statistiques bien fiables via le proxy, et de comment éviter un téléchargement "par le côté", alors ça me va. Ça amène d'autres points mais on pourra voir plus tard.

Copy link
Contributor

@thbar thbar left a comment

Choose a reason for hiding this comment

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

Top, merci @ptitfred

@thbar
Copy link
Contributor

thbar commented Feb 10, 2025

@ptitfred je te laisse merger à un moment qui te va ?

@ptitfred ptitfred added this pull request to the merge queue Feb 10, 2025
Merged via the queue into master with commit 098a223 Feb 10, 2025
4 checks passed
@ptitfred ptitfred deleted the registre-arrets/automation branch February 10, 2025 17:25
@ptitfred
Copy link
Contributor Author

ptitfred commented Feb 12, 2025

Pas besoin, chez clever c'est automatique.

J'ai menti. Je pensais l'avoir observé en faisant mes tests en local, mais c'est peut-être une conséquence d'avoir testé avec un outil tiers (s3cmd).

Je les ai créés à la main donc (prod, staging, et dev).

@thbar
Copy link
Contributor

thbar commented Feb 12, 2025

Je les ai créés à la main donc (prod, staging, et dev).

Top, merci !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants