summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-01 00:08:41 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-01 00:08:41 +0000
commit72817fd7c07d1b812623f8d5e27fc7bcecb4eed5 (patch)
tree2e81b28a062212375bf17d1da0ff836d6b021469
parent9db503ef9888c984b287af44d009d884e835ce04 (diff)
downloadgitlab-ce-72817fd7c07d1b812623f8d5e27fc7bcecb4eed5.tar.gz
Add latest changes from gitlab-org/gitlab@master
-rw-r--r--.gitlab/issue_templates/Feature proposal.md6
-rw-r--r--CHANGELOG-EE.md7
-rw-r--r--CHANGELOG.md8
-rw-r--r--app/models/pages_domain.rb8
-rw-r--r--app/models/release.rb9
-rw-r--r--changelogs/unreleased/198938-fix-invalid-issue-tracker-data.yml5
-rw-r--r--changelogs/unreleased/38103-collect-release-evidence-at-moment-of-release-end-date.yml5
-rw-r--r--changelogs/unreleased/ali-add-type-to-pages-domains.yml5
-rw-r--r--changelogs/unreleased/fix-missing-apply-sugegstion-project-setting.yml5
-rw-r--r--changelogs/unreleased/id-fix-suggestions.yml5
-rw-r--r--changelogs/unreleased/sh-fix-trigger-check-rds.yml5
-rw-r--r--db/migrate/20200128184209_add_usage_to_pages_domains.rb18
-rw-r--r--db/migrate/20200129034515_update_indexes_of_pages_domains_add_usage_domain_wildcard_remove_domain.rb21
-rw-r--r--db/migrate/20200129035446_rename_pages_domains_domain_type_to_scope.rb17
-rw-r--r--db/post_migrate/20200129035708_cleanup_rename_pages_domains_domain_type_to_scope.rb17
-rw-r--r--db/schema.rb10
-rw-r--r--lib/api/releases.rb11
-rw-r--r--spec/factories/pages_domains.rb3
-rw-r--r--spec/models/pages_domain_spec.rb14
-rw-r--r--spec/models/release_spec.rb6
-rw-r--r--spec/requests/api/releases_spec.rb104
21 files changed, 242 insertions, 47 deletions
diff --git a/.gitlab/issue_templates/Feature proposal.md b/.gitlab/issue_templates/Feature proposal.md
index dea2384a2e9..fa989e45281 100644
--- a/.gitlab/issue_templates/Feature proposal.md
+++ b/.gitlab/issue_templates/Feature proposal.md
@@ -38,7 +38,9 @@ If this feature requires changing permissions, this document https://docs.gitlab
### Availability & Testing
-<!-- What risks does this change pose to our availability? How might it affect the quality of the product? What additional test coverage or changes to tests will be needed? Will it require cross-browser testing?
+<!-- This section needs to be retained and filled in during the workflow planning breakdown phase of this feature proposal, if not earlier.
+
+ What risks does this change pose to our availability? How might it affect the quality of the product? What additional test coverage or changes to tests will be needed? Will it require cross-browser testing?
Please list the test areas (unit, integration and end-to-end) that needs to be added or updated to ensure that this feature will work as intended. Please use the list below as guidance.
* Unit test changes
@@ -51,7 +53,7 @@ See the test engineering planning process and reach out to your counterpart Soft
<!-- Define both the success metrics and acceptance criteria. Note that success metrics indicate the desired business outcomes, while acceptance criteria indicate when the solution is working correctly. If there is no way to measure success, link to an issue that will implement a way to measure this. -->
-### What is the type of buyer?
+### What is the type of buyer?
<!-- Which leads to: in which enterprise tier should this feature go? See https://about.gitlab.com/handbook/product/pricing/#four-tiers -->
diff --git a/CHANGELOG-EE.md b/CHANGELOG-EE.md
index ab7d706fc7b..3e09b0ef702 100644
--- a/CHANGELOG-EE.md
+++ b/CHANGELOG-EE.md
@@ -1,5 +1,12 @@
Please view this file on the master branch, on stable branches it's out of date.
+## 12.7.5
+
+### Fixed (1 change)
+
+- Fix DB connection pool size for Geo database. !24021
+
+
## 12.7.3
- No changes.
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3ce912798ee..eb5031d79cd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,7 +4,13 @@ entry.
## 12.7.5
-- No changes.
+### Fixed (4 changes, 1 of them is from the community)
+
+- Add accidentally deleted project config for custom apply suggestions. !23687 (Fabio Huser)
+- Fix database permission check for triggers on Amazon RDS. !24035
+- Fix applying the suggestions with an empty custom message. !24144
+- Remove invalid data from issue_tracker_data table.
+
## 12.7.3
diff --git a/app/models/pages_domain.rb b/app/models/pages_domain.rb
index dd2cafd9a35..330764ebc7f 100644
--- a/app/models/pages_domain.rb
+++ b/app/models/pages_domain.rb
@@ -6,7 +6,8 @@ class PagesDomain < ApplicationRecord
SSL_RENEWAL_THRESHOLD = 30.days.freeze
enum certificate_source: { user_provided: 0, gitlab_provided: 1 }, _prefix: :certificate
- enum domain_type: { instance: 0, group: 1, project: 2 }, _prefix: :domain_type
+ enum scope: { instance: 0, group: 1, project: 2 }, _prefix: :scope
+ enum usage: { pages: 0, serverless: 1 }, _prefix: :usage
belongs_to :project
has_many :acme_orders, class_name: "PagesDomainAcmeOrder"
@@ -26,8 +27,9 @@ class PagesDomain < ApplicationRecord
validate :validate_intermediates, if: ->(domain) { domain.certificate.present? && domain.certificate_changed? }
default_value_for(:auto_ssl_enabled, allow_nil: false) { ::Gitlab::LetsEncrypt.enabled? }
- default_value_for :domain_type, allow_nil: false, value: :project
+ default_value_for :scope, allow_nil: false, value: :project
default_value_for :wildcard, allow_nil: false, value: false
+ default_value_for :usage, allow_nil: false, value: :pages
attr_encrypted :key,
mode: :per_attribute_iv_and_salt,
@@ -220,7 +222,7 @@ class PagesDomain < ApplicationRecord
# rubocop: disable CodeReuse/ServiceClass
def update_daemon
- return if domain_type_instance?
+ return if usage_serverless?
::Projects::UpdatePagesConfigurationService.new(project).execute
end
diff --git a/app/models/release.rb b/app/models/release.rb
index ecfae554fe0..2543717895f 100644
--- a/app/models/release.rb
+++ b/app/models/release.rb
@@ -34,7 +34,6 @@ class Release < ApplicationRecord
delegate :repository, to: :project
- after_commit :create_evidence!, on: :create, unless: :importing?
after_commit :notify_new_release, on: :create, unless: :importing?
MAX_NUMBER_TO_DISPLAY = 3
@@ -70,6 +69,10 @@ class Release < ApplicationRecord
released_at.present? && released_at > Time.zone.now
end
+ def historical_release?
+ released_at.present? && released_at < created_at
+ end
+
def name
self.read_attribute(:name) || tag
end
@@ -98,10 +101,6 @@ class Release < ApplicationRecord
end
end
- def create_evidence!
- CreateEvidenceWorker.perform_async(self.id)
- end
-
def notify_new_release
NewReleaseWorker.perform_async(id)
end
diff --git a/changelogs/unreleased/198938-fix-invalid-issue-tracker-data.yml b/changelogs/unreleased/198938-fix-invalid-issue-tracker-data.yml
deleted file mode 100644
index 36bf6e3aa26..00000000000
--- a/changelogs/unreleased/198938-fix-invalid-issue-tracker-data.yml
+++ /dev/null
@@ -1,5 +0,0 @@
----
-title: Remove invalid data from issue_tracker_data table
-merge_request:
-author:
-type: fixed
diff --git a/changelogs/unreleased/38103-collect-release-evidence-at-moment-of-release-end-date.yml b/changelogs/unreleased/38103-collect-release-evidence-at-moment-of-release-end-date.yml
new file mode 100644
index 00000000000..97a5807ab17
--- /dev/null
+++ b/changelogs/unreleased/38103-collect-release-evidence-at-moment-of-release-end-date.yml
@@ -0,0 +1,5 @@
+---
+title: Collect release evidence at release timestamp
+merge_request: 23697
+author:
+type: added
diff --git a/changelogs/unreleased/ali-add-type-to-pages-domains.yml b/changelogs/unreleased/ali-add-type-to-pages-domains.yml
new file mode 100644
index 00000000000..60c60f7179d
--- /dev/null
+++ b/changelogs/unreleased/ali-add-type-to-pages-domains.yml
@@ -0,0 +1,5 @@
+---
+title: Update PagesDomains data model for serverless domains
+merge_request: 23943
+author:
+type: changed
diff --git a/changelogs/unreleased/fix-missing-apply-sugegstion-project-setting.yml b/changelogs/unreleased/fix-missing-apply-sugegstion-project-setting.yml
deleted file mode 100644
index d084148fbd8..00000000000
--- a/changelogs/unreleased/fix-missing-apply-sugegstion-project-setting.yml
+++ /dev/null
@@ -1,5 +0,0 @@
----
-title: Add accidentally deleted project config for custom apply suggestions
-merge_request: 23687
-author: Fabio Huser
-type: fixed
diff --git a/changelogs/unreleased/id-fix-suggestions.yml b/changelogs/unreleased/id-fix-suggestions.yml
deleted file mode 100644
index 3987a590e14..00000000000
--- a/changelogs/unreleased/id-fix-suggestions.yml
+++ /dev/null
@@ -1,5 +0,0 @@
----
-title: Fix applying the suggestions with an empty custom message
-merge_request: 24144
-author:
-type: fixed
diff --git a/changelogs/unreleased/sh-fix-trigger-check-rds.yml b/changelogs/unreleased/sh-fix-trigger-check-rds.yml
deleted file mode 100644
index 99ae6039aaa..00000000000
--- a/changelogs/unreleased/sh-fix-trigger-check-rds.yml
+++ /dev/null
@@ -1,5 +0,0 @@
----
-title: Fix database permission check for triggers on Amazon RDS
-merge_request: 24035
-author:
-type: fixed
diff --git a/db/migrate/20200128184209_add_usage_to_pages_domains.rb b/db/migrate/20200128184209_add_usage_to_pages_domains.rb
new file mode 100644
index 00000000000..292490078cd
--- /dev/null
+++ b/db/migrate/20200128184209_add_usage_to_pages_domains.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddUsageToPagesDomains < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ PAGES_USAGE = 0
+
+ disable_ddl_transaction!
+
+ def up
+ add_column_with_default :pages_domains, :usage, :integer, limit: 2, default: PAGES_USAGE, allow_null: false # rubocop:disable Migration/AddColumnWithDefault
+ end
+
+ def down
+ remove_column :pages_domains, :usage
+ end
+end
diff --git a/db/migrate/20200129034515_update_indexes_of_pages_domains_add_usage_domain_wildcard_remove_domain.rb b/db/migrate/20200129034515_update_indexes_of_pages_domains_add_usage_domain_wildcard_remove_domain.rb
new file mode 100644
index 00000000000..2f13567c540
--- /dev/null
+++ b/db/migrate/20200129034515_update_indexes_of_pages_domains_add_usage_domain_wildcard_remove_domain.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class UpdateIndexesOfPagesDomainsAddUsageDomainWildcardRemoveDomain < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :pages_domains, :usage
+ add_concurrent_index :pages_domains, [:domain, :wildcard], unique: true
+ remove_concurrent_index :pages_domains, :domain
+ end
+
+ def down
+ remove_concurrent_index :pages_domains, :usage
+ remove_concurrent_index :pages_domains, [:domain, :wildcard]
+ add_concurrent_index :pages_domains, :domain, unique: true
+ end
+end
diff --git a/db/migrate/20200129035446_rename_pages_domains_domain_type_to_scope.rb b/db/migrate/20200129035446_rename_pages_domains_domain_type_to_scope.rb
new file mode 100644
index 00000000000..74d9827e370
--- /dev/null
+++ b/db/migrate/20200129035446_rename_pages_domains_domain_type_to_scope.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class RenamePagesDomainsDomainTypeToScope < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ rename_column_concurrently :pages_domains, :domain_type, :scope
+ end
+
+ def down
+ undo_rename_column_concurrently :pages_domains, :domain_type, :scope
+ end
+end
diff --git a/db/post_migrate/20200129035708_cleanup_rename_pages_domains_domain_type_to_scope.rb b/db/post_migrate/20200129035708_cleanup_rename_pages_domains_domain_type_to_scope.rb
new file mode 100644
index 00000000000..d1d2b4962dd
--- /dev/null
+++ b/db/post_migrate/20200129035708_cleanup_rename_pages_domains_domain_type_to_scope.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class CleanupRenamePagesDomainsDomainTypeToScope < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ cleanup_concurrent_column_rename :pages_domains, :domain_type, :scope
+ end
+
+ def down
+ undo_cleanup_concurrent_column_rename :pages_domains, :domain_type, :scope
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 70e93a63148..98f127020de 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 2020_01_27_090233) do
+ActiveRecord::Schema.define(version: 2020_01_29_035708) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_trgm"
@@ -3018,13 +3018,15 @@ ActiveRecord::Schema.define(version: 2020_01_27_090233) do
t.datetime_with_timezone "certificate_valid_not_after"
t.integer "certificate_source", limit: 2, default: 0, null: false
t.boolean "wildcard", default: false, null: false
- t.integer "domain_type", limit: 2, default: 2, null: false
+ t.integer "usage", limit: 2, default: 0, null: false
+ t.integer "scope", limit: 2, default: 2, null: false
t.index ["certificate_source", "certificate_valid_not_after"], name: "index_pages_domains_need_auto_ssl_renewal", where: "(auto_ssl_enabled = true)"
- t.index ["domain"], name: "index_pages_domains_on_domain", unique: true
- t.index ["domain_type"], name: "index_pages_domains_on_domain_type"
+ t.index ["domain", "wildcard"], name: "index_pages_domains_on_domain_and_wildcard", unique: true
t.index ["project_id", "enabled_until"], name: "index_pages_domains_on_project_id_and_enabled_until"
t.index ["project_id"], name: "index_pages_domains_on_project_id"
t.index ["remove_at"], name: "index_pages_domains_on_remove_at"
+ t.index ["scope"], name: "index_pages_domains_on_scope"
+ t.index ["usage"], name: "index_pages_domains_on_usage"
t.index ["verified_at", "enabled_until"], name: "index_pages_domains_on_verified_at_and_enabled_until"
t.index ["verified_at"], name: "index_pages_domains_on_verified_at"
t.index ["wildcard"], name: "index_pages_domains_on_wildcard"
diff --git a/lib/api/releases.rb b/lib/api/releases.rb
index 506d2b0f985..b1f23d9837f 100644
--- a/lib/api/releases.rb
+++ b/lib/api/releases.rb
@@ -67,6 +67,7 @@ module API
if result[:status] == :success
log_release_created_audit_event(result[:release])
+ create_evidence!
present result[:release], with: Entities::Release, current_user: current_user
else
@@ -164,6 +165,16 @@ module API
def log_release_milestones_updated_audit_event
# This is a separate method so that EE can extend its behaviour
end
+
+ def create_evidence!
+ return if release.historical_release?
+
+ if release.upcoming_release?
+ CreateEvidenceWorker.perform_at(release.released_at, release.id)
+ else
+ CreateEvidenceWorker.perform_async(release.id)
+ end
+ end
end
end
end
diff --git a/spec/factories/pages_domains.rb b/spec/factories/pages_domains.rb
index 282783dee3a..7606e806e04 100644
--- a/spec/factories/pages_domains.rb
+++ b/spec/factories/pages_domains.rb
@@ -377,7 +377,8 @@ x6zG6WoibsbsJMj70nwseUnPTBQNDP+j61RJjC/r
trait :instance_serverless do
wildcard { true }
- domain_type { :instance }
+ scope { :instance }
+ usage { :serverless }
end
end
end
diff --git a/spec/models/pages_domain_spec.rb b/spec/models/pages_domain_spec.rb
index b1df13e8c2a..a88db3b87af 100644
--- a/spec/models/pages_domain_spec.rb
+++ b/spec/models/pages_domain_spec.rb
@@ -180,8 +180,12 @@ describe PagesDomain do
expect(subject.wildcard).to eq(false)
end
- it 'defaults domain_type to project' do
- expect(subject.domain_type).to eq('project')
+ it 'defaults scope to project' do
+ expect(subject.scope).to eq('project')
+ end
+
+ it 'defaults usage to pages' do
+ expect(subject.usage).to eq('pages')
end
end
@@ -315,11 +319,11 @@ describe PagesDomain do
end
describe '#update_daemon' do
- context 'when domain_type is instance' do
- it 'does nothing' do
+ context 'when usage is serverless' do
+ it 'does not call the UpdatePagesConfigurationService' do
expect(Projects::UpdatePagesConfigurationService).not_to receive(:new)
- create(:pages_domain, domain_type: :instance)
+ create(:pages_domain, usage: :serverless)
end
end
diff --git a/spec/models/release_spec.rb b/spec/models/release_spec.rb
index 2f84b92b806..85e398c7d5f 100644
--- a/spec/models/release_spec.rb
+++ b/spec/models/release_spec.rb
@@ -53,12 +53,6 @@ RSpec.describe Release do
end
end
- describe 'callbacks' do
- it 'creates a new Evidence object on after_commit', :sidekiq_inline do
- expect { release }.to change(Evidence, :count).by(1)
- end
- end
-
describe '#assets_count' do
subject { release.assets_count }
diff --git a/spec/requests/api/releases_spec.rb b/spec/requests/api/releases_spec.rb
index ae95b54a590..e0f88caeab6 100644
--- a/spec/requests/api/releases_spec.rb
+++ b/spec/requests/api/releases_spec.rb
@@ -9,6 +9,7 @@ describe API::Releases do
let(:guest) { create(:user) }
let(:non_project_member) { create(:user) }
let(:commit) { create(:commit, project: project) }
+ let(:last_release) { project.releases.last }
before do
project.add_maintainer(maintainer)
@@ -709,6 +710,109 @@ describe API::Releases do
expect(response).to have_gitlab_http_status(:conflict)
end
end
+
+ context 'Evidence collection' do
+ let(:params) do
+ {
+ name: 'New release',
+ tag_name: 'v0.1',
+ description: 'Super nice release',
+ released_at: released_at
+ }.compact
+ end
+
+ around do |example|
+ Timecop.freeze { example.run }
+ end
+
+ subject do
+ post api("/projects/#{project.id}/releases", maintainer), params: params
+ end
+
+ context 'historical release' do
+ let(:released_at) { 3.weeks.ago }
+
+ it 'does not execute CreateEvidenceWorker' do
+ expect { subject }.not_to change(CreateEvidenceWorker.jobs, :size)
+ end
+
+ it 'does not create an Evidence object', :sidekiq_inline do
+ expect { subject }.not_to change(Evidence, :count)
+ end
+
+ it 'is a historical release' do
+ subject
+
+ expect(last_release.historical_release?).to be_truthy
+ end
+
+ it 'is not an upcoming release' do
+ subject
+
+ expect(last_release.upcoming_release?).to be_falsy
+ end
+ end
+
+ context 'immediate release' do
+ let(:released_at) { nil }
+
+ it 'sets `released_at` to the current dttm' do
+ subject
+
+ expect(last_release.updated_at).to be_like_time(Time.now)
+ end
+
+ it 'queues CreateEvidenceWorker' do
+ expect { subject }.to change(CreateEvidenceWorker.jobs, :size).by(1)
+ end
+
+ it 'creates Evidence', :sidekiq_inline do
+ expect { subject }.to change(Evidence, :count).by(1)
+ end
+
+ it 'is not a historical release' do
+ subject
+
+ expect(last_release.historical_release?).to be_falsy
+ end
+
+ it 'is not an upcoming release' do
+ subject
+
+ expect(last_release.upcoming_release?).to be_falsy
+ end
+ end
+
+ context 'upcoming release' do
+ let(:released_at) { 1.day.from_now }
+
+ it 'queues CreateEvidenceWorker' do
+ expect { subject }.to change(CreateEvidenceWorker.jobs, :size).by(1)
+ end
+
+ it 'queues CreateEvidenceWorker at the released_at timestamp' do
+ subject
+
+ expect(CreateEvidenceWorker.jobs.last['at']).to eq(released_at.to_i)
+ end
+
+ it 'creates Evidence', :sidekiq_inline do
+ expect { subject }.to change(Evidence, :count).by(1)
+ end
+
+ it 'is not a historical release' do
+ subject
+
+ expect(last_release.historical_release?).to be_falsy
+ end
+
+ it 'is an upcoming release' do
+ subject
+
+ expect(last_release.upcoming_release?).to be_truthy
+ end
+ end
+ end
end
describe 'PUT /projects/:id/releases/:tag_name' do