From 76fe8c389b60aedb0662886ef212694d423f93e7 Mon Sep 17 00:00:00 2001 From: dushu Date: Tue, 14 Jan 2025 11:19:56 -0500 Subject: [PATCH] fix: fix the ldap requested event initialization --- lib/charms/glauth_k8s/v0/ldap.py | 7 +++++-- src/charm.py | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/charms/glauth_k8s/v0/ldap.py b/lib/charms/glauth_k8s/v0/ldap.py index 6e495780..3da0ab9c 100644 --- a/lib/charms/glauth_k8s/v0/ldap.py +++ b/lib/charms/glauth_k8s/v0/ldap.py @@ -135,7 +135,7 @@ def _on_ldap_requested(self, event: LdapRequestedEvent) -> None: RelationCreatedEvent, RelationEvent, ) -from ops.framework import EventSource, Object, ObjectEvents +from ops.framework import EventSource, Handle, Object, ObjectEvents from ops.model import Relation, SecretNotFoundError from pydantic import ( BaseModel, @@ -155,7 +155,7 @@ def _on_ldap_requested(self, event: LdapRequestedEvent) -> None: # Increment this PATCH version before using `charmcraft publish-lib` or reset # to 0 if you are raising the major API version -LIBPATCH = 7 +LIBPATCH = 8 PYDEPS = ["pydantic>=2.5.3"] @@ -280,6 +280,9 @@ class LdapRequirerData(BaseModel): class LdapRequestedEvent(RelationEvent): """An event emitted when the LDAP integration is built.""" + def __init__(self, handle: Handle, relation: Relation) -> None: + super().__init__(handle, relation, relation.app) + @property def data(self) -> Optional[LdapRequirerData]: relation_data = self.relation.data.get(self.relation.app) diff --git a/src/charm.py b/src/charm.py index 29fe3fd6..45e3d20f 100755 --- a/src/charm.py +++ b/src/charm.py @@ -28,6 +28,7 @@ from charms.prometheus_k8s.v0.prometheus_scrape import MetricsEndpointProvider from charms.traefik_k8s.v1.ingress_per_unit import IngressPerUnitRequirer from lightkube import Client +from ops import main from ops.charm import ( CharmBase, ConfigChangedEvent, @@ -37,7 +38,6 @@ RelationJoinedEvent, RemoveEvent, ) -from ops.main import main from ops.model import ActiveStatus, BlockedStatus, MaintenanceStatus from ops.pebble import ChangeError @@ -276,7 +276,7 @@ def __on_pebble_ready(self, event: PebbleReadyEvent) -> None: @wait_when(database_not_ready, service_not_ready) def _on_ldap_requested(self, event: LdapRequestedEvent) -> None: if not (requirer_data := event.data): - logger.error(f"The LDAP requirer {event.app.name} does not provide necessary data.") + logger.warning(f"The LDAP requirer {event.app.name} does not provide necessary data.") return self._ldap_integration.load_bind_account(