Skip to content

Remove previously deprecated job class instances

Hunter Stewart requested to merge hustewart-cleanup-jobs into master

What does this MR do and why?

Since Clusters::Applications has been deprecated, we are in the process of cleaning up lingering code around this part of the application. This post migration removes job class instances that may be lingering in in queues, in an effort to ensure that the eventual removal of the job classes themselves (this will take place in a future milestone) is safe to do.

The following job classes are affected:

  • ClusterConfigureIstioWorker
  • ClusterInstallAppWorker
  • ClusterPatchAppWorker
  • ClusterUpdateAppWorker
  • ClusterUpgradeAppWorker
  • ClusterWaitForAppInstallationWorker
  • ClusterWaitForAppUpdateWorker
  • ClusterWaitForIngressIpAddressWorker

For more context this MR is the umbrella issue for the lingering code removal.

And this MR tracks the completed investigation and no-oping of the aforementioned job classes.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

How to set up and validate locally

  1. Turn off sidekiq so that jobs don't process before you can validate (I use GDK so for me this is gdk stop rails-background-jobs)
  2. rails c
  3. In rails console, enqueue the relevant jobs
DEPRECATED_JOB_CLASSES = [
 ClusterConfigureIstioWorker,
 ClusterInstallAppWorker,
 ClusterPatchAppWorker,
 ClusterUpdateAppWorker,
 ClusterUpgradeAppWorker,
 ClusterWaitForAppInstallationWorker,
 ClusterWaitForAppUpdateWorker,
 ClusterWaitForIngressIpAddressWorker
]

DEPRECATED_JOB_CLASSES.each(&:perform_async)
  1. Verify your jobs are sitting in the queues (in GDK all jobs route to default so that's what we're checking here)
Sidekiq::Queue.new('default').map(&:klass)

# Should see something like this, mine has a few extra ClusterConfigureIstioWorker because i
# was testing multiples.
#
# => ["ClusterWaitForIngressIpAddressWorker",
#  "ClusterWaitForAppUpdateWorker",
#  "ClusterWaitForAppInstallationWorker",
#  "ClusterUpgradeAppWorker",
#  "ClusterUpdateAppWorker",
#  "ClusterPatchAppWorker",
#  "ClusterInstallAppWorker",
#  "ClusterConfigureIstioWorker",
#  "ClusterConfigureIstioWorker",
#  "ClusterConfigureIstioWorker"]
  1. exit rails console (if you forget to do this, the migration may not work as expected)

  2. execute the migration in terminal rake db:migrate VERSION=20221117135032

  3. After it runs, open rails console again rails c

  4. Check the default queue again

Sidekiq::Queue.new('default').map(&:klass)

# Should see an empty array like this
=> []

NOTE: If you need to rollback back the migration at all

rake db:migrate:down:main VERSION=20221117135032
rake db:migrate:down:ci VERSION=20221117135032

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Hunter Stewart

Merge request reports