canonical / discourse-k8s-operator

discourse-k8s-operator - charm repository.
Apache License 2.0
7 stars 5 forks source link

ISD-1516 Remove is_leader check when running db migration #189

Closed Thanhphan1147 closed 7 months ago

Thanhphan1147 commented 7 months ago

We can take advantage of the idem-potency of the db:migrate task to remove a check and run that task on all units.

Local tests shows a time loss of around 3s per unit for each skipped checks (note that unit-discourse-k8s-1 is doing the actual migration and the other calling the task and skipping it):

unit-discourse-k8s-1: 00:34:47 INFO unit.discourse-k8s/1.juju-log Discourse setup: about to execute migrations
unit-discourse-k8s-1: 00:34:51 INFO unit.discourse-k8s/1.juju-log unit: <ops.model.Unit discourse-k8s/1> DB migration done in 4.5590386390686035 seconds
...
unit-discourse-k8s-0: 00:37:36 INFO unit.discourse-k8s/0.juju-log unit: <ops.model.Unit discourse-k8s/0> DB migration done in 3.47281813621521 seconds
unit-discourse-k8s-0: 00:37:36 INFO unit.discourse-k8s/0.juju-log Discourse setup: about to compile assets

Checklist

github-actions[bot] commented 7 months ago

Test coverage for cf63c2625a65ec081ac059b2d3613800d0ae24aa

Name              Stmts   Miss Branch BrPart  Cover   Missing
-------------------------------------------------------------
src/charm.py        329     30     80     11    90%   177, 185-186, 350->355, 552-554, 559-560, 571-573, 578-579, 591-593, 598-599, 611-613, 638-640, 682->exit, 692->exit, 722-728, 754->exit, 768-769, 779->exit, 793
src/database.py      30      1      8      1    95%   56
-------------------------------------------------------------
TOTAL               359     31     88     12    90%

Static code analysis report

Run started:2024-02-19 17:59:37.454459

Test results:
    No issues identified.

Code scanned:
    Total lines of code: 1985
    Total lines skipped (#nosec): 1
    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):