Skip to content

WIP: rake gitlab:artifacts:migrate tries to migrate migrated artifacts again

What does this MR do?

rake gitlab:artifacts:migrate has the following code

# lib/tasks/gitlab/artifacts.rake

task migrate: :environment do
  logger = Logger.new(STDOUT)
  logger.info('Starting transfer of artifacts')

  Ci::Build.joins(:project)
    .with_artifacts_stored_locally
    .find_each(batch_size: 10) do |build|
    begin
      build.artifacts_file.migrate!(ObjectStoreUploader::REMOTE_STORE)
      build.artifacts_metadata.migrate!(ObjectStoreUploader::REMOTE_STORE)

with_artifacts_stored_locally refers ci_builds.artifacts_file_store

# app/models/ci/build.rb

class Build < CommitStatus
  scope :with_artifacts_stored_locally, ->() { with_artifacts.where(artifacts_file_store: [nil, LegacyArtifactUploader::LOCAL_STORE]) }

However, if build.artifacts_file and build.artifacts_metadata are ci_job_artifacts, they don't update ci_builds.artifacts_file_store. Instead, they update ci_job_artifacts.file_store.

So I assume rake gitlab:artifacts:migrate tries to migrate migrated artifacts again and again, if it's ci_job_artifacts.

Are there points in the code the reviewer needs to double check?

Why was this MR needed?

Screenshots (if relevant)

Does this MR meet the acceptance criteria?

What are the relevant issue numbers?

/cc @ayufan @zj @grzesiek

Edited by Shinya Maeda

Merge request reports