YYYY-MM-DDTHH:MM:SS.###Z error wcp [eamagency/create.go:72] [opID=vCLS] Unable to create entity in db for cluster agency: ERROR: duplicate key value violates unique constraint "hdcs_cluster_agencies_pkey" (SQLSTATE 23505)
YYYY-MM-DDTHH:MM:SS.###Z-04:00 error vpxd[11060] [Originator@6876 sub=Default opID=wcp-vCLS-9b] [VdbStatement] SQLError was thrown: "ODBC error: (23505) - ERROR: duplicate key value violates unique constraint "pk_vpx_auth_tenant_mgmt_rs"When an entry related to vCLS is removed from the vpx_ext_data table in the vCenter database, it correctly triggers the automatic removal of the associated vCLS agency VMs from vCenter. However, the corresponding agency entry in the hdcs.hdcs_cluster_agencies table might not be cleaned up simultaneously. This inconsistency leaves a stale record, which prevents the system from provisioning new vCLS entries or VMs for that cluster.
Note: Before undertaking the following steps, it is strongly recommended to create a snapshot of your vCenter Server, please refer KB: VMware vCenter in Enhanced Linked Mode pre-changes snapshot (online or offline) best practice
To resolve this issue, the stale agency entry must be manually located and removed from the hdcs.hdcs_cluster_agencies table within the vCenter Server's embedded vPostgres database.
VCDB=# SELECT cluster_moref, agency_moref FROM hdcs.hdcs_cluster_agencies WHERE cluster_moref='<domain-number-of-cluster>';
For example:
VCDB=# select cluster_moref, agency_moref FROM hdcs.hdcs_cluster_agencies WHERE cluster_moref='domain-c30019';
cluster_moref | agency_moref---------------+-------------------------------------- domain-c30019 | 7f4ec319-053d-4dff-8dda-a69ee368a86e(1 row)
VCDB=# delete from hdcs.hdcs_cluster_agencies where cluster_moref='<domain-number-of-cluster>';
The <domain-number-of-cluster> is same as from step 4.
cluster_moref | agency_moref---------------+--------------(0 rows)Once the cluster agency entry is deleted from hdcs.hdcs_cluster_agencies, the vCLS VMs should be immediately re-created.