Skip to content

Commit d988a7e

Browse files
committed
Handle missing Instance Pools in cluster import
1 parent e731057 commit d988a7e

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

dbclient/ClustersClient.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,19 @@ def cleanup_cluster_pool_configs(self, cluster_json, cluster_creator, is_job_clu
4747
:return:
4848
"""
4949
pool_id_dict = self.get_instance_pool_id_mapping()
50-
# if pool id exists, remove instance types
51-
cluster_json.pop('node_type_id', None)
52-
cluster_json.pop('driver_node_type_id', None)
53-
cluster_json.pop('enable_elastic_disk', None)
50+
51+
if not pool_id_dict:
52+
logging.info("WARNING: instance pool is outdated. Pools may have been deleted; cluster will use defaults.")
53+
cluster_json.pop("instance_pool_id")
54+
else:
55+
# if pool id exists, remove instance types
56+
cluster_json.pop('node_type_id', None)
57+
cluster_json.pop('driver_node_type_id', None)
58+
cluster_json.pop('enable_elastic_disk', None)
59+
# map old pool ids to new pool ids
60+
old_pool_id = cluster_json['instance_pool_id']
61+
cluster_json['instance_pool_id'] = pool_id_dict.get[old_pool_id]
62+
5463
if not is_job_cluster:
5564
# add custom tag for original cluster creator for cost tracking
5665
if 'custom_tags' in cluster_json:
@@ -65,9 +74,7 @@ def cleanup_cluster_pool_configs(self, cluster_json, cluster_creator, is_job_clu
6574
iam_role = aws_conf.get('instance_profile_arn', None)
6675
if not iam_role:
6776
cluster_json['aws_attributes'] = {'instance_profile_arn': iam_role}
68-
# map old pool ids to new pool ids
69-
old_pool_id = cluster_json['instance_pool_id']
70-
cluster_json['instance_pool_id'] = pool_id_dict[old_pool_id]
77+
7178
return cluster_json
7279

7380
def delete_all_clusters(self):

0 commit comments

Comments
 (0)