cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Cluster termination using python script, sending return code 1

Harsh-dataB
New Contributor II

i have used a cluster termination logic for terminating a cluster , the issue is , the cluster is not terminating gracefully , returns a return/exit code 1

The cluster is completing all the spark jobs, but it goes on long running state, hence i created a logic for terminating the clusters getting in long run state,

is there any way to change the return code to 0 , or terminate the cluster gracefully .

2 REPLIES 2

Kaniz_Fatma
Community Manager
Community Manager

Hi @Harsh-dataB,

  • First, review your cluster termination logic. Make sure it accounts for all necessary cleanup tasks and allows sufficient time for Spark jobs to complete.
  • If youโ€™re using custom scripts or logic, ensure that it gracefully handles all necessary shutdown procedures.
  • Check your cluster configuration settings in Databricks. Verify that resource limits, timeouts, and eviction policies are appropriately configured.
  • Adjust these settings if needed to allow for graceful termination.
  • Unfortunately, Databricks doesnโ€™t directly allow changing the exit code from 1 to 0 during cluster termination.
  • However, you can create a custom script or wrapper around your termination logic. In this script, you can explicitly exit with code 0 after ensuring all necessary cleanup tasks are completed.
  • As a workaround, consider manually terminating the cluster using the Databricks UI or API. This way, you can ensure proper cleanup.
  • If youโ€™re using the Databricks REST API, you can issue a POST request to the /api/2.0/clusters/delete endpoint with the appropriate cluster-ID.

If you encounter any challenges or need further assistance, feel free to ask! ๐Ÿ˜Š๐Ÿš€

I am terminating the cluster manually using Databricks API, that only gives the return code 1, and have checked all the necessary changes, but nothing works.

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group