fix: cleanup /opt/tipi-setup before reboot after first-boot setup#20
Conversation
📝 WalkthroughWalkthroughL'endpoint ChangesNettoyage du répertoire de configuration lors du redémarrage
Effort estimé de révision du code🎯 2 (Simple) | ⏱️ ~8 minutes Poème
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
stage-tipi/01-config/files/app/app.py (1)
450-451: Encadrer l’auto-suppression de/opt/tipi-setuppendant le redémarrage
- La route
/rebootrenvoie immédiatement{"ok": True}puis dans un thread attendtime.sleep(2)avantshutil.rmtree("/opt/tipi-setup", ignore_errors=True)etsystemctl 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/logtoutes les 1s). Or/progress/logrenvoie 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=Truelimite les crashs etsystemctl rebootarrive juste après; les avertissements statiques sursystemctl rebootsont 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 avantrmtree(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
📒 Files selected for processing (1)
stage-tipi/01-config/files/app/app.py
Summary by CodeRabbit