This page explains how to update and delete an existing Managed Service for Apache Spark cluster.

## Update a cluster

You can update a cluster by issuing a Dataproc API
[clusters.patch](https://docs.cloud.google.com/managed-spark/docs/reference/rest/v1/projects.regions.clusters/patch.md.txt) request, running
a [gcloud dataproc clusters update](https://docs.cloud.google.com/sdk/gcloud/reference/dataproc/clusters/update.md.txt)
command in a local terminal window or in
[Cloud Shell](https://console.cloud.google.com/?cloudshell=true), or by editing cluster
parameters from the Configuration tab of the Cluster details page for the
cluster in the [Google Cloud console](https://console.cloud.google.com/dataproc/clusters).

The following cluster parameters can be updated:

- the number of standard worker nodes in a cluster---see [Scaling clusters](https://docs.cloud.google.com/managed-spark/docs/concepts/scaling-clusters)
- the number of secondary worker nodes in a cluster--- see [Managed Service for Apache Spark secondary workers](https://docs.cloud.google.com/managed-spark/docs/concepts/compute/secondary-vms.md.txt)
- whether to use [graceful decommissioning](https://docs.cloud.google.com/managed-spark/docs/concepts/configuring-clusters/scaling-clusters.md.txt#graceful_decommissioning) to control shutting down a worker after its jobs are completed
- adding or deleting cluster [labels](https://docs.cloud.google.com/managed-spark/docs/concepts/labels)

### Cluster update error

Managed Service for Apache Spark issues an `ERROR_DUE_TO_UPDATE` error when a cluster
update operation fails. This error places the cluster in a fail-safe state to
avoid data loss, and restricts further cluster operations: jobs can continue
to be submitted to the cluster, the cluster can be deleted, but further
cluster update operations are not permitted.

Recommendation: After receiving an `ERROR_DUE_TO_UPDATE` on a cluster,
[recreate the cluster](https://docs.cloud.google.com/managed-spark/docs/guides/recreate-cluster.md.txt#recreate_and_update_a_cluster)
by exporting the cluster configuration to create a new cluster, then delete the
failed cluster. If recreating the cluster fails, contact
[Cloud Customer Care](https://docs.cloud.google.com/support) for help in restoring the cluster to a
`RUNNING` state.

> [!NOTE]
> **Note:** A cluster can enter the `ERROR_DUE_TO_UPDATE` state if you attempt to update cluster resources through Compute Engine API operations. To update cluster resources, use [Managed Service for Apache Spark update](https://docs.cloud.google.com/managed-spark/docs/guides/manage-cluster.md.txt#update_a_cluster) operations.

## Delete a cluster

You can delete a cluster via a Dataproc API
[clusters.delete](https://docs.cloud.google.com/managed-spark/docs/reference/rest/v1/projects.regions.clusters/delete.md.txt) HTTP or programmatic request, using the Google Cloud CLI
[gcloud](https://docs.cloud.google.com/sdk/gcloud/reference/dataproc/clusters/delete)
command-line tool locally in a terminal window or in [Cloud Shell](https://console.cloud.google.com/?cloudshell=true), or from the [Google Cloud console](https://console.cloud.google.com/dataproc/clusters).

> [!CAUTION]
> **Deletion is permanent:** Once deleted, clusters cannot be restored. You can, however, quickly create new Managed Service for Apache Spark clusters as you need them.

### Google Cloud CLI

To delete a Managed Service for Apache Spark cluster, use the gcloud CLI
[gcloud dataproc clusters delete](https://docs.cloud.google.com/sdk/gcloud/reference/dataproc/clusters/delete)
command locally in a terminal window or in
[Cloud Shell](https://console.cloud.google.com/?cloudshell=true).

```
gcloud dataproc clusters delete cluster-name \
    --region=region
```

### REST API

Use the Managed Service for Apache Spark
[clusters.delete](https://docs.cloud.google.com/managed-spark/docs/reference/rest/v1/projects.regions.clusters/delete.md.txt)
API to delete a cluster.

### Console

Open the Managed Service for Apache Spark
[Clusters](https://console.cloud.google.com/dataproc/clusters)
page in the Google Cloud console. Select the cluster by checking the box
to the left of the cluster name, then Click **Delete** to
delete the cluster.
![](https://docs.cloud.google.com/static/managed-spark/images/dataproc-1-delete.png)