|
6 | 6 | import time |
7 | 7 | import six |
8 | 8 |
|
9 | | -from .dcs import Member |
| 9 | +from .dcs import Member, Cluster |
10 | 10 | from .dcs.kubernetes import catch_kubernetes_errors, Kubernetes |
11 | 11 | from .exceptions import DCSError |
12 | 12 |
|
@@ -59,7 +59,7 @@ def on_shutdown(self, checkpoint_location): |
59 | 59 | class SingleSiteController(AbstractSiteController): |
60 | 60 | """Do nothing controller for single site operation.""" |
61 | 61 | def status(self): |
62 | | - return "Leader" |
| 62 | + return {"status": "Leader", "active": False} |
63 | 63 |
|
64 | 64 | class MultisiteController(Thread, AbstractSiteController): |
65 | 65 | is_active = True |
@@ -117,7 +117,12 @@ def __init__(self, config, on_change=None): |
117 | 117 | self._dcs_error = None |
118 | 118 |
|
119 | 119 | def status(self): |
120 | | - return "Leader" if self._has_leader else "Standby" |
| 120 | + return { |
| 121 | + "status": "Leader" if self._has_leader or self._standby_config is None else "Standby", |
| 122 | + "active": True, |
| 123 | + "name": self.name, |
| 124 | + "standby_config": self.get_active_standby_config(), |
| 125 | + } |
121 | 126 |
|
122 | 127 | def get_active_standby_config(self): |
123 | 128 | return self._standby_config |
@@ -317,7 +322,7 @@ def _update_history(self, cluster): |
317 | 322 | else: |
318 | 323 | self.dcs.set_history_value(json.dumps([{'last_leader': self.name, 'switches': 0}])) |
319 | 324 |
|
320 | | - def _check_for_failover(self, cluster): |
| 325 | + def _check_for_failover(self, cluster: Cluster): |
321 | 326 | if cluster.failover and cluster.failover.target_site: |
322 | 327 | if cluster.failover.target_site == self.name: |
323 | 328 | logger.info("Cleaning up failover key targeting us") |
|
0 commit comments