-
Bug
-
Resolution: Won't Do
-
Normal
-
None
-
4.12.z
-
None
-
Quality / Stability / Reliability
-
False
-
-
None
-
Moderate
-
No
-
None
-
None
-
None
-
None
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Description of problem:
When running the cleanup script provided from the github page the script does not remove the klusterlet CRD. So when trying to detach a cluster and import it back you receive the following error:
The cluster cannot be imported because its Klusterlet CRD already exists. Either the cluster was already imported, or it was not detached completely during a previous detach process. Detach the existing cluster before trying the import again.
Version-Release number of selected component (if applicable):
2.8.1
How reproducible:
Very
Steps to Reproduce:
1. oc login to a cluster that has the klusterlet CRD 2. run cleanup shell script 3. execute generated command from RHACM Infrastructure tab
Actual results:
The cluster cannot be imported because its Klusterlet CRD already exists. Either the cluster was already imported, or it was not detached completely during a previous detach process. Detach the existing cluster before trying the import again.
Expected results:
Cluster is connected to hub cluster and becomes available/connected
Additional info:
I found an old bug from a previous version with this same issue https://github.com/stolostron/deploy/issues/179
Here is the cleanup script:
#!/bin/bash
###############################################################################
# Copyright (c) 2020 Red Hat, Inc.
###############################################################################if [ -z "${OPERATOR_NAMESPACE}" ]; then
OPERATOR_NAMESPACE="open-cluster-management-agent-addon"
fiif [ -z "${KLUSTERLET_NAMESPACE}" ]; then
KLUSTERLET_NAMESPACE="open-cluster-management-agent"
fiKUBECTL=oc# Force delete klusterlet
echo "attempt to delete klusterlet"
${KUBECTL} delete klusterlet klusterlet --timeout=60s
${KUBECTL} delete namespace ${KLUSTERLET_NAMESPACE} --wait=false
echo "force removing klusterlet"
${KUBECTL} patch klusterlet klusterlet --type="json" -p '[{"op": "remove", "path":"/metadata/finalizers"}]'
echo "removing klusterlet crd"
${KUBECTL} delete crd klusterlets.operator.open-cluster-management.io --timeout=30s# Force delete all component CRDs if they still exist
component_crds=(
applicationmanagers.agent.open-cluster-management.io
certpolicycontrollers.agent.open-cluster-management.io
iampolicycontrollers.agent.open-cluster-management.io
policycontrollers.agent.open-cluster-management.io
searchcollectors.agent.open-cluster-management.io
workmanagers.agent.open-cluster-management.io
appliedmanifestworks.work.open-cluster-management.io
klusterlets.operator.open-cluster-management.io
)for crd in "${component_crds[@]}"; do
echo "force delete all CustomResourceDefinition ${crd} resources..."
for resource in `${KUBECTL} get ${crd} -o name -n ${OPERATOR_NAMESPACE}`; do
echo "attempt to delete ${crd} resource ${resource}..."
${KUBECTL} delete ${resource} -n ${OPERATOR_NAMESPACE} --timeout=30s
echo "force remove ${crd} resource ${resource}..."
${KUBECTL} patch ${resource} -n ${OPERATOR_NAMESPACE} --type="json" -p '[{"op": "remove", "path":"/metadata/finalizers"}]'
done
echo "force delete all CustomResourceDefinition ${crd} resources..."
${KUBECTL} delete crd ${crd}
done${KUBECTL} delete namespace ${OPERATOR_NAMESPACE}