From 563de787869a0951abafcdf1dccb829fe1807675 Mon Sep 17 00:00:00 2001 From: revital Date: Sun, 16 Feb 2025 10:33:58 +0200 Subject: [PATCH] Add deleting tenants from ClearML --- .../enterprise_deploy/delete_tenant.md | 115 ++++++++++++++++++ sidebars.js | 1 + 2 files changed, 116 insertions(+) create mode 100644 docs/deploying_clearml/enterprise_deploy/delete_tenant.md diff --git a/docs/deploying_clearml/enterprise_deploy/delete_tenant.md b/docs/deploying_clearml/enterprise_deploy/delete_tenant.md new file mode 100644 index 00000000..9542de79 --- /dev/null +++ b/docs/deploying_clearml/enterprise_deploy/delete_tenant.md @@ -0,0 +1,115 @@ +--- +title: Deleting Tenants from ClearML +--- + +The following is a step-by-step guide for deleting tenants (i.e. companies, workspaces) from ClearML. + +:::caution +Deleting a tenant is a destructive operation that cannot be undone. +* Make sure you have the data prior to deleting the tenant. +* Backing up the system before deleting is recommended. +::: + +The tenant deletion is done from MongoDB, ElasticsSearch, and the Fileserver. + +The first two are done from within the `apiserver` container, and last from within the `fileserver` container. + +Any external artifacts (ex: AWS S3, GCS, minio) can be removed manually. + +## Deleting Tenants from MongoDB and ElasticSearch + +1. Enter the `apiserver` in one of the following ways + * In `docker-compose`: + + ``` + sudo docker exec -it allegro-apiserver /bin/bash + ``` + * In Kubernetes: + + ``` + kubectl -n exec -it -c clearml-apiserver -- /bin/bash + ``` + +1. Set the ID and the name of the company (tenant) you wish to delete + + ``` + tenant_to_delete= + company_name_to_delete="" + ``` + +1. Delete the company's data from MongoDB: + + ``` + PYTHONPATH=../trains-server-repo python3 \ + -m jobs.management.delete_company_data_from_mongo \ + --id $tenant_to_delete \ + --name \ + --delete-user + ``` + + :::note + This also deletes the admin users. Remove `--delete-user` to avoid this. + ::: + +1. Delete the company's data from ElasticSearch: + + ``` + PYTHONPATH=../trains-server-repo python3 \ + -m jobs.management.cleanup_deleted_companies \ + --ids $tenant_to_delete --delete-company + ``` + +1. Exit pod/container + +## Deleting Tenants from the Fileserver + +To remove a tenant's data from the fileserver, you can choose one of the following methods depending on your deployment setup: + +* Option 1: Delete the tenant's data from within the fileserver container or pod. +* Option 2: Delete the tenant's data externally from the host system. + +### Option 1 - From Within the Fileserver + + +1. Enter the `fileserver` in one of the following ways + * In `docker-compose`: + + ``` + sudo docker exec -it allegro-fileserver /bin/bash + ``` + * In Kubernetes: + + ``` + kubectl -n exec -it -c clearml-fileserver -- /bin/bash + ``` + +1. Run the following: + + ``` + rm -rf /mnt/fileserver/ + ``` + +1. Exit pod/container + +### Option 2 - External Deletion + +#### Docker compose + +Run the following: + +``` +rm -rf /opt/allegro/data/fileserver/ +``` + +#### Kubernetes + +Run the following: + +``` +kubectl -n exec -it -c clearml-apiserver -- /bin/bash -c "PYTHONPATH=../trains-server-repo python3 -m jobs.management.delete_company_data_from_mongo --id --delete-user" + +kubectl -n exec -it -c clearml-apiserver -- /bin/bash -c "PYTHONPATH=../trains-server-repo python3 -m jobs.management.cleanup_deleted_companies --ids --delete-company" + +kubectl -n exec -it -c clearml-fileserver -- /bin/bash -c "rm -rf /mnt/fileserver/" +``` + diff --git a/sidebars.js b/sidebars.js index c8059952..16c0e8ca 100644 --- a/sidebars.js +++ b/sidebars.js @@ -699,6 +699,7 @@ module.exports = { 'deploying_clearml/enterprise_deploy/on_prem_ubuntu', ] }, + 'deploying_clearml/enterprise_deploy/delete_tenant', { 'Enterprise Applications': [ 'deploying_clearml/enterprise_deploy/app_install_ubuntu_on_prem',