Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(charm): make collect-status a LifeCycleEvent to avoid logging it #1080

Merged
merged 4 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ops/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
EventSource,
Framework,
Handle,
LifecycleEvent,
Object,
ObjectEvents,
)
Expand Down Expand Up @@ -914,7 +915,7 @@ def defer(self) -> NoReturn:
'this event until you create a new revision.')


class CollectStatusEvent(EventBase):
class CollectStatusEvent(LifecycleEvent):
"""Event triggered at the end of every hook to collect statuses for evaluation.

If the charm wants to provide application or unit status in a consistent
Expand Down
1 change: 1 addition & 0 deletions ops/framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,7 @@ def _reemit(self, single_event_path: Optional[str] = None):
elif self._event_name and self._event_name != event.handle.kind:
# if the event we are emitting now is not the event being
# dispatched, and it also is not an event we have deferred,
# and is also not a lifecycle (framework-emitted) event,
# it must be a custom event
logger.debug("Emitting custom event %s.", event)

Expand Down
8 changes: 5 additions & 3 deletions test/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,9 +866,11 @@ def _call_event(self, rel_path: Path, env: typing.Dict[str, str]):

def test_setup_event_links(self):
"""Test auto-creation of symlinks caused by initial events."""
all_event_hooks = [f"hooks/{name.replace('_', '-')}"
for name, event_source in self.charm_module.Charm.on.events().items()
if issubclass(event_source.event_type, ops.LifecycleEvent)]
all_event_hooks = [
f"hooks/{name.replace('_', '-')}"
for name, event_source in self.charm_module.Charm.on.events().items()
if issubclass(event_source.event_type, (ops.CommitEvent, ops.PreCommitEvent))
]

initial_events = {
EventSpec(ops.InstallEvent, 'install'),
Expand Down
Loading