diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-06 15:08:05 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-06 15:08:05 +0000 |
commit | f78257cbddd711e18cbce93ad740a4aa0acac347 (patch) | |
tree | 7f018abe3ce1c0010879cc480f348a35e616fabb /app | |
parent | f500600a43b531e2e7a5858b74bd35312b02c349 (diff) | |
download | gitlab-ce-f78257cbddd711e18cbce93ad740a4aa0acac347.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/diffs/components/app.vue | 2 | ||||
-rw-r--r-- | app/models/ci/bridge.rb | 4 | ||||
-rw-r--r-- | app/models/ci/pipeline.rb | 4 | ||||
-rw-r--r-- | app/models/snippet.rb | 2 | ||||
-rw-r--r-- | app/services/projects/update_repository_storage_service.rb | 47 | ||||
-rw-r--r-- | app/workers/post_receive.rb | 5 |
6 files changed, 48 insertions, 16 deletions
diff --git a/app/assets/javascripts/diffs/components/app.vue b/app/assets/javascripts/diffs/components/app.vue index f9d3d31e152..77cd2afc106 100644 --- a/app/assets/javascripts/diffs/components/app.vue +++ b/app/assets/javascripts/diffs/components/app.vue @@ -398,7 +398,7 @@ export default { }" > <commit-widget v-if="commit" :commit="commit" /> - <div v-if="isBatchLoading" class="loading"><gl-loading-icon /></div> + <div v-if="isBatchLoading" class="loading"><gl-loading-icon size="lg" /></div> <template v-else-if="renderDiffFiles"> <diff-file v-for="file in diffFiles" diff --git a/app/models/ci/bridge.rb b/app/models/ci/bridge.rb index a28e44d44c1..d62aa09e432 100644 --- a/app/models/ci/bridge.rb +++ b/app/models/ci/bridge.rb @@ -89,6 +89,10 @@ module Ci end end + def parent_pipeline + pipeline if triggers_child_pipeline? + end + def triggers_child_pipeline? yaml_for_downstream.present? end diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index ff257c6cd68..bc0528bdbe0 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -787,6 +787,10 @@ module Ci .fabricate! end + def find_job_with_archive_artifacts(name) + builds.latest.with_artifacts_archive.find_by_name(name) + end + def latest_builds_with_artifacts # We purposely cast the builds to an Array here. Because we always use the # rows if there are more than 0 this prevents us from having to run two diff --git a/app/models/snippet.rb b/app/models/snippet.rb index 770d9b5205c..27e1778e9b6 100644 --- a/app/models/snippet.rb +++ b/app/models/snippet.rb @@ -197,6 +197,8 @@ class Snippet < ApplicationRecord end def blobs + return [] unless repository_exists? + repository.ls_files(repository.root_ref).map { |file| Blob.lazy(self, repository.root_ref, file) } end diff --git a/app/services/projects/update_repository_storage_service.rb b/app/services/projects/update_repository_storage_service.rb index 30b99e85304..1565b534b19 100644 --- a/app/services/projects/update_repository_storage_service.rb +++ b/app/services/projects/update_repository_storage_service.rb @@ -4,6 +4,7 @@ module Projects class UpdateRepositoryStorageService < BaseService include Gitlab::ShellAdapter + Error = Class.new(StandardError) RepositoryAlreadyMoved = Class.new(StandardError) def initialize(project) @@ -17,37 +18,45 @@ module Projects # exception. raise RepositoryAlreadyMoved if project.repository_storage == new_repository_storage_key - if mirror_repositories(new_repository_storage_key) - mark_old_paths_for_archive + mirror_repositories(new_repository_storage_key) - project.update(repository_storage: new_repository_storage_key, repository_read_only: false) - project.leave_pool_repository - project.track_project_repository + mark_old_paths_for_archive - enqueue_housekeeping - else - project.update(repository_read_only: false) - end + project.update(repository_storage: new_repository_storage_key, repository_read_only: false) + project.leave_pool_repository + project.track_project_repository + + enqueue_housekeeping + + success + + rescue Error => e + project.update(repository_read_only: false) + + Gitlab::ErrorTracking.track_exception(e, project_path: project.full_path) + + error(s_("UpdateRepositoryStorage|Error moving repository storage for %{project_full_path} - %{message}") % { project_full_path: project.full_path, message: e.message }) end private def mirror_repositories(new_repository_storage_key) - result = mirror_repository(new_repository_storage_key) + mirror_repository(new_repository_storage_key) if project.wiki.repository_exists? - result &&= mirror_repository(new_repository_storage_key, type: Gitlab::GlRepository::WIKI) + mirror_repository(new_repository_storage_key, type: Gitlab::GlRepository::WIKI) end - - result end def mirror_repository(new_storage_key, type: Gitlab::GlRepository::PROJECT) - return false unless wait_for_pushes(type) + unless wait_for_pushes(type) + raise Error, s_('UpdateRepositoryStorage|Timeout waiting for %{type} repository pushes') % { type: type.name } + end repository = type.repository_for(project) full_path = repository.full_path raw_repository = repository.raw + checksum = repository.checksum # Initialize a git repository on the target path gitlab_shell.create_repository(new_storage_key, raw_repository.relative_path, full_path) @@ -56,7 +65,15 @@ module Projects raw_repository.gl_repository, full_path) - new_repository.fetch_repository_as_mirror(raw_repository) + unless new_repository.fetch_repository_as_mirror(raw_repository) + raise Error, s_('UpdateRepositoryStorage|Failed to fetch %{type} repository as mirror') % { type: type.name } + end + + new_checksum = new_repository.checksum + + if checksum != new_checksum + raise Error, s_('UpdateRepositoryStorage|Failed to verify %{type} repository checksum from %{old} to %{new}') % { type: type.name, old: checksum, new: new_checksum } + end end def mark_old_paths_for_archive diff --git a/app/workers/post_receive.rb b/app/workers/post_receive.rb index 5178fabb2d8..05b6d6d570c 100644 --- a/app/workers/post_receive.rb +++ b/app/workers/post_receive.rb @@ -77,6 +77,11 @@ class PostReceive # rubocop:disable Scalability/IdempotentWorker return false unless user + # We can remove once we implement multi-file snippets + # https://gitlab.com/gitlab-org/gitlab/-/issues/39269 + blob = snippet.blobs.first + snippet.update(file_name: blob.path, content: blob.data) if blob + # At the moment, we only expires the repository caches. # In the future we might need to call ProjectCacheWorker # (or the custom class we create) to update the snippet |