@@ -41,15 +41,30 @@ def is_compatible(
41
41
old_workload_version : str ,
42
42
new_workload_version : str ,
43
43
) -> bool :
44
+ # Check charm version compatibility
44
45
if not super ().is_compatible (
45
46
old_charm_version = old_charm_version ,
46
47
new_charm_version = new_charm_version ,
47
48
old_workload_version = old_workload_version ,
48
49
new_workload_version = new_workload_version ,
49
50
):
50
51
return False
51
- # TODO: check workload version—prevent downgrade?
52
- return True
52
+
53
+ # Check workload version compatibility
54
+ old_major , old_minor , old_patch = (
55
+ int (component ) for component in old_workload_version .split ("." )
56
+ )
57
+ new_major , new_minor , new_patch = (
58
+ int (component ) for component in new_workload_version .split ("." )
59
+ )
60
+ if old_major != new_major :
61
+ return False
62
+ if new_minor > old_minor :
63
+ return True
64
+ elif new_minor == old_minor :
65
+ return new_patch >= old_patch
66
+ else :
67
+ return False
53
68
54
69
55
70
class MySQLRouterCharm (ops .CharmBase , abc .ABC ):
@@ -323,7 +338,7 @@ def reconcile(self, event=None) -> None: # noqa: C901
323
338
if self ._database_requires .is_relation_breaking (event ):
324
339
if self .refresh .in_progress :
325
340
logger .warning (
326
- "Modifying relations during an upgrade is not supported. The charm may be in a broken, unrecoverable state. Re-deploy the charm"
341
+ "Modifying relations during a refresh is not supported. The charm may be in a broken, unrecoverable state. Re-deploy the charm"
327
342
)
328
343
self ._database_provides .delete_all_databags ()
329
344
elif (
0 commit comments