@@ -84,7 +84,7 @@ def _on_ingress_revoked(self, event: IngressPerAppRevokedEvent):
8484
8585# Increment this PATCH version before using `charmcraft publish-lib` or reset
8686# to 0 if you are raising the major API version
87- LIBPATCH = 16
87+ LIBPATCH = 17
8888
8989PYDEPS = ["pydantic" ]
9090
@@ -456,11 +456,16 @@ class IngressPerAppDataRemovedEvent(RelationEvent):
456456 """Event representing that ingress data has been removed for an app."""
457457
458458
459+ class IngressPerAppEndpointsUpdatedEvent (RelationEvent ):
460+ """Event representing that the proxied endpoints have been updated."""
461+
462+
459463class IngressPerAppProviderEvents (ObjectEvents ):
460464 """Container for IPA Provider events."""
461465
462466 data_provided = EventSource (IngressPerAppDataProvidedEvent )
463467 data_removed = EventSource (IngressPerAppDataRemovedEvent )
468+ endpoints_updated = EventSource (IngressPerAppEndpointsUpdatedEvent )
464469
465470
466471@dataclass
@@ -508,7 +513,7 @@ def _handle_relation(self, event):
508513 )
509514
510515 def _handle_relation_broken (self , event ):
511- self .on .data_removed .emit (event .relation ) # type: ignore
516+ self .on .data_removed .emit (event .relation , event . relation . app ) # type: ignore
512517
513518 def wipe_ingress_data (self , relation : Relation ):
514519 """Clear ingress data from relation."""
@@ -523,6 +528,7 @@ def wipe_ingress_data(self, relation: Relation):
523528 )
524529 return
525530 del relation .data [self .app ]["ingress" ]
531+ self .on .endpoints_updated .emit (relation = relation , app = relation .app )
526532
527533 def _get_requirer_units_data (self , relation : Relation ) -> List ["IngressRequirerUnitData" ]:
528534 """Fetch and validate the requirer's unit databag."""
@@ -556,7 +562,9 @@ def get_data(self, relation: Relation) -> IngressRequirerData:
556562 self ._get_requirer_app_data (relation ), self ._get_requirer_units_data (relation )
557563 )
558564 except (pydantic .ValidationError , DataValidationError ) as e :
559- raise DataValidationError ("failed to validate ingress requirer data" ) from e
565+ raise DataValidationError (
566+ "failed to validate ingress requirer data: %s" % str (e )
567+ ) from e
560568
561569 def is_ready (self , relation : Optional [Relation ] = None ):
562570 """The Provider is ready if the requirer has sent valid data."""
@@ -566,7 +574,7 @@ def is_ready(self, relation: Optional[Relation] = None):
566574 try :
567575 self .get_data (relation )
568576 except (DataValidationError , NotReadyError ) as e :
569- log .debug ("Provider not ready; validation error encountered: %s" % str (e ))
577+ log .info ("Provider not ready; validation error encountered: %s" % str (e ))
570578 return False
571579 return True
572580
@@ -591,6 +599,7 @@ def publish_url(self, relation: Relation, url: str):
591599 ingress_url = {"url" : url }
592600 try :
593601 IngressProviderAppData (ingress = ingress_url ).dump (relation .data [self .app ]) # type: ignore
602+ self .on .endpoints_updated .emit (relation = relation , app = relation .app )
594603 except pydantic .ValidationError as e :
595604 # If we cannot validate the url as valid, publish an empty databag and log the error.
596605 log .error (f"Failed to validate ingress url '{ url } ' - got ValidationError { e } " )
@@ -756,7 +765,7 @@ def _handle_relation(self, event):
756765
757766 def _handle_relation_broken (self , event ):
758767 self ._stored .current_url = None # type: ignore
759- self .on .revoked .emit (event .relation ) # type: ignore
768+ self .on .revoked .emit (relation = event .relation , app = event . relation . app ) # type: ignore
760769
761770 def _handle_upgrade_or_leader (self , event ):
762771 """On upgrade/leadership change: ensure we publish the data we have."""
0 commit comments