@@ -100,23 +100,29 @@ def _logrotate(self) -> logrotate.LogRotate:
100
100
101
101
@property
102
102
@abc .abstractmethod
103
- def _read_write_endpoint (self ) -> str :
103
+ def _read_write_endpoints (self ) -> str :
104
104
"""MySQL Router read-write endpoint"""
105
105
106
106
@property
107
107
@abc .abstractmethod
108
- def _read_only_endpoint (self ) -> str :
108
+ def _read_only_endpoints (self ) -> str :
109
109
"""MySQL Router read-only endpoint"""
110
110
111
111
@property
112
112
@abc .abstractmethod
113
- def _exposed_read_write_endpoint (self ) -> str :
114
- """The exposed read-write endpoint"""
113
+ def _exposed_read_write_endpoints (self ) -> typing .Optional [str ]:
114
+ """The exposed read-write endpoint.
115
+
116
+ Only defined in vm charm.
117
+ """
115
118
116
119
@property
117
120
@abc .abstractmethod
118
- def _exposed_read_only_endpoint (self ) -> str :
119
- """The exposed read-only endpoint"""
121
+ def _exposed_read_only_endpoints (self ) -> typing .Optional [str ]:
122
+ """The exposed read-only endpoint.
123
+
124
+ Only defined in vm charm.
125
+ """
120
126
121
127
@abc .abstractmethod
122
128
def is_externally_accessible (self , * , event ) -> typing .Optional [bool ]:
@@ -125,6 +131,11 @@ def is_externally_accessible(self, *, event) -> typing.Optional[bool]:
125
131
Only defined in vm charm to return True/False. In k8s charm, returns None.
126
132
"""
127
133
134
+ @property
135
+ @abc .abstractmethod
136
+ def _status (self ) -> ops .StatusBase :
137
+ """Status of the charm."""
138
+
128
139
@property
129
140
def _tls_certificate_saved (self ) -> bool :
130
141
"""Whether a TLS certificate is available to use"""
@@ -202,6 +213,8 @@ def _determine_app_status(self, *, event) -> ops.StatusBase:
202
213
# (Relations should not be modified during upgrade.)
203
214
return upgrade_status
204
215
statuses = []
216
+ if self ._status :
217
+ statuses .append (self ._status )
205
218
for endpoint in (self ._database_requires , self ._database_provides ):
206
219
if status := endpoint .get_status (event ):
207
220
statuses .append (status )
@@ -236,8 +249,8 @@ def wait_until_mysql_router_ready(self, *, event) -> None:
236
249
"""
237
250
238
251
@abc .abstractmethod
239
- def _reconcile_node_port (self , * , event ) -> None :
240
- """Reconcile node port .
252
+ def _reconcile_service (self ) -> None :
253
+ """Reconcile service .
241
254
242
255
Only applies to Kubernetes charm
243
256
"""
@@ -249,6 +262,10 @@ def _reconcile_ports(self, *, event) -> None:
249
262
Only applies to Machine charm
250
263
"""
251
264
265
+ @abc .abstractmethod
266
+ def _update_endpoints (self ) -> None :
267
+ """Update the endpoints in the provider relation if necessary."""
268
+
252
269
# =======================
253
270
# Handlers
254
271
# =======================
@@ -332,23 +349,17 @@ def reconcile(self, event=None) -> None: # noqa: C901
332
349
and isinstance (workload_ , workload .AuthenticatedWorkload )
333
350
and workload_ .container_ready
334
351
):
335
- self ._reconcile_node_port ( event = event )
352
+ self ._reconcile_service ( )
336
353
self ._database_provides .reconcile_users (
337
354
event = event ,
338
- router_read_write_endpoint = self ._read_write_endpoint ,
339
- router_read_only_endpoint = self ._read_only_endpoint ,
340
- exposed_read_write_endpoint = self ._exposed_read_write_endpoint ,
341
- exposed_read_only_endpoint = self ._exposed_read_only_endpoint ,
355
+ router_read_write_endpoints = self ._read_write_endpoints ,
356
+ router_read_only_endpoints = self ._read_only_endpoints ,
357
+ exposed_read_write_endpoints = self ._exposed_read_write_endpoints ,
358
+ exposed_read_only_endpoints = self ._exposed_read_only_endpoints ,
342
359
shell = workload_ .shell ,
343
360
)
344
- # _ha_cluster only assigned a value in machine charms
345
- if self ._ha_cluster :
346
- self ._database_provides .update_endpoints (
347
- router_read_write_endpoint = self ._read_write_endpoint ,
348
- router_read_only_endpoint = self ._read_only_endpoint ,
349
- exposed_read_write_endpoint = self ._exposed_read_write_endpoint ,
350
- exposed_read_only_endpoint = self ._exposed_read_only_endpoint ,
351
- )
361
+ self ._update_endpoints ()
362
+
352
363
if workload_ .container_ready :
353
364
workload_ .reconcile (
354
365
event = event ,
0 commit comments