Skip to content

Zombie domains in the database after access for a domain is revoked #116

Description

@swetha1654

Bug Description

When the access to a domain for a user is revoked, the domain still remains in the domain table even if it is not accessed by any other user.
The charm needs to ensure that the domain is also deleted if the domain is not referenced in any other record under DomainUserPermission.

To Reproduce

  1. Deploy the charm and integrate with Postgres
  2. Add a user
  3. Provide access to a domain for the user.
  4. Revoke access to the domain for the user.
  5. The domain remains when you log in to the database and list the domain table.

Environment

Version - latest/edge Rev - 56

Relevant log output

httprequest-lego-provider=> select * from api_domain;
 id |             fqdn
----+-------------------------------
  1 | _acme-challenge.example.com
  2 | _acme-challenge.example2.com
  3 | _acme-challenge.*.example.com

httprequest-lego-provider=> select * from api_domainuserpermission;
 id | text | domain_id | user_id
----+------+-----------+---------
  1 |      |         1 |       1
  2 |      |         2 |       1

Row 3 in api_domain is a zombie domain.

Additional context

No response

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