Removing a PVC (Parallels Virtuozzo Containers) hardware node registered in POA fails with the error message like this:
Error Foreign key 've_templates_fk0' violation while executing ' DELETE FROM vz_templates WHERE origin = ? AND NOT EXISTS (SELECT 1 FROM hn_templates WHERE vz_templates.template_id = hn_templates.template_id)'
The issue is caused by pre-installed OS or application template on the hardware node being removed that is also installed in a VPS running on another PVC hardware node.
In the past, when the problem PVC hardware node was registered in POA, Provider imported OS and application templates installed on it into the POA database, this can be done using the 'Update templates' button on the 'General' tab in the hardware node properties in the POA Provider Control Panel.
During the templates importing POA added templates into the system database and marked them as pre-installed exactly from the server which Provider is going to remove from POA now.
So, according to the POA database, the hardware node being removed is the node from which the template installed in some VPS running on another node was imported. POA does not allow to remove the hardware node because it would lead to the template removal and this cannot be done because the template is installed in some VPS.
The template which does not allow to remove the PVC hardware node may be found in the [poa.debug.log] (https://kb.cloudblue.com/116741 "") during the attempt to remove the server from POA.
For example, the following SQL query from the poa.debug.log shows pre-installed templates (origin = 2) installed on the hardware node #4:
plesk=> SELECT DISTINCT v.host_id AS ve_id, h.template_id, t.name, t.origin FROM hn_templates h JOIN vz_templates t ON h.template_id=t.template_id JOIN ve_templates v ON v.template_id=t.template_id WHERE h.host_id = 4 AND origin = 2; ve_id | template_id | name | origin ---------+-------------+----------------------+-------- 7 | 1139 | .centos-5-x86_64 | 2 7 | 1547 | .pp10 | 2 (2 rows)
The output above means that the OS template centos-5-x86_64 and the application template pp10 were imported from the PVC hardware node #4 (they are marked as pre-installed in the POA database) and these template are used by the VPS #7 (the 've_id' column). POA will not allow to remove the PVC hardware #4.
To resolve the problem Provider has to add problem OS and application templates into POA properly:
- Go to Service Director > Virtuozzo Manager > OS Templates or Service Director > Virtuozzo Manager > Application Templates
- Click the Add New OS Template or the Add New Application Template button
- Follow the template installation wizard
Alternatively, you may want to remove the VPS(s) which do not allow to remove the PVC hardware node.