Skip to content

Making refresh_jid more robust for github imports

What does this MR do and why?

Currently, some github imports get stuck when a stage takes a long time to complete.

This MR adds checkpoints that refresh the jid to the import progress. Giving more time to the imports

Screenshots or screen recordings

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

Before After

How to set up and validate locally

  1. Try triggering some bulkImport jobs locally in the console. And then kill sidekiq background worker
[28] pry(main)> Project.last.import_state.jid
=> "89b0f39f4027d106ccbc4bea"

-- Wait a minute if you want easier to compare numbers

[29] pry(main)> Sidekiq.redis { |redis|  redis.ttl("gitlab-sidekiq-status:89b0f39f4027d106ccbc4bea") }
=> 86224
[30] pry(main)> Gitlab::GithubImport::Stage::ImportLfsObjectsWorker.perform_async # This is to enqueue a random worker as an example
=> "c6054b4bd5354d97aa809479"

-- Wait a minute if you want easier to compare numbers

[31] pry(main)> Sidekiq.redis { |redis|  redis.ttl("gitlab-sidekiq-status:c6054b4bd5354d97aa809479") }
=> 86248

So here we have import state jid (89b0f39f4027d106ccbc4bea) with TTL: 86224
Abd we gave random worker'd jid (c6054b4bd5354d97aa809479) with TTL: 86248

[33] pry(main)> Gitlab::GithubImport::RefreshImportJidWorker.new.perform(268, "c6054b4bd5354d97aa809479")
=> "79f6fdb931606aa3715d1025" #useless do not need

-- Now triggering the TTL on the same JIDs will refresh the TTL

[34] pry(main)> Sidekiq.redis { |redis|  redis.ttl("gitlab-sidekiq-status:89b0f39f4027d106ccbc4bea") }
=> 86384
[35] pry(main)> Sidekiq.redis { |redis|  redis.ttl("gitlab-sidekiq-status:c6054b4bd5354d97aa809479") }
=> 86379
  1. After this change, these github import jobs that use StageMethods will have a ttl set in rails/sidekiq
  2. In addition, this TTL as well as the import state's TTL will be continuously refreshed throughout the process
  3. Previous to this change, these jobs will not have any redis status set

MR acceptance checklist

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

Related to #431936 (closed)

Edited by Max Fan

Merge request reports

Loading