Skip to content

create-replication action crashes with AttributeError when async-replication relation is not established #1675

@jansdhillon

Description

@jansdhillon

Bug

Running the create-replication action on a unit that has no async-replication relation crashes with an unhandled AttributeError.

Steps to reproduce

  1. Deploy postgresql (VM charm) with no async-replication relation
  2. Run juju run postgresql/<unit> create-replication name=default

Error

Action id 2865 failed: exit status 1

Uncaught AttributeError in charm code: 'NoneType' object has no attribute 'name'

Full traceback from /var/log/juju/unit-postgresql-54.log:

Traceback (most recent call last):
  ...
  File ".../src/relations/async_replication.py", line 602, in _on_create_replication
    if self._relation.name == REPLICATION_CONSUMER_RELATION:
       ^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'name'

self._relation is None because no async-replication relation exists on the unit. The handler does not guard against this.

Environment

  • Charm: Charmed PostgreSQL VM
  • Charm revision: 1047
  • Juju version: juju version on controller

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    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