OpenShift Tips

Baremetal

Unblock a stuck oc delete bmh command

Sometimes, when deleting a BMH object with oc delete bmh -n openshift-machine-api <node name> the delete command is stuck forever. This happens because ironic is trying to decommision and delete stuff from the node itself, and does not always succeed with that.

To unblock the delete command, simply remove the object finalizer: oc patch -n openshift-machine-api <node name> -p '{"metadata":{"finalizers":null}}' --type=merge

Reprovisioning a node

  1. for conveniency oc project openshift-machine-api
  2. locate the correct secret, it’ll have the same name as the bmh with a ‘-bmc-secret’ postfix.
  3. save the secret - oc get secret <bmh-name-bmc-secret> -o yaml > secret.yaml
  4. save the bmh - oc get bmh <bmh-name> -o yaml > bmh.yaml
  5. only then delete the bmh - oc delete bmh <bmh-name>
  6. edit the secert.yaml file so it includes only the date, type, metadata.name and meteadata.namespace fields
  7. edit the bmh.yaml so it includes only the oc spec, metadata.name and meteadata.namespace fields
  8. apply - oc apply -f secert.yaml and then oc apply -f bmh.yaml

The node should start reprovisioning and be ready after a while.

Last updated on 25 Apr 2021
Published on 18 Jun 2019
Edit on GitHub