Skip to content

Provide more context when raising ModelError #2575

Description

@sed-i

Recently we received a log blob that included:

unit-otelcol-0: 08:53:35 ERROR unit.otelcol/0.juju-log grafana-dashboards-consumer:262: Uncaught exception while in charm code:
Traceback (most recent call last):

...

ops.hookcmds._utils.Error: command ('relation-get', '--format=json', '-r', '250', '--app', '-', 'otelcol') exited with status 1

...

ops.model.ModelError: ERROR permission denied (unauthorized access)

The trouble is that when we get to triage/troubleshoot, the full original logs/env are not available to us, so it is difficult to pinpoint what went wrong.

It would be helpful if a ModelError exception message included:

  • hook name or action name
  • (relation name and id are in the log blob above, but "far away" from the ModelError message)

Perhaps jujucontext could have a method such as "error_message_context" that would format some details. For example, if the current hook is a secret hook, then render fields relevant to secrets, etc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions