openshift-cluster-acm-cleanup¶
A task to remove Advanced Cluster Management (ACM) from an OpenShift cluster
Advanced Cluster Management Cleanup Task¶
This task removes Red Hat Advanced Cluster Management (ACM) from an OpenShift cluster: the MultiClusterHub, the operator subscription, the ACM namespace and what the removal leaves behind. Deletes do not block, and every wait runs under one deadline and reports what it is waiting on.
Requirements¶
Parameters¶
- openshift/acm-namespace: Namespace containing ACM installation
- openshift/acm-operator-name: Name of ACM operator subscription
- openshift/acm-cleanup-timeout: One overall deadline for the task, in seconds
Cluster Access¶
- Administrative access to the OpenShift cluster
- Valid kubeconfig with cluster-admin privileges
- Required permissions for resource deletion
Usage¶
Basic Cleanup¶
# Apply cleanup task
drpcli machines tasks add <machine-uuid> openshift-cluster-acm-cleanup
# Verify removal
oc get mch -n open-cluster-management
oc get csv -n open-cluster-management
Cleanup Process¶
The task works in the following order:
1. Finds the MultiClusterHub. It fails, removing nothing, if the cluster API
cannot be read or a hub exists outside openshift/acm-namespace.
2. Checks for managed clusters before a hub or its engine is deleted. It
fails, removing nothing, if any cluster other than the hub's own
local-cluster is still attached, or if the check itself cannot be made.
3. Removes discovery configurations, the agent service configuration and
observability, which Red Hat documents as to be removed before the hub.
Only when a hub is being removed.
4. Deletes the MultiClusterHub and waits for it to be gone. A delete that the
cluster rejects is logged and repeated. Progress is logged while it waits.
5. Waits for the multicluster engine that the hub installed to be gone, and
deletes it first if an interrupted removal left it behind. An engine that
was installed on its own is left in place.
While it waits in steps 4, 5 and 10, it releases the hub's own Klusterlet
when the klusterlet operator is already gone: it removes the
operator.open-cluster-management.io/klusterlet-cleanup finalizer, and
only that finalizer, from a Klusterlet that has been waiting to be deleted
for at least 60 seconds, and only when no Deployment named klusterlet
exists in any namespace. Without its operator nothing else can release
that finalizer, and the Klusterlet CustomResourceDefinition (and sometimes
the hub) would wait behind it forever. Each removal is logged.
6. Removes the operator subscription, its ClusterServiceVersions and the
OperatorGroup.
7. Deletes the ACM namespace, which removes everything left in it
(InstallPlans, Secrets, ConfigMaps, ServiceAccounts, Routes, Services,
workloads and claims), and the hive and hypershift namespaces when
they hold no workloads, claims or operator subscriptions.
8. Removes stale APIServices and webhook configurations: ones whose service
is in an ACM namespace that is gone or terminating. A webhook
configuration is removed only when every webhook in it is stale.
9. Waits for the deleted namespaces to be gone.
10. Waits for every CustomResourceDefinition in an ACM API group
(open-cluster-management.io, multicluster.openshift.io,
hive.openshift.io, hiveinternal.openshift.io,
hypershift.openshift.io, agent-install.openshift.io and their
subgroups) that is waiting to be deleted to be gone. The task fails
rather than report success while one is still waiting to be deleted, or
when this cannot be checked, because installing ACM again would meet a
CustomResourceDefinition that is going away.
CustomResourceDefinitions that are not being deleted are left in place, as with any operator removal.
When the Removal Is Stuck¶
If the MultiClusterHub, the engine, a namespace or an ACM
CustomResourceDefinition that is being deleted is still there when
openshift/acm-cleanup-timeout passes, the task fails and prints what the
removal is waiting on: the hub, engine and ClusterManager that are left, the
namespaces that are still terminating, APIServices that are not available,
webhook configurations that point into an ACM namespace, and every object
whose finalizer holds a CustomResourceDefinition that is being deleted.
A finalizer is released by its controller. When that controller was removed first, the finalizer never clears and the removal waits forever. This is most likely when a hub is removed while it is still installing. Remove the listed finalizers by hand, then run the task again; it picks up from the state the cluster is in.
Verification Steps¶
# Verify namespace removal
oc get namespace open-cluster-management
# Check for remaining resources
oc get multiclusterhub --all-namespaces
oc get subscription --all-namespaces | grep advanced-cluster-management
Important Notes¶
- Backup any important data before running cleanup
- Detach managed clusters first; the task refuses to run while any are attached
- The hub removal can take up to 20 minutes, longer on a loaded cluster
- Wait for a hub that is still installing to finish before removing it
- The task can be run again after a failure
Objects that Reference openshift-cluster-acm-cleanup¶
- blueprints openshift-cluster-acm-cleanup in Openshift ACM as part of Tasks (declared)
Objects used by openshift-cluster-acm-cleanup¶
- templates openshift-cluster-acm-cleanup.sh.tmpl in field Templates[0].ID as value openshift-cluster-acm-cleanup.sh.tmpl