Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

CORTX-30147: Simplify upgrade by using selector labels #298

Merged
merged 2 commits into from
Jun 24, 2022
Merged

CORTX-30147: Simplify upgrade by using selector labels #298

merged 2 commits into from
Jun 24, 2022

Conversation

keithpine
Copy link
Contributor

Description

After fixing PR #297, I felt that the script was fragile with all the grepping and case statements. Now that all of the CORTX workloads are labeled with common labels, we can use said labels to simplify the querying and setting of images of active workloads.

Also re-ordered some error checking to bail out earlier when possible.

Breaking change

The script now requires certain labels to be set:

  • app.kubernetes.io/name=<release name>
  • app.kubernetes.io/component=<component> where component is server, data, etc.

These labels are always applied when installing the Helm chart. So this won't work on previous deployments that are unlabeled. However, the script is already breaking for past releases due to the switch from Deployment to StatefulSet for Data, Server and Client workloads. So this is the best time to make such a change.

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds new functionality)
  • Breaking change (bug fix or new feature that breaks existing functionality)
  • Third-party dependency update
  • Documentation additions or improvements
  • Code quality improvements to existing code or test additions/updates

Applicable issues

  • This change fixes an issue: CORTX-30147

How was this tested?

Deployed clusters and ran upgrade. Used both standard and data-only deployment. Also ran when no cluster installed.

Additional information

When you use a selector to set the image, kubectl will just silently exit if no label matches. This means we can just loop over all of the components and set image-by-image without regard to their installation state or their workload type, and attempt to set the images. In order to avoid confusion, the output was modified slightly to accommodate this, e.g. it won't say it's updating an RGW image for a data-only deployment.

(It looks like there is no union operation for labels using kubectl, they only can reduce the previous set, which means I can't do something like using a single command to set cortx-data image for both client and data workloads. If that capability exists, let me know!)

Before:

Updating CORTX Deployments to use:
   ghcr.io/seagate/cortx-rgw:2.0.0-837
   ghcr.io/seagate/cortx-data:2.0.0-837
   ghcr.io/seagate/cortx-control:2.0.0-837

Updating CORTX component cortx-control to use image ghcr.io/seagate/cortx-control:2.0.0-837
deployment.apps/cortx-control image updated
Updating CORTX component cortx-ha to use image ghcr.io/seagate/cortx-control:2.0.0-837
deployment.apps/cortx-ha image updated
Updating CORTX component cortx-client to use image ghcr.io/seagate/cortx-data:2.0.0-837
statefulset.apps/cortx-client image updated
Updating CORTX component cortx-data to use image ghcr.io/seagate/cortx-data:2.0.0-837
statefulset.apps/cortx-data image updated
Updating CORTX component cortx-server to use image ghcr.io/seagate/cortx-rgw:2.0.0-837
statefulset.apps/cortx-server image updated

After:

Current container images:
  cortx-control ==> ghcr.io/seagate/cortx-control:2.0.0-835
  cortx-ha ==> ghcr.io/seagate/cortx-control:2.0.0-835
  cortx-client ==> ghcr.io/seagate/cortx-data:2.0.0-835
  cortx-data ==> ghcr.io/seagate/cortx-data:2.0.0-835
  cortx-server ==> ghcr.io/seagate/cortx-rgw:2.0.0-835

Updating CORTX resources to use:
   ghcr.io/seagate/cortx-rgw:2.0.0-837
   ghcr.io/seagate/cortx-data:2.0.0-837
   ghcr.io/seagate/cortx-control:2.0.0-837

Updating container images...
statefulset.apps/cortx-client image updated
deployment.apps/cortx-ha image updated
statefulset.apps/cortx-data image updated
statefulset.apps/cortx-server image updated
deployment.apps/cortx-control image updated

Updated container images:
  cortx-control ==> ghcr.io/seagate/cortx-control:2.0.0-837
  cortx-ha ==> ghcr.io/seagate/cortx-control:2.0.0-837
  cortx-client ==> ghcr.io/seagate/cortx-data:2.0.0-837
  cortx-data ==> ghcr.io/seagate/cortx-data:2.0.0-837
  cortx-server ==> ghcr.io/seagate/cortx-rgw:2.0.0-837

Data-only:

Current container images:
  cortx-client ==> ghcr.io/seagate/cortx-data:2.0.0-835
  cortx-data ==> ghcr.io/seagate/cortx-data:2.0.0-835

Updating CORTX resources to use:
   ghcr.io/seagate/cortx-rgw:2.0.0-837
   ghcr.io/seagate/cortx-data:2.0.0-837
   ghcr.io/seagate/cortx-control:2.0.0-837

Updating container images...
statefulset.apps/cortx-client image updated
statefulset.apps/cortx-data image updated

Updated container images:
  cortx-client ==> ghcr.io/seagate/cortx-data:2.0.0-837
  cortx-data ==> ghcr.io/seagate/cortx-data:2.0.0-837

No cluster installed:

Using solution config file 'solution.yaml'
No resources found in cortx namespace.
No CORTX Deployments were found so the image upgrade cannot be performed.

Checklist

  • The change is tested and works locally.
  • New or changed settings in the solution YAML are documented clearly in the README.md file.
  • All commits are signed off and are in agreement with the CORTX Community DCO and CLA policy.

If this change requires newer CORTX or third party image versions:

  • The image fields in solution.example.yaml have been updated to use the required versions.
  • The appVersion field of the Helm chart has been updated to use the new CORTX version.

If this change addresses a CORTX Jira issue:

  • The title of the PR starts with the issue ID (e.g. CORTX-XXXXX:)

@cla-bot cla-bot bot added the cla-signed label Jun 24, 2022
@keithpine keithpine marked this pull request as ready for review June 24, 2022 00:50
@keithpine keithpine requested a review from a team as a code owner June 24, 2022 00:50
Copy link
Contributor

@walterlopatka walterlopatka left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

@osowski osowski left a comment

Choose a reason for hiding this comment

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

lgtm

@keithpine keithpine merged commit 8b986c7 into Seagate:integration Jun 24, 2022
@keithpine keithpine deleted the CORTX-30147_upgrade-labels branch June 24, 2022 20:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants