Fix a duplicate DevWorkspace Operator after a cluster upgrade

Fix a duplicate DevWorkspace Operator installation that can occur when an OLM restart or cluster upgrade leaves multiple Operator entries in a Replacing or Pending loop.

Prerequisites
  • You have an active kubectl session as a cluster administrator to the destination OpenShift cluster. See Overview of kubectl.

  • You see multiple entries for the DevWorkspace Operator on the Installed Operators page of the Kubernetes or OpenShift web console, or you see one entry that is stuck in a loop of Replacing and Pending.

Procedure
  1. Delete the devworkspace-controller namespace that contains the failing pod.

  2. Update DevWorkspace and DevWorkspaceTemplate Custom Resource Definitions (CRD) by setting the conversion strategy to None and removing the entire webhook section:

    spec:
      ...
      conversion:
        strategy: None
    status:
    ...
    You can find and edit the DevWorkspace and DevWorkspaceTemplate CRDs in the Administrator perspective of the OpenShift web console by searching for DevWorkspace in Administration  CustomResourceDefinitions.
    The DevWorkspaceOperatorConfig and DevWorkspaceRouting CRDs have the conversion strategy set to None by default.
  3. Remove the DevWorkspace Operator subscription:

    $ oc delete sub devworkspace-operator \
    -n openshift-operators (1)
    1 openshift-operators or an OpenShift namespace where the DevWorkspace Operator is installed.
  4. Get the DevWorkspace Operator CSVs in the <devworkspace_operator.vX.Y.Z> format:

    $ oc get csv | grep devworkspace
  5. Remove each DevWorkspace Operator CSV:

    $ oc delete csv <devworkspace_operator.vX.Y.Z> \
    -n openshift-operators (1)
    1 openshift-operators or an OpenShift namespace where the DevWorkspace Operator is installed.
  6. Re-create the DevWorkspace Operator subscription:

    $ cat <<EOF | oc apply -f -
    apiVersion: operators.coreos.com/v1alpha1
    kind: Subscription
    metadata:
      name: devworkspace-operator
      namespace: openshift-operators
    spec:
      channel: fast
      name: devworkspace-operator
      source: redhat-operators
      sourceNamespace: openshift-marketplace
      installPlanApproval: Automatic (1)
      startingCSV: devworkspace-operator.v0.42.0
    EOF
    1 Automatic or Manual.
    For installPlanApproval: Manual, in the Administrator perspective of the OpenShift web console, go to Operators  Installed Operators and select the following for the DevWorkspace Operator: Upgrade available  Preview InstallPlan  Approve.
Verification
  • In the Administrator perspective of the OpenShift web console, go to Operators  Installed Operators and verify the Succeeded status of the DevWorkspace Operator.