Skip to content

fix: cleanup /opt/tipi-setup before reboot after first-boot setup#20

Merged
Mouette03 merged 1 commit into
mainfrom
Fix-rm-tipisetup-opt
Jun 13, 2026
Merged

fix: cleanup /opt/tipi-setup before reboot after first-boot setup#20
Mouette03 merged 1 commit into
mainfrom
Fix-rm-tipisetup-opt

Conversation

@Mouette03

@Mouette03 Mouette03 commented Jun 13, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • Améliorations
    • Le répertoire de configuration initiale est désormais supprimé automatiquement après le redémarrage du système, garantissant un nettoyage approprié suite à l'installation.

@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

L'endpoint /reboot est étendu pour nettoyer le répertoire de configuration /opt/tipi-setup avant le redémarrage système. Le fichier importe shutil pour permettre la suppression récursive du répertoire avec gestion des erreurs.

Changes

Nettoyage du répertoire de configuration lors du redémarrage

Couche / Fichier(s) Résumé
Import et logique de nettoyage du redémarrage
stage-tipi/01-config/files/app/app.py
Ajout de import shutil et modification du handler reboot() pour supprimer récursivement le répertoire /opt/tipi-setup (avec ignorance des erreurs) avant d'exécuter le redémarrage système. Correction mineure du shebang.

Effort estimé de révision du code

🎯 2 (Simple) | ⏱️ ~8 minutes

Poème

🐰 Un redémarrage en ligne,
Qui nettoie le chemin,
/opt/tipi-setup s'efface enfin,
Avant que le système bascule et décline,
Adieu, portail de configuration ! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Le titre décrit précisément le changement principal : suppression du répertoire /opt/tipi-setup avant le redémarrage suite à l'installation initiale.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch Fix-rm-tipisetup-opt

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
stage-tipi/01-config/files/app/app.py (1)

450-451: Encadrer l’auto-suppression de /opt/tipi-setup pendant le redémarrage

  • La route /reboot renvoie immédiatement {"ok": True} puis dans un thread attend time.sleep(2) avant shutil.rmtree("/opt/tipi-setup", ignore_errors=True) et systemctl reboot, donc le risque de couper la réponse HTTP est faible.
  • Durant la fenêtre de 2s, le navigateur peut encore faire des requêtes (ex. polling /progress/log toutes les 1s). Or /progress/log renvoie des données en mémoire (_progress_log, _setup_done) et ne dépend pas de templates/statics, mais des requêtes de ressources statiques possibles pendant la suppression peuvent échouer (404) avant reboot.
  • ignore_errors=True limite les crashs et systemctl reboot arrive juste après; les avertissements statiques sur systemctl reboot sont sans entrée utilisateur.

Suggestions (robustesse, optionnelles) : stopper le polling côté client au moment du clic reboot (arrêter pollTimer) et/ou fermer proprement le serveur avant rmtree (ou augmenter légèrement le délai si nécessaire). [OPTIONAL]

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@stage-tipi/01-config/files/app/app.py` around lines 450 - 451, The /reboot
handler currently returns immediately then in a background thread sleeps 2s and
calls shutil.rmtree("/opt/tipi-setup", ignore_errors=True) followed by systemctl
reboot; to avoid deleting static resources while clients may still poll (e.g.
/progress/log using _progress_log and _setup_done), change the background
sequence so it first cleanly stops the HTTP server (invoke the app shutdown
mechanism such as calling the Werkzeug shutdown function or your service's
graceful stop routine), then perform shutil.rmtree("/opt/tipi-setup",
ignore_errors=True), then call systemctl reboot; keep the short sleep only if
needed to allow the HTTP response to reach clients, but do not delete files
until after shutting down the server to prevent 404s during the polling window.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@stage-tipi/01-config/files/app/app.py`:
- Around line 450-451: The /reboot handler currently returns immediately then in
a background thread sleeps 2s and calls shutil.rmtree("/opt/tipi-setup",
ignore_errors=True) followed by systemctl reboot; to avoid deleting static
resources while clients may still poll (e.g. /progress/log using _progress_log
and _setup_done), change the background sequence so it first cleanly stops the
HTTP server (invoke the app shutdown mechanism such as calling the Werkzeug
shutdown function or your service's graceful stop routine), then perform
shutil.rmtree("/opt/tipi-setup", ignore_errors=True), then call systemctl
reboot; keep the short sleep only if needed to allow the HTTP response to reach
clients, but do not delete files until after shutting down the server to prevent
404s during the polling window.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ed85ea5c-b72b-4342-9f6e-15cdd3a72c71

📥 Commits

Reviewing files that changed from the base of the PR and between c8b2aaa and ceb70bf.

📒 Files selected for processing (1)
  • stage-tipi/01-config/files/app/app.py

@Mouette03 Mouette03 merged commit fd7a966 into main Jun 13, 2026
2 checks passed
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.

1 participant