File tree Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -107,7 +107,7 @@ def __init__(self, *args):
107
107
108
108
# Increment this PATCH version before using `charmcraft publish-lib` or reset
109
109
# to 0 if you are raising the major API version
110
- LIBPATCH = 9
110
+ LIBPATCH = 10
111
111
112
112
PYDEPS = ["pydantic" ]
113
113
@@ -902,7 +902,16 @@ def _get_endpoint(
902
902
def get_endpoint (
903
903
self , protocol : ReceiverProtocol , relation : Optional [Relation ] = None
904
904
) -> Optional [str ]:
905
- """Receiver endpoint for the given protocol."""
905
+ """Receiver endpoint for the given protocol.
906
+
907
+ It could happen that this function gets called before the provider publishes the endpoints.
908
+ In such a scenario, if a non-leader unit calls this function, a permission denied exception will be raised due to
909
+ restricted access. To prevent this, this function needs to be guarded by the `is_ready` check.
910
+
911
+ Raises:
912
+ ProtocolNotRequestedError:
913
+ If the charm unit is the leader unit and attempts to obtain an endpoint for a protocol it did not request.
914
+ """
906
915
endpoint = self ._get_endpoint (relation or self ._relation , protocol = protocol )
907
916
if not endpoint :
908
917
requested_protocols = set ()
Original file line number Diff line number Diff line change @@ -815,20 +815,19 @@ def _is_cluster_blocked(self) -> bool:
815
815
# We need to query member state from the server since member state would
816
816
# be 'offline' if pod rescheduled during cluster creation, however
817
817
# member-state in the unit peer databag will be 'waiting'
818
- member_state_exists = True
819
818
try :
820
819
member_state , _ = self ._mysql .get_member_state ()
821
820
except MySQLUnableToGetMemberStateError :
822
821
logger .error ("Error getting member state while checking if cluster is blocked" )
823
822
self .unit .status = MaintenanceStatus ("Unable to get member state" )
824
823
return True
825
824
except MySQLNoMemberStateError :
826
- member_state_exists = False
825
+ member_state = None
827
826
828
- if not member_state_exists or member_state == "restarting" :
827
+ if not member_state or member_state == "restarting" :
829
828
# avoid changing status while tls is being set up or charm is being initialized
830
829
logger .info ("Unit is waiting or restarting" )
831
- logger .debug (f"{ member_state_exists = } , { member_state = } " )
830
+ logger .debug (f"{ member_state = } " )
832
831
return True
833
832
834
833
# avoid changing status while async replication is setting up
You can’t perform that action at this time.
0 commit comments