Development fixture fails to seed NPM package
In https://gitlab.com/gitlab-org/gitlab-development-kit/-/jobs/502741189 we see the update step failing:
rake aborted!
ActiveRecord::RecordInvalid: Validation failed: Package already exists
/builds/gitlab-org/gitlab-development-kit/gitlab-development-kit/gitlab/ee/app/services/packages/npm/create_package_service.rb:17:in `create_package!'
/builds/gitlab-org/gitlab-development-kit/gitlab-development-kit/gitlab/ee/app/services/packages/npm/create_package_service.rb:11:in `block in execute'
/builds/gitlab-org/gitlab-development-kit/gitlab-development-kit/gitlab/ee/app/services/packages/npm/create_package_service.rb:11:in `execute'
(eval):24:in `block in seed_npm_packages'
(eval):14:in `times'
(eval):14:in `seed_npm_packages'
(eval):10:in `seed_packages'
(eval):156:in `block (5 levels) in run_file'
(eval):155:in `each'
(eval):155:in `block (4 levels) in run_file'
(eval):151:in `each'
(eval):151:in `block (3 levels) in run_file'
/builds/gitlab-org/gitlab-development-kit/gitlab-development-kit/gitlab/lib/gitlab/seeder.rb:89:in `quiet'
(eval):144:in `block (2 levels) in run_file'
/builds/gitlab-org/gitlab-development-kit/gitlab-development-kit/gitlab/lib/tasks/gitlab/setup.rake:34:in `setup_db'
/builds/gitlab-org/gitlab-development-kit/gitlab-development-kit/gitlab/lib/tasks/gitlab/setup.rake:5:in `block (2 levels) in <main>'
/builds/gitlab-org/gitlab-development-kit/gitlab-development-kit/gitlab/lib/tasks/dev.rake:7:in `block (2 levels) in <main>'
/home/gdk/.rbenv/versions/2.6.5/bin/bundle:23:in `load'
/home/gdk/.rbenv/versions/2.6.5/bin/bundle:23:in `<main>'
Tasks: TOP => db:seed_fu
Down below:
== Seed from ee/db/fixtures/development/26_packages.rb
Use the `SEED_ALL_PACKAGE_TYPES` environment variable to seed packages of all types.
Seeding packages for the 'gnuwget/wget2' project
.....
Seeding packages for the 'gitlab-org/gitlab-test' project
.....
Seeding packages for the 'reported_user_1/html5-boilerplate' project
.....
Seeding packages for the 'gitlab-org/gitlab-shell' project
support/bootstrap-rails failed
@10io I think this problem happens because package_already_taken?
(https://gitlab.com/gitlab-org/gitlab/blob/01112e5497e1180a83e805ad6be9a3d2df741690/ee/app/models/ee/project.rb#L669-673) fails because gitlab-org
already has these package names. Perhaps the way to solve this is to append the full project name to the package name itself in https://gitlab.com/gitlab-org/gitlab/blob/f6fd12af5db44b397cd5e2d631a48e34d57c8aac/ee/db/fixtures/development/26_packages.rb#L15.
Edited by Stan Hu