Both of the above tests fail on retrieving a cluster primary when the old primary is stopped or cut from the network. The reason for this, I believe, is the usage of == to compare units. Despite the unit and unit_excluded is the same, the unit is not excluded (the condition does not hold true). This is why the tests above fail to get primary from the "old primary unit" which does not have a running mysqld.
Issue
Network cut test: https://github.com/canonical/mysql-operator/actions/runs/10397182320/job/28792633963 Replicate data on restart test: https://github.com/canonical/mysql-operator/actions/runs/10397182320/job/28792634154#step:28:425
Both of the above tests fail on retrieving a cluster primary when the old primary is stopped or cut from the network. The reason for this, I believe, is the usage of
==
to compare units. Despite theunit
andunit_excluded
is the same, the unit is not excluded (the condition does not hold true). This is why the tests above fail to get primary from the "old primary unit" which does not have a running mysqld.Solution
Compare unit names instead