// Module included in the following assemblies:
//
// * nodes/nodes/nodes-nodes-replace-control-plane.adoc

:_mod-docs-content-type: PROCEDURE
[id="deleting-machine_{context}"]
= Deleting the machine of the unhealthy etcd member

Finish removing the failed control plane node by deleting the machine of the unhealthy etcd member.

.Procedure

. Ensure that the Bare Metal Operator is available by running the following command:
+
[source,terminal]
----
$ oc get clusteroperator baremetal
----
+
.Example output
[source,terminal]
----
NAME        VERSION   AVAILABLE   PROGRESSING   DEGRADED   SINCE   MESSAGE
baremetal   4.21.0    True        False         False      3d15h
----

. Save the `BareMetalHost` object of the affected node to a file for later use by running the following command:
+
[source,terminal]
----
$ oc get -n openshift-machine-api bmh <node_name> -o yaml > bmh_affected.yaml
----
+
Replace `<node_name>` with the name of the affected node, which usually matches the associated `BareMetalHost` name.

. View the YAML file of the saved `BareMetalHost` object by running the following command, and ensure the content is correct:
+
[source,terminal]
----
$ cat bmh_affected.yaml
----

. Remove the affected `BareMetalHost` object by running the following command:
+
[source,terminal]
----
$ oc delete -n openshift-machine-api bmh <node_name>
----
+
Replace `<node_name>` with the name of the affected node.

. List all machines by running the following command and identify the machine associated with the affected node:
+
[source,terminal]
----
$ oc get machines -n openshift-machine-api -o wide
----
+
.Example output
[source,terminal]
----
NAME                            PHASE    TYPE  REGION  ZONE  AGE    NODE                       PROVIDERID                                                                                             STATE
examplecluster-control-plane-0  Running                      3h11m  openshift-control-plane-0  baremetalhost:///openshift-machine-api/openshift-control-plane-0/da1ebe11-3ff2-41c5-b099-0aa41222964e  externally provisioned
examplecluster-control-plane-1  Running                      3h11m  openshift-control-plane-1  baremetalhost:///openshift-machine-api/openshift-control-plane-1/d9f9acbc-329c-475e-8d81-03b20280a3e1  externally provisioned
examplecluster-control-plane-2  Running                      3h11m  openshift-control-plane-2  baremetalhost:///openshift-machine-api/openshift-control-plane-2/3354bdac-61d8-410f-be5b-6a395b056135  externally provisioned
examplecluster-compute-0        Running                      165m   openshift-compute-0        baremetalhost:///openshift-machine-api/openshift-compute-0/3d685b81-7410-4bb3-80ec-13a31858241f        provisioned
examplecluster-compute-1        Running                      165m   openshift-compute-1        baremetalhost:///openshift-machine-api/openshift-compute-1/0fdae6eb-2066-4241-91dc-e7ea72ab13b9        provisioned
----

. Delete the machine of the unhealthy member by running the following command:
+
[source,terminal]
----
$ oc delete machine -n openshift-machine-api <machine_name>
----
+
Replace `<machine_name>` with the machine name associated with the affected node.
+
.Example command
[source,terminal]
----
$ oc delete machine -n openshift-machine-api examplecluster-control-plane-2
----
+
[NOTE]
====
After you remove the `BareMetalHost` and `Machine` objects, the machine controller automatically deletes the `Node` object.
====

. If deletion of the machine is delayed for any reason or the command is obstructed and delayed, force deletion by removing the machine object finalizer field.
+
[WARNING]
====
Do not interrupt machine deletion by pressing `Ctrl+c`. You must allow the command to proceed to completion. Open a new terminal window to edit and delete the finalizer fields.
====

.. On a new terminal window, edit the machine configuration by running the following command:
+
[source,terminal]
----
$ oc edit machine -n openshift-machine-api examplecluster-control-plane-2
----

.. Delete the following fields in the `Machine` custom resource, and then save the updated file:
+
[source,yaml]
----
finalizers:
- machine.machine.openshift.io
----
+
.Example output
[source,terminal]
----
machine.machine.openshift.io/examplecluster-control-plane-2 edited
----
