Skip to content

When using a custom group-level project template that contains a wiki, creating a project results in an email error and Wiki, issues, merge requests, and other objects are missing

Summary

When using a custom group-level project template that contains a wiki, creating a project results in an email error and Wiki, issues, merge requests and other objects are missing.

Reported on ZD 327317 (internal)

Steps to reproduce

  1. Create a subgroup in an existing group.
  2. Add a project to the new subgroup to use as the template.
  3. Add a Wiki to that project
  4. Browse to the top level group, select Settings > General.
  5. Expand Custom project templates and select the subgroup.
  6. Create a new project and choose Create from template
  7. Select the template project from the Group tab

Example Project

  1. Go to https://gitlab.com/gitlab-gold/templatetoplevel
  2. Create a new project and choose Create from template
  3. Select the Group tab, expand GitLab.com - Gold / TemplateTopLevel / TemplateGroupTest
  4. Select WikiTest project

What is the current bug behavior?

The new project is created with the repository, but there are no wiki, issues, merge requests and other objects in the new project.

There are no errors reported in UI.

A few mins later user who created the project receives an email with the error:

Project <TEMPLATE_PROJECT> couldn't be exported.
The errors we encountered were:
Error importing repository into [FILTERED] - 6:creating repository: repository exists already. debug_error_string:{"created":"@1663856917.749210777","description":"Error received from peer [FILTERED] repository: repository exists already","grpc_status":6}

What is the expected correct behavior?

A new project should be created and all the objects existing in the project template should be present in the new project.

Relevant logs and/or screenshots

from /var/log/gitlab/gitlab-rails/exceptions_json.log:

{
  "severity": "ERROR",
  "time": "2022-10-12T09:43:13.003Z",
  "correlation_id": "01GF5S70NASHX8B0Y9HCKJET9Y",
  "exception.class": "RuntimeError",
  "exception.message": "Error importing repository  into root/test_from_template2022 - 6:creating repository: repository exists already. debug_error_string:{\"created\":\"@1665567791.803305225\",\"description\":\"Error received from peer [FILTERED] repository: repository exists already\",\"grpc_status\":6}",
  "exception.backtrace": [
    "app/workers/repository_import_worker.rb:37:in `perform'",
    "ee/app/workers/ee/repository_import_worker.rb:9:in `perform'",
    "ee/lib/ee/gitlab/import_export/after_export_strategies/custom_template_export_import_strategy.rb:30:in `strategy_execute'",
    "lib/gitlab/import_export/after_export_strategies/base_after_export_strategy.rb:43:in `execute'",
    "app/services/projects/import_export/export_service.rb:51:in `execute_after_export_action'",
    "app/services/projects/import_export/export_service.rb:21:in `execute'",
    "app/services/concerns/measurable.rb:35:in `execute'",
    "app/workers/project_export_worker.rb:25:in `perform'",
...

The error comes from gitaly:

{
  "correlation_id": "01GF5S70NASHX8B0Y9HCKJET9Y",
  "error": "creating repository: repository exists already",
  "grpc.code": "AlreadyExists",
  "grpc.meta.auth_version": "v2",
  "grpc.meta.client_name": "gitlab-sidekiq",
  "grpc.meta.deadline_type": "unknown",
  "grpc.meta.method_type": "client_stream",
  "grpc.method": "CreateRepositoryFromBundle",
  "grpc.request.deadline": "2022-10-12T15:43:11.799",
  "grpc.request.fullMethod": "/gitaly.RepositoryService/CreateRepositoryFromBundle",
  "grpc.request.glProjectPath": "root/test_from_template2022.wiki",
  "grpc.request.glRepository": "wiki-160",
  "grpc.request.payload_bytes": 480,
  "grpc.request.repoPath": "@hashed/a5/12/a512db2741cd20693e4b16f19891e72b9ff12cead72761fc5e92d2aaf34740c1.wiki.git",
  "grpc.request.repoStorage": "default",
  "grpc.response.payload_bytes": 0,
  "grpc.service": "gitaly.RepositoryService",
  "grpc.start_time": "2022-10-12T09:43:11.799",
  "grpc.time_ms": 3.703,
  "level": "info",
  "msg": "finished streaming call with code AlreadyExists",
  "peer.address": "@",
  "pid": 887,
  "remote_ip": "80.113.68.61",
  "span.kind": "server",
  "system": "grpc",
  "time": "2022-10-12T09:43:11.803Z",
  "username": "root"
}

Output of checks

This bug happens on GitLab.com. Also reproduced on self-managed instances of GitLab starting from 15.1.0. Not reproduced on GitLab 15.0.0.

Results of GitLab environment info

Expand for output related to GitLab environment info

(For installations with omnibus-gitlab package run and paste the output of:
`sudo gitlab-rake gitlab:env:info`)

(For installations from source run and paste the output of:
`sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)

Results of GitLab application Check

Expand for output related to the GitLab application check

(For installations with omnibus-gitlab package run and paste the output of: sudo gitlab-rake gitlab:check SANITIZE=true)

(For installations from source run and paste the output of: sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true)

(we will only investigate if the tests are passing)

Possible fixes

Edited by Alexandr Tanayno