Normally, cluster configurations are automatically deleted 30 days after the cluster was last terminated.
If you want to keep specific cluster configurations, you can pin them. Up to 100 clusters can be pinned.
Pinned clusters are not automatically deleted, however they can be manually deleted.
You can easily pin a cluster (AWS | Azure | GCP) via the workspace UI, but if you are managing your clusters via the API, you can also use the Pin endpoint (AWS | Azure | GCP) in the Clusters API.
Instructions
Pin all unpinned clusters
Use the following sample code to pin all unpinned clusters in your workspace.
Before running the sample code, you will need a personal access token (AWS | Azure | GCP) and your workspace domain. The workspace domain is just the domain name.
- Copy and paste the sample code into a notebook cell.
- Update the <workspace-domain-without-trailing-backlash> and <personal-access-token> values.
- Run the cell to pin all unpinned clusters in your workspace.
%python import requests workspace_url = "<workspace-domain-without-trailing-backlash>" access_token = "<personal-access-token>" url = workspace_url + "/api/2.0/clusters/list" headers = { 'Authorization': 'Bearer ' + access_token } cluster = requests.request("GET", url, headers=headers).json() for unpinned in cluster["clusters"]: if not 'pinned_by_user_name' in unpinned : print("Pinning"+" , "+ unpinned["default_tags"]['ClusterName']) url = workspace_url + "/api/2.0/clusters/pin" requests.post(url,json={"cluster_id" : unpinned["cluster_id"]},headers=headers)
Pin a cluster by name
Use the following sample code to pin a specific cluster in your workspace.
Before running the sample code, you will need a personal access token and your workspace domain. The workspace domain is just the domain name.
- Copy and paste the sample code into a notebook cell.
- Update the <workspace-domain-without-trailing-backlash> and <personal-access-token> values.
- Update the <cluster-name-to-pin> value with the name of the cluster you want to pin.
- Run the cell to pin the selected cluster in your workspace.
%python import requests workspace_url = "<workspace-domain-without-trailing-backlash>" access_token = "<personal-access-token>" url = workspace_url + "/api/2.0/clusters/list" headers = { 'Authorization': 'Bearer ' + access_token } cluster = requests.request("GET", url, headers=headers).json() for unpinned in cluster["clusters"]: if not 'pinned_by_user_name' in unpinned : if unpinned["default_tags"]['ClusterName'] == "<cluster-name-to-pin>" : print("Pinning"+" , "+ unpinned["default_tags"]['ClusterName']) url = workspace_url + "/api/2.0/clusters/pin" requests.post(url,json={"cluster_id" : unpinned["cluster_id"]},headers=headers)
Pin all clusters by a specific user
Use the following sample code to pin a specific cluster in your workspace.
Before running the sample code, you will need a personal access token and your workspace domain. The workspace domain is just the domain name.
- Copy and paste the sample code into a notebook cell.
- Update the <workspace-domain-without-trailing-backalsh> and <personal-access-token> values.
- Update the <cluster-creator-username> value with the name of the user whose clusters you want to pin.
- Run the cell to pin the selected clusters in your workspace.
%python import requests workspace_url = "<workspace-domain-without-trailing-backlash>" access_token = "<personal-access-token>" url = workspace_url + "/api/2.0/clusters/list" headers={ 'Authorization': 'Bearer ' + access_token } cluster = requests.request("GET", url, headers=headers).json() for unpinned in cluster["clusters"]: if not 'pinned_by_user_name' in unpinned : if unpinned["creator_user_name"] == "<cluster-creator-username>" : url = shard_url + "/api/2.0/clusters/pin" requests.post(url,json={"cluster_id" : unpinned["cluster_id"]},headers=headers) print("Pinning"+" , "+ unpinned["default_tags"]['ClusterName'])