|
4 | 4 |
|
5 | 5 | from databricks.sdk import WorkspaceClient |
6 | 6 | from databricks.sdk.errors import NotFound |
7 | | -from databricks.sdk.service import compute |
8 | 7 | from databricks.sdk.service.compute import ClusterDetails, ClusterSource, Policy |
9 | 8 |
|
10 | 9 | from databricks.labs.ucx.assessment.crawlers import ( |
@@ -68,21 +67,12 @@ def _check_init_scripts(self, cluster, failures): |
68 | 67 | continue |
69 | 68 | failures.append(f"{_AZURE_SP_CONF_FAILURE_MSG} cluster.") |
70 | 69 |
|
71 | | - def _check_cluster_failures(self, cluster: ClusterDetails | compute.ClusterSpec): |
| 70 | + def _check_cluster_failures(self, cluster: ClusterDetails): |
72 | 71 | 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 | | - ) |
82 | 72 | cluster_info = ClusterInfo( |
83 | | - cluster_id=cluster_id, |
| 73 | + cluster_id=cluster.cluster_id if cluster.cluster_id else "", |
84 | 74 | cluster_name=cluster.cluster_name, |
85 | | - creator=creator_user_name, |
| 75 | + creator=cluster.creator_user_name, |
86 | 76 | success=1, |
87 | 77 | failures="[]", |
88 | 78 | ) |
@@ -115,6 +105,11 @@ def _assess_clusters(self, all_clusters): |
115 | 105 | for cluster in all_clusters: |
116 | 106 | if cluster.cluster_source == ClusterSource.JOB: |
117 | 107 | 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 | + ) |
118 | 113 | yield self._check_cluster_failures(cluster) |
119 | 114 |
|
120 | 115 | def snapshot(self) -> Iterable[ClusterInfo]: |
|
0 commit comments