Uploaded image for project: 'Red Hat Advanced Cluster Management'
  1. Red Hat Advanced Cluster Management
  2. ACM-7482

Cleanup Script does not remove klusterlet CRD

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Critical Critical
    • ACM 2.8.Z
    • ACM 2.8.1
    • Server Foundation
    • None
    • True
    • Klusterlet CRD is causing import command to fail so no existing clusters in our test environment can be imported
    • False
    • Critical
    • No

      Description of problem:

      Unable to remove klusterlet CRD from ocp cluster with cleanup script. This makes it so I am unable to import existing clusters to my RHACM environment. When trying to run the auto generated command to install the klusterlet agent it thinks it already exists on the cluster. I also tried removing the klusterlet CRD manually and had the same result when trying to import an existing cluster. 

      Version-Release number of selected component (if applicable):

      OCP 4.12.17 RHACM 2.8.1

      How reproducible:

      Consistent

      Steps to Reproduce:

      1. Log onto cluster that has RHACM installed and multi-cluster hub CRD created
      2. download and run cleanup shell script targeting the cluster you want to import that had a klusterlet on it
      3. Go to RHACM console and select the infrastructure tab
      4. click import cluster
      5. give it a name (ignore the ansible portion) 
      6. click generate command and copy the command
      7. log onto target managed cluster you want to import and run the command

      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 becomes connected and is available to RHACM config

      Additional info:

      cleanup.sh
      #!/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}

       

        1. image (1).png
          image (1).png
          56 kB
        2. acmocp1.log
          4 kB
        3. acmbuild0.log
          62 kB
        4. ocp1_klusterlet-registration-agent-5d5c595dc4-7mh94.log
          4 kB

              zxue@redhat.com ZHAO XUE
              zcast Zechariah Castillo (Inactive)
              Zechariah Castillo (Inactive)
              Hui Chen Hui Chen
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Created:
                Updated:
                Resolved: