VK Cloud logo

Cannot delete a security group

When deleting a security group, an error occurs:

Failed to delete group with name or ID 'f4ad1825-XXXX-XXXX-XXXX': ConflictException: 409:Client Error for url: https://infra.mail.ru:9696/v2.0/security-groups/f4ad1825-XXXX-XXXX-XXXX,Security Group f4ad1825-XXXX-XXXX-XXXX in use.1 of 1 groups failed to delete.

The problem occurs if the security group is in use and attached to ports.

Solution

  1. Make sure the OpenStack client is installed, and authenticate in the project.

  2. Make sure the additional neutron package is installed.

  3. Get a list of port IDs associated with the security group:

    neutron port-list -c id -c name -c security_groups | grep <SECURITY_GROUP_ID> | awk '{print $2}'

    Here, <SECURITY_GROUP_ID> is the security group ID that could not be deleted.

  4. Detach the security group from each port:

    openstack port unset --security-group <SECURITY_GROUP_ID> <PORT_ID>

    Here:

    • <SECURITY_GROUP_ID> — the ID of the security group that could not be deleted.
    • <PORT_ID> — the port ID from the list obtained earlier.
  5. Delete the security group:

    openstack security group delete <SECURITY_GROUP_ID>
  6. If the problem persists, contact technical support.

Was this article helpful?