Skip to content

Commit aeda4c9

Browse files
authored
Changed _check_cluster_failures to be more resilient. (#845)
1 parent b4128cc commit aeda4c9

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

src/databricks/labs/ucx/assessment/clusters.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
from databricks.sdk import WorkspaceClient
66
from databricks.sdk.errors import NotFound
7-
from databricks.sdk.service import compute
87
from databricks.sdk.service.compute import ClusterDetails, ClusterSource, Policy
98

109
from databricks.labs.ucx.assessment.crawlers import (
@@ -68,21 +67,12 @@ def _check_init_scripts(self, cluster, failures):
6867
continue
6968
failures.append(f"{_AZURE_SP_CONF_FAILURE_MSG} cluster.")
7069

71-
def _check_cluster_failures(self, cluster: ClusterDetails | compute.ClusterSpec):
70+
def _check_cluster_failures(self, cluster: ClusterDetails):
7271
failures = []
73-
if isinstance(cluster, ClusterDetails) and not cluster.creator_user_name:
74-
logger.warning(
75-
f"Cluster {cluster.cluster_id} have Unknown creator, it means that the original creator "
76-
f"has been deleted and should be re-created"
77-
)
78-
cluster_id = cluster.cluster_id if isinstance(cluster, ClusterDetails) and cluster.cluster_id else ""
79-
creator_user_name = (
80-
cluster.creator_user_name if isinstance(cluster, ClusterDetails) and cluster.creator_user_name else None
81-
)
8272
cluster_info = ClusterInfo(
83-
cluster_id=cluster_id,
73+
cluster_id=cluster.cluster_id if cluster.cluster_id else "",
8474
cluster_name=cluster.cluster_name,
85-
creator=creator_user_name,
75+
creator=cluster.creator_user_name,
8676
success=1,
8777
failures="[]",
8878
)
@@ -115,6 +105,11 @@ def _assess_clusters(self, all_clusters):
115105
for cluster in all_clusters:
116106
if cluster.cluster_source == ClusterSource.JOB:
117107
continue
108+
if not cluster.creator_user_name:
109+
logger.warning(
110+
f"Cluster {cluster.cluster_id} have Unknown creator, it means that the original creator "
111+
f"has been deleted and should be re-created"
112+
)
118113
yield self._check_cluster_failures(cluster)
119114

120115
def snapshot(self) -> Iterable[ClusterInfo]:

src/databricks/labs/ucx/assessment/jobs.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from dataclasses import dataclass
44

55
from databricks.sdk import WorkspaceClient
6+
from databricks.sdk.service.compute import ClusterDetails
67
from databricks.sdk.service.jobs import BaseJob
78

89
from databricks.labs.ucx.assessment.clusters import ClustersMixin
@@ -84,7 +85,8 @@ def _assess_jobs(self, all_jobs: list[BaseJob], all_clusters_by_id) -> Iterable[
8485
job_id = job.job_id
8586
if not job_id:
8687
continue
87-
cluster_failures = self._check_cluster_failures(cluster_config)
88+
cluster_details = ClusterDetails.from_dict(cluster_config.as_dict())
89+
cluster_failures = self._check_cluster_failures(cluster_details)
8890
for failure in json.loads(cluster_failures.failures):
8991
job_assessment[job_id].add(failure)
9092

0 commit comments

Comments
 (0)