From a3473b4cd5dfe84cc34fc9b50b9a1838e04bb377 Mon Sep 17 00:00:00 2001 From: Achilleas Pipinellis Date: Wed, 20 Mar 2019 14:01:54 +0000 Subject: Merge branch 'jramsay/dedupe-beta-docs' into 'master' Add beta caution to hashed object pools See merge request gitlab-org/gitlab-ce!26289 (cherry picked from commit d2c01153a882b1f3d5ad5dc3e1218741bfabceb5) c149921a Add beta caution to hashed object pools f7f8f4d0 Link to meta issue --- doc/administration/repository_storage_types.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/administration/repository_storage_types.md b/doc/administration/repository_storage_types.md index 40f7c5566ac..25c3d564560 100644 --- a/doc/administration/repository_storage_types.md +++ b/doc/administration/repository_storage_types.md @@ -86,6 +86,11 @@ by another folder with the next 2 characters. They are both stored in a special ### Hashed object pools +CAUTION: **Beta:** +Hashed objects pools are considered beta, and are not ready for production use. +Follow [gitaly#1548](https://gitlab.com/gitlab-org/gitaly/issues/1548) for +updates. + For deduplication of public forks and their parent repository, objects are pooled in an object pool. These object pools are a third repository where shared objects are stored. -- cgit v1.2.3 From 3c764b18b533e57c1d9f0afa62a7cbf8c2b12120 Mon Sep 17 00:00:00 2001 From: Douglas Barbosa Alexandre Date: Tue, 19 Mar 2019 21:09:49 +0000 Subject: Merge branch 'sh-create-branch-as-project-owner-for-github-import' into 'master' GitHub import: Create new branches as project owner See merge request gitlab-org/gitlab-ce!26335 (cherry picked from commit 6e74eb4eacdc9dbb4ce584fc8ae2e151a911e17b) 1e6ea914 GitHub import: Create new branches as project owner --- .../sh-create-branch-as-project-owner-for-github-import.yml | 5 +++++ lib/gitlab/github_import/importer/pull_request_importer.rb | 2 +- spec/lib/gitlab/github_import/importer/pull_request_importer_spec.rb | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/sh-create-branch-as-project-owner-for-github-import.yml diff --git a/changelogs/unreleased/sh-create-branch-as-project-owner-for-github-import.yml b/changelogs/unreleased/sh-create-branch-as-project-owner-for-github-import.yml new file mode 100644 index 00000000000..a3d484cbf05 --- /dev/null +++ b/changelogs/unreleased/sh-create-branch-as-project-owner-for-github-import.yml @@ -0,0 +1,5 @@ +--- +title: 'GitHub import: Create new branches as project owner' +merge_request: 26335 +author: +type: fixed diff --git a/lib/gitlab/github_import/importer/pull_request_importer.rb b/lib/gitlab/github_import/importer/pull_request_importer.rb index e294173f992..72451e5e01e 100644 --- a/lib/gitlab/github_import/importer/pull_request_importer.rb +++ b/lib/gitlab/github_import/importer/pull_request_importer.rb @@ -89,7 +89,7 @@ module Gitlab return if project.repository.branch_exists?(source_branch) - project.repository.add_branch(merge_request.author, source_branch, pull_request.source_branch_sha) + project.repository.add_branch(project.owner, source_branch, pull_request.source_branch_sha) rescue Gitlab::Git::CommandError => e Gitlab::Sentry.track_acceptable_exception(e, extra: { diff --git a/spec/lib/gitlab/github_import/importer/pull_request_importer_spec.rb b/spec/lib/gitlab/github_import/importer/pull_request_importer_spec.rb index 15e59718dce..37c3fae7cb7 100644 --- a/spec/lib/gitlab/github_import/importer/pull_request_importer_spec.rb +++ b/spec/lib/gitlab/github_import/importer/pull_request_importer_spec.rb @@ -273,6 +273,11 @@ describe Gitlab::GithubImport::Importer::PullRequestImporter, :clean_gitlab_redi mr.state = 'opened' mr.save + # Ensure the project owner is creating the branches because the + # merge request author may not have access to push to this + # repository. + allow(project.repository).to receive(:add_branch).with(project.owner, anything, anything).and_call_original + importer.insert_git_data(mr, exists) expect(project.repository.branch_exists?(mr.source_branch)).to be_truthy -- cgit v1.2.3 From d610b4f572f2c79198439d7c8cbb70b6b602acf7 Mon Sep 17 00:00:00 2001 From: Clement Ho Date: Wed, 20 Mar 2019 15:47:55 +0000 Subject: Merge branch 'winh-replty-to-comment-tooltip' into 'master' Move reply to comment tooltip to the top Closes #59198 See merge request gitlab-org/gitlab-ce!26366 (cherry picked from commit 75e24b8f506444bfdac57fd0d8d691e49fb77dc1) 6f4c0178 Move reply to comment tooltip to the top --- app/assets/javascripts/notes/components/note_actions/reply_button.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/notes/components/note_actions/reply_button.vue b/app/assets/javascripts/notes/components/note_actions/reply_button.vue index f50cab81efe..be8e42af9ea 100644 --- a/app/assets/javascripts/notes/components/note_actions/reply_button.vue +++ b/app/assets/javascripts/notes/components/note_actions/reply_button.vue @@ -18,7 +18,7 @@ export default {
Date: Wed, 20 Mar 2019 18:01:04 +0000 Subject: Merge branch '59208-fix-error-500-on-every-page-when-active-broadcast-message-present-after-upgrading-to-11-9-0' into 'master' Gracefully handles excluded fields from attributes during serialization on JsonCache Closes #59208 See merge request gitlab-org/gitlab-ce!26368 (cherry picked from commit cc5095edfce2b4d4083a4fb1cdc7c0a1898b9921) 7028b376 Gracefully handles excluded fields from attributes during serialization 1c7a2c05 Add CHANGELOG entry --- ...t-message-present-after-upgrading-to-11-9-0.yml | 6 ++++ lib/gitlab/json_cache.rb | 19 +++++++++-- spec/lib/gitlab/json_cache_spec.rb | 38 +++++++++++++++++++++- 3 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 changelogs/unreleased/59208-fix-error-500-on-every-page-when-active-broadcast-message-present-after-upgrading-to-11-9-0.yml diff --git a/changelogs/unreleased/59208-fix-error-500-on-every-page-when-active-broadcast-message-present-after-upgrading-to-11-9-0.yml b/changelogs/unreleased/59208-fix-error-500-on-every-page-when-active-broadcast-message-present-after-upgrading-to-11-9-0.yml new file mode 100644 index 00000000000..3c9feae5a04 --- /dev/null +++ b/changelogs/unreleased/59208-fix-error-500-on-every-page-when-active-broadcast-message-present-after-upgrading-to-11-9-0.yml @@ -0,0 +1,6 @@ +--- +title: Gracefully handles excluded fields from attributes during serialization on + JsonCache +merge_request: 26368 +author: +type: fixed diff --git a/lib/gitlab/json_cache.rb b/lib/gitlab/json_cache.rb index 24daad638f4..e4bc437d787 100644 --- a/lib/gitlab/json_cache.rb +++ b/lib/gitlab/json_cache.rb @@ -80,8 +80,23 @@ module Gitlab # when the new_record? method incorrectly returns false. # # See https://gitlab.com/gitlab-org/gitlab-ee/issues/9903#note_145329964 - attributes = klass.attributes_builder.build_from_database(raw, {}) - klass.allocate.init_with("attributes" => attributes, "new_record" => new_record?(raw, klass)) + klass + .allocate + .init_with( + "attributes" => attributes_for(klass, raw), + "new_record" => new_record?(raw, klass) + ) + end + + def attributes_for(klass, raw) + # We have models that leave out some fields from the JSON export for + # security reasons, e.g. models that include the CacheMarkdownField. + # The ActiveRecord::AttributeSet we build from raw does know about + # these columns so we need manually set them. + missing_attributes = (klass.columns.map(&:name) - raw.keys) + missing_attributes.each { |column| raw[column] = nil } + + klass.attributes_builder.build_from_database(raw, {}) end def new_record?(raw, klass) diff --git a/spec/lib/gitlab/json_cache_spec.rb b/spec/lib/gitlab/json_cache_spec.rb index 2cae8ec031a..b7dc8234bdf 100644 --- a/spec/lib/gitlab/json_cache_spec.rb +++ b/spec/lib/gitlab/json_cache_spec.rb @@ -7,7 +7,7 @@ describe Gitlab::JsonCache do let(:namespace) { 'geo' } let(:key) { 'foo' } let(:expanded_key) { "#{namespace}:#{key}:#{Rails.version}" } - let(:broadcast_message) { create(:broadcast_message) } + set(:broadcast_message) { create(:broadcast_message) } subject(:cache) { described_class.new(namespace: namespace, backend: backend) } @@ -321,6 +321,42 @@ describe Gitlab::JsonCache do expect(result).to be_new_record end + + it 'gracefully handles bad cached entry' do + allow(backend).to receive(:read) + .with(expanded_key) + .and_return('{') + + expect(cache.read(key, BroadcastMessage)).to be_nil + end + + it 'gracefully handles an empty hash' do + allow(backend).to receive(:read) + .with(expanded_key) + .and_return('{}') + + expect(cache.read(key, BroadcastMessage)).to be_a(BroadcastMessage) + end + + it 'gracefully handles unknown attributes' do + allow(backend).to receive(:read) + .with(expanded_key) + .and_return(broadcast_message.attributes.merge(unknown_attribute: 1).to_json) + + expect(cache.read(key, BroadcastMessage)).to be_nil + end + + it 'gracefully handles excluded fields from attributes during serialization' do + backend.write(expanded_key, broadcast_message.to_json) + + result = cache.fetch(key, as: BroadcastMessage) { 'block result' } + + excluded_fields = BroadcastMessage.cached_markdown_fields.html_fields + + (excluded_fields + ['cached_markdown_version']).each do |field| + expect(result.public_send(field)).to be_nil + end + end end it "returns the result of the block when 'as' option is nil" do -- cgit v1.2.3