Closed javierdelapuente closed 4 months ago
Test coverage for fb21dd17a7e2666f0d5d2715e9d005ab63046025
Name Stmts Miss Branch BrPart Cover Missing
-------------------------------------------------------------
src/charm.py 321 27 78 12 90% 186, 194-195, 207, 335->343, 376->381, 393, 575-577, 582-583, 595-597, 602-603, 615-617, 640-642, 684->exit, 694->exit, 724-730, 756->exit, 770-771, 781->exit, 795
src/database.py 30 1 8 1 95% 56
-------------------------------------------------------------
TOTAL 351 28 86 13 91%
Static code analysis report
Run started:2024-04-30 13:45:45.343895
Test results:
No issues identified.
Code scanned:
Total lines of code: 2042
Total lines skipped (#nosec): 3
Total potential issues skipped due to specifically being disabled (e.g., #nosec BXXX): 0
Run metrics:
Total issues (by severity):
Undefined: 0
Low: 0
Medium: 0
High: 0
Total issues (by confidence):
Undefined: 0
Low: 0
Medium: 0
High: 0
Files skipped (0):
Overview
The goal of this PR is to write an integration test that tests the charm upgrade process. There should be no downtime in the upgrade process, so the way of checking it in this test is to make a request every 0.5 seconds to the endpoint
/srv/status
(to the ingress endpoint), in a similar way as how it will work in a real environment.Two issues were found in the test.
Lack of a graceful shutdown. Kubernetes (pebble) sends a SIGTERM signal to Discourse. However,
unicorn
requires SIGQUIT instead for a graceful shutdown (see https://yhbt.net/unicorn/SIGNALS.html). Besides, it looks that having some time before sending the signal could help (see https://medium.com/@acgs771126/ror-unicorn-graceful-shutdown-in-kubernetes-f66d83e1eb48). This is similar to what is suggested in Heroku (see https://blog.heroku.com/unicorn_rails). For that, a patch has been generated that translates SIGTERM to SIGQUIT, and also a delay before sending SIGQUIT to the unicorn master.Workload containers are ready even when there is no discourse running. To improve this situation, the pebble check
discourse-setup-completed
has been moved to the rock, so it always runs. Before that, the check was only added when the discourse service was also added.Rationale
Juju Events Changes
Module Changes
Library Changes
Checklist
src-docs
urgent
,trivial
,complex
)