# 2021-11-18-17:46:24+0800 Clean unused cluster and backup

- Cause:

This [PR](https://github.com/tidbcloud/ops-trail/pull/116) delete the tenant, but there are still clusters running. These clusters become orphaned. So we need to clean them.

- Operation:

1. Run the following SQL statement to mark cluster as 'cleared'
``` sql
select * from tenants where email = 'huohao@pingcap.com'; -- find tenant id: 1372813089188751281
select * from clusters where tenant_id = 1372813089188751281; -- find running cluster id: 1379661944584004070 and project id: 1372813089188691298

select * from tenants where email = 'wangxingzong@pingcap.com'; -- find tenant id:
select * from clusters where tenant_id = 1372813089188331289; -- find running cluster id: 1379661944583914068 and project id: 1372813089188271285


update clusters set status = 'cleared' where tenant_id = 1372813089188331289 and id = 1379661944583914068; -- set cluster status as 'cleared'
update clusters set status = 'cleared' where tenant_id = 1372813089188751281 and id = 1379661944584004070; -- set cluster status as 'cleared'
```

2. Run the following command to clean the cluster and backup

``` shell
kubectl exec -it -n infra infra-provider-5996d84b9f-mbg8d -- sh
kubectl delete backup -n prod-1372813089188271285 ab-1379661944583914068-330032
kubectl delete cluster -n prod-1372813089188271285 1379661944583914068

kubectl delete backup -n prod-1372813089188691298 ab-1379661944584004070-300011
kubectl delete cluster -n prod-1372813089188691298 1379661944584004070
```

- Impact:

The orhpaned cluster will be cleaned.

- Recovery operation:

NA

- Time window:

2021-111-18 17:10 ~ 17:50 CST
