Skip to content

Rename files if necessary after remote to local artifact migration

What does this MR do and why?

We have a problem in our artifact migration process.

Whenever we migrate from remote to local storage, Ci::JobArtifact's are copied over with a wrong filename.

The files physically exist after remote to local storage migration, but their name equals the last path part of the value of file_final_path.

To give you an example, please look at file_final_path below:

image.png

The expected path would be gitlab-development-kit/gitlab/shared/artifacts/5f/9c/5f9c4ab08cac7457e9111a30e4664920607ea2c115a1433d7be98e97e64244ca/2025_10_15/922/485/artifacts.zip,

but it is

gitlab-development-kit/gitlab/shared/artifacts/5f/9c/5f9c4ab08cac7457e9111a30e4664920607ea2c115a1433d7be98e97e64244ca/2025_10_15/922/485/4f8681af93715b90c913e507f24b05cc6ca6e583d4f91103e97bf6d92bbb

instead.

This MR fixes the migration process from remote to local storage by changing the name of the artifacts to the expected name, in this case e.g. artifacts.zip.

Furthermore, it adds a task that attempts to rename, if possible, already broken artifact paths.

We might need a follow up on this to find out why the filename equals a random hash instead of just being artifacts.zip.

How to set up and validate locally

  1. On master, create a few artifacts on your gdk instance (you need to have remote storage configured, e.g. MinIO)
  2. Run bundle exec rails gitlab:artifacts:migrate_to_local
  3. Try to download artifacts.zip -> exception.
  4. Do the same now on the branch of this MR. -> New artifacts should be downloadable
  5. As a bonus, to repair your local files, run bundle exec rails gitlab:artifacts:fix_artifact_filepath which will repair the broken artifacts from running the migration task on your local master branch.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #574865

Edited by Daniel Prause

Merge request reports

Loading