Handle a zero-worker Databricks cluster in _init_nodes - #2148
Merged
Merged
Conversation
`spark_rapids qualification --cluster <id>` (and `profiling`) on a Databricks single-node cluster died with `TypeError: 'NoneType' object is not iterable` in `_init_nodes`, because `databricks clusters get` returns no `executors` entry for a cluster with no workers and the guard added in NVIDIA#964 only regenerates the list when `num_workers` differs from the count. The intended answer for this shape, the `RuntimeError` "Invalid cluster: The cluster has no worker nodes" from NVIDIA#240, never ran. `_init_nodes` in the Azure and AWS platforms now reads `executors` as an empty list when the entry is absent. The count stays 0, the guard is unchanged, the loop is a no-op and `_verify_workers_exist` raises the intended error; every shape with a nonzero worker count takes the path it takes today, with the same log lines. Tests: `TestDatabricksClusterWorkers` in `tests/spark_rapids_tools_ut/test_cluster.py`, parametrized over AWS and Azure, loads the existing `{aws,azure}-cpu-00.json` fixtures with the `executors` entry removed through `load_cluster_by_prop`; `num_workers: 0` raises the `RuntimeError` (the `TypeError` on dev), `num_workers: 2` yields two generated workers. Fixes NVIDIA#2143 Signed-off-by: Thomas Wynne <jtwynne3@gmail.com>
jtwynne
force-pushed
the
db-zero-worker-cluster
branch
from
September 9, 2026 05:41
1994d09 to
e72575c
Compare
cindyyuanjiang
approved these changes
Sep 10, 2026
Collaborator
|
Thanks @jtwynne for this fix! Verified with a real Databricks-Azure cluster. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2143
Problem
spark_rapids qualification --cluster <id>(andprofiling, same path) on a Databrickssingle-node cluster died with
TypeError: 'NoneType' object is not iterablein_init_nodes.databricks clusters getreturns noexecutorsentry for a cluster with no workers, and theguard from #964 only regenerates the worker list when
num_workersdiffers from the executorcount, which is 0 in both cases. The intended answer for this shape, the
RuntimeError"Invalid cluster: The cluster has no worker nodes" added in #240, never ran because
_init_nodescrashes before_verify_workers_exist.A zero-worker cluster as
databricks clusters getreturns it (trimmed):{"cluster_id": "...", "state": "TERMINATED", "num_workers": 0, "node_type_id": "Standard_NC16as_T4_v3", "driver_node_type_id": "Standard_NC16as_T4_v3", "spark_conf": {"spark.databricks.cluster.profile": "singleNode", "spark.master": "local[*, 4]"}, "custom_tags": {"ResourceClass": "SingleNode"}}Fix
_init_nodesin the Azure and AWS platform classes readsexecutorsas an empty list when theentry is absent, the same line in the same place in both files, right after the
driverread(
drivergets its own absent-entry branch further down in the same method)._verify_workers_existraises the intended error. This restores the error, not single-node support; [BUG] --cluster on a zero-worker (single-node) Databricks cluster raises TypeError instead of the intended "no worker nodes" error #2143 notes
driver-only evaluation as a separate request.
executorspresent,
executorsempty) takes the path it takes today with the same log lines. Propswith none of
num_workers,autoscaleandexecutorsalso move from theTypeErrortothe same
RuntimeError.executorscount 0does not match the
num_workersvalue 0. Using generated names." on the zero-worker path.ClusterBase._process_loaded_propsis the hook for cleaning loaded properties (emr.pyunwraps its
Clusterwrapper there); neither Databricks class overrides it, so a defaultthere is a new override per file that writes into the props, against one line at the read.
Tests
TestDatabricksClusterWorkersintests/spark_rapids_tools_ut/test_cluster.py, parametrizedover the AWS and Azure platforms, loads the existing
{aws,azure}-cpu-00.jsonfixtures withthe
executorsentry removed and builds the cluster throughload_cluster_by_prop(no CLIcall on that path).
test_zero_worker_cluster_raises_no_workers_error:num_workers: 0raises theRuntimeErrorfrom_verify_workers_exist; ondevboth platforms fail it with theTypeError.test_terminated_cluster_generates_workers:num_workers: 2yields two generated workers,with and without the change.
spark_rapids_tools_utset passes (313). pylint 10.00/10 and flake8 clean.