Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(deploy): recreate deployment if selector changed #472

Merged
merged 1 commit into from
Oct 13, 2022

Conversation

ebaron
Copy link
Member

@ebaron ebaron commented Oct 12, 2022

This PR modifies the Deployment update code to detect when the immutable selector has changed. When this is detected, the operator deletes the deployment and recreates it. With this change it should be possible to upgrade from 2.0 to 2.2, the deployment selectors were changed in 2.1. I built a catalog image to help test this upgrade scenario: quay.io/ebaron/cryostat-operator-catalog:selector-fix-01.

To test:

  1. Create the following objects:
apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
    name: cryostat-catalog
    namespace: openshift-marketplace
spec:
    sourceType: grpc
    image: quay.io/ebaron/cryostat-operator-catalog:selector-fix-01
    displayName: Cryostat Catalog
    publisher: Cryostat Authors
    updateStrategy:
        registryPoll:
            interval: 10m
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
    name: cryostat-operator-group
    namespace: cryostat-operator-system
spec:
    targetNamespaces:
    - cryostat-operator-system
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
    name: sub-to-cryostat-operator
    namespace: cryostat-operator-system
spec:
    channel: alpha
    name: cryostat-operator
    source: cryostat-catalog
    sourceNamespace: openshift-marketplace
    installPlanApproval: Manual
    startingCSV: cryostat-operator.v2.0.1-dev
    config:
        env:
        - name: RELATED_IMAGE_CORE
          value: quay.io/ebaron/cryostat:before-db
  1. Approve the install plan for cryostat-operator.v2.0.1-dev.
  2. Create a Cryostat instance.
  3. Approve the install plan to upgrade to cryostat-operator.v2.2.0-dev.
  4. The Cryostat deployment selector should have the component label:
kubectl get -ojsonpath='{.spec.selector}' deploy cryostat-sample | jq
{
  "matchLabels": {
    "app": "cryostat-sample",
    "component": "cryostat",
    "kind": "cryostat"
  }
}
  1. The upgraded Cryostat application should function as normal.

Fixes: #433, #388

Copy link
Member

@andrewazores andrewazores left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense and worked well in crc. Only hiccup was that the 2.0.1 installation had a broken Cryostat instance because the AUTH_MANAGER env var had the wrong fully-qualified classname (package has moved between versions), but I don't think that's relevant for this PR.

Copy link
Member

@tthvo tthvo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I tested on Cluster Bot with OCP 4.11.1 and worked as expected. Also noticed the crashing for 2.0.1, but select is updated expected :D

@ebaron ebaron merged commit 8545a26 into cryostatio:main Oct 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: Done
3 participants