Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2022-08-10 21:09:39 +00:00
parent 2e2c1a521c
commit 20a18d1f9b
16 changed files with 182 additions and 24 deletions

View file

@ -19,10 +19,13 @@ module SystemNotes
def change_start_date_or_due_date(changed_dates = {}) def change_start_date_or_due_date(changed_dates = {})
return if changed_dates.empty? return if changed_dates.empty?
if noteable.is_a?(Issue) && changed_dates.key?('due_date') # Using instance_of because WorkItem < Issue. We don't want to track work item updates as issue updates
if noteable.instance_of?(Issue) && changed_dates.key?('due_date')
issue_activity_counter.track_issue_due_date_changed_action(author: author) issue_activity_counter.track_issue_due_date_changed_action(author: author)
end end
work_item_activity_counter.track_work_item_date_changed_action(author: author) if noteable.is_a?(WorkItem)
create_note( create_note(
NoteSummary.new(noteable, project, author, changed_date_body(changed_dates), action: 'start_date_or_due_date') NoteSummary.new(noteable, project, author, changed_date_body(changed_dates), action: 'start_date_or_due_date')
) )
@ -147,5 +150,9 @@ module SystemNotes
def issue_activity_counter def issue_activity_counter
Gitlab::UsageDataCounters::IssueActivityUniqueCounter Gitlab::UsageDataCounters::IssueActivityUniqueCounter
end end
def work_item_activity_counter
Gitlab::UsageDataCounters::WorkItemActivityUniqueCounter
end
end end
end end

View file

@ -49,6 +49,7 @@
events: events:
- users_creating_work_items - users_creating_work_items
- users_updating_work_item_title - users_updating_work_item_title
- users_updating_work_item_dates
feature_flag: track_work_items_activity feature_flag: track_work_items_activity
- name: xmau_project_management - name: xmau_project_management
operator: OR operator: OR
@ -57,6 +58,7 @@
events: events:
- users_creating_work_items - users_creating_work_items
- users_updating_work_item_title - users_updating_work_item_title
- users_updating_work_item_dates
feature_flag: track_work_items_activity feature_flag: track_work_items_activity
- name: users_work_items - name: users_work_items
operator: OR operator: OR
@ -65,4 +67,5 @@
events: events:
- users_creating_work_items - users_creating_work_items
- users_updating_work_item_title - users_updating_work_item_title
- users_updating_work_item_dates
feature_flag: track_work_items_activity feature_flag: track_work_items_activity

View file

@ -0,0 +1,25 @@
---
key_path: redis_hll_counters.work_items.users_updating_work_item_dates_monthly
description: Unique users updating a work item's date
product_category: team_planning
product_section: dev
product_stage: plan
product_group: project_management
value_type: number
status: active
milestone: '15.3'
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/93231
time_frame: 28d
data_source: redis_hll
data_category: optional
instrumentation_class: RedisHLLMetric
options:
events:
- users_updating_work_item_dates
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate

View file

@ -0,0 +1,25 @@
---
key_path: redis_hll_counters.work_items.users_updating_work_item_dates_weekly
description: Unique users updating a work item's date
product_category: team_planning
product_section: dev
product_stage: plan
product_group: project_management
value_type: number
status: active
milestone: '15.3'
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/93231
time_frame: 7d
data_source: redis_hll
data_category: optional
instrumentation_class: RedisHLLMetric
options:
events:
- users_updating_work_item_dates
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate

View file

@ -119,8 +119,8 @@ The following are required to run Geo:
The following operating systems are known to ship with a current version of OpenSSH: The following operating systems are known to ship with a current version of OpenSSH:
- [CentOS](https://www.centos.org) 7.4 or later - [CentOS](https://www.centos.org) 7.4 or later
- [Ubuntu](https://ubuntu.com) 16.04 or later - [Ubuntu](https://ubuntu.com) 16.04 or later
- PostgreSQL 12 with [Streaming Replication](https://wiki.postgresql.org/wiki/Streaming_Replication) - PostgreSQL 12 or 13 with [Streaming Replication](https://wiki.postgresql.org/wiki/Streaming_Replication)
- PostgreSQL 13 is not supported for Geo, see [epic 3832](https://gitlab.com/groups/gitlab-org/-/epics/3832) - Note,[PostgreSQL 12 is deprecated](../../update/deprecations.md#postgresql-12-deprecated) and will be removed in GitLab 16.0.
- Git 2.9 or later - Git 2.9 or later
- Git-lfs 2.4.2 or later on the user side when using LFS - Git-lfs 2.4.2 or later on the user side when using LFS
- All sites must run [the same GitLab and PostgreSQL versions](setup/database.md#postgresql-replication). - All sites must run [the same GitLab and PostgreSQL versions](setup/database.md#postgresql-replication).

View file

@ -22,6 +22,7 @@ The steps below should be followed in the order they appear. **Make sure the Git
If you installed GitLab using the Omnibus packages (highly recommended): If you installed GitLab using the Omnibus packages (highly recommended):
1. Confirm the [requirements for running Geo](../index.md#requirements-for-running-geo) are met.
1. [Install GitLab Enterprise Edition](https://about.gitlab.com/install/) on the nodes that serve as the **secondary** site. **Do not create an account or log in** to the new **secondary** site. The **GitLab version must match** across primary and secondary sites. 1. [Install GitLab Enterprise Edition](https://about.gitlab.com/install/) on the nodes that serve as the **secondary** site. **Do not create an account or log in** to the new **secondary** site. The **GitLab version must match** across primary and secondary sites.
1. [Add the GitLab License](../../../user/admin_area/license.md) on the **primary** site to unlock Geo. The license must be for [GitLab Premium](https://about.gitlab.com/pricing/) or higher. 1. [Add the GitLab License](../../../user/admin_area/license.md) on the **primary** site to unlock Geo. The license must be for [GitLab Premium](https://about.gitlab.com/pricing/) or higher.
1. [Confirm network connectivity](../index.md#firewall-rules) between the **primary** and **secondary** site. 1. [Confirm network connectivity](../index.md#firewall-rules) between the **primary** and **secondary** site.

View file

@ -95,7 +95,7 @@ To connect to a clone using `psql`:
1. In the **Clone details** page of the Postgres.ai web interface, copy and run 1. In the **Clone details** page of the Postgres.ai web interface, copy and run
the command to start SSH port forwarding for the clone. the command to start SSH port forwarding for the clone.
1. In the **Clone details** page of the Postgres.ai web interface, copy and run the `psql` connection string. 1. In the **Clone details** page of the Postgres.ai web interface, copy and run the `psql` connection string.
Use the password provided at setup. Use the password provided at setup and set the `dbname` to `gitlabhq_dblab` (or check what databases are available by using `psql -l` with the same query string but `dbname=postgres`).
After you connect, use clone like you would any `psql` console in production, but with After you connect, use clone like you would any `psql` console in production, but with
the added benefit and safety of an isolated writeable environment. the added benefit and safety of an isolated writeable environment.

View file

@ -756,6 +756,21 @@ If a backport adding a column with a default value is needed for %12.9 or earlie
it should use `add_column_with_default` helper. If a [large table](https://gitlab.com/gitlab-org/gitlab/-/blob/master/rubocop/rubocop-migrations.yml#L3) it should use `add_column_with_default` helper. If a [large table](https://gitlab.com/gitlab-org/gitlab/-/blob/master/rubocop/rubocop-migrations.yml#L3)
is involved, backporting to %12.9 is contraindicated. is involved, backporting to %12.9 is contraindicated.
## Removing the column default for non-nullable columns
If you have added a non-nullable column, and used the default value to populate
existing data, you need to keep that default value around until at least after
the application code is updated. You cannot remove the default value in the
same migration, as the migrations run before the model code is updated and
models will have an old schema cache, meaning they won't know about this column
and won't be able to set it. In this case it's recommended to:
1. Add the column with default value in a normal migration.
1. Remove the default in a post-deployment migration.
The post-deployment migration happens after the application restarts,
ensuring the new column has been discovered.
## Changing the column default ## Changing the column default
One might think that changing a default column with `change_column_default` is an One might think that changing a default column with `change_column_default` is an

View file

@ -152,8 +152,8 @@ includes a **Resolve with merge request** option.
The following scanners are supported by this feature: The following scanners are supported by this feature:
- [Dependency Scanning](../dependency_scanning/index.md). - [Dependency Scanning](../dependency_scanning/index.md).
Automatic Patch creation is only available for Node.js projects managed with Automatic patch creation is only available for Node.js projects managed with
`yarn` when [FIPS mode](../../../development/fips_compliance.md#enable-fips-mode) is disabled. `yarn`. Also, Automatic patch creation is only supported when [FIPS mode](../../../development/fips_compliance.md#enable-fips-mode) is disabled.
- [Container Scanning](../container_scanning/index.md). - [Container Scanning](../container_scanning/index.md).
To resolve a vulnerability, you can either: To resolve a vulnerability, you can either:

View file

@ -124,10 +124,8 @@ You can create a release directly as part of the GitLab CI/CD pipeline by using
The release is created only if the job processes without error. If the API returns an error during The release is created only if the job processes without error. If the API returns an error during
release creation, the release job fails. release creation, the release job fails.
Methods for creating a release using a CI/CD job include: For examples of how you can create a release of your application in the CI/CD pipeline,
see [Release CI/CD examples](release_cicd_examples.md).
- Create a release when a Git tag is created.
- Create a release when a commit is merged to the default branch.
### Use a custom SSL CA certificate authority ### Use a custom SSL CA certificate authority

View file

@ -9,3 +9,8 @@
redis_slot: users redis_slot: users
aggregation: weekly aggregation: weekly
feature_flag: track_work_items_activity feature_flag: track_work_items_activity
- name: users_updating_work_item_dates
category: work_items
redis_slot: users
aggregation: weekly
feature_flag: track_work_items_activity

View file

@ -5,6 +5,7 @@ module Gitlab
module WorkItemActivityUniqueCounter module WorkItemActivityUniqueCounter
WORK_ITEM_CREATED = 'users_creating_work_items' WORK_ITEM_CREATED = 'users_creating_work_items'
WORK_ITEM_TITLE_CHANGED = 'users_updating_work_item_title' WORK_ITEM_TITLE_CHANGED = 'users_updating_work_item_title'
WORK_ITEM_DATE_CHANGED = 'users_updating_work_item_dates'
class << self class << self
def track_work_item_created_action(author:) def track_work_item_created_action(author:)
@ -15,6 +16,10 @@ module Gitlab
track_unique_action(WORK_ITEM_TITLE_CHANGED, author) track_unique_action(WORK_ITEM_TITLE_CHANGED, author)
end end
def track_work_item_date_changed_action(author:)
track_unique_action(WORK_ITEM_DATE_CHANGED, author)
end
private private
def track_unique_action(action, author) def track_unique_action(action, author)

View file

@ -113,7 +113,7 @@ module Gitlab
# Methods defined within a class method are already public by default, so we don't need to # Methods defined within a class method are already public by default, so we don't need to
# explicitly make them public. # explicitly make them public.
scope = %i(private protected).find do |scope| scope = %i[private protected].find do |scope|
klass.send("#{scope}_instance_methods") # rubocop:disable GitlabSecurity/PublicSend klass.send("#{scope}_instance_methods") # rubocop:disable GitlabSecurity/PublicSend
.include? method_name .include? method_name
end end

View file

@ -20,4 +20,12 @@ RSpec.describe Gitlab::UsageDataCounters::WorkItemActivityUniqueCounter, :clean_
it_behaves_like 'work item unique counter' it_behaves_like 'work item unique counter'
end end
describe '.track_work_item_date_changed_action' do
subject(:track_event) { described_class.track_work_item_date_changed_action(author: user) }
let(:event_name) { described_class::WORK_ITEM_DATE_CHANGED }
it_behaves_like 'work item unique counter'
end
end end

View file

@ -7,15 +7,16 @@ RSpec.describe ::SystemNotes::TimeTrackingService do
let_it_be(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
describe '#change_start_date_or_due_date' do describe '#change_start_date_or_due_date' do
let_it_be(:issue) { create(:issue, project: project) }
let_it_be(:work_item) { create(:work_item, project: project) }
subject(:note) { described_class.new(noteable: noteable, project: project, author: author).change_start_date_or_due_date(changed_dates) } subject(:note) { described_class.new(noteable: noteable, project: project, author: author).change_start_date_or_due_date(changed_dates) }
let(:start_date) { Date.today } let(:start_date) { Date.today }
let(:due_date) { 1.week.from_now.to_date } let(:due_date) { 1.week.from_now.to_date }
let(:changed_dates) { { 'due_date' => [nil, due_date], 'start_date' => [nil, start_date] } } let(:changed_dates) { { 'due_date' => [nil, due_date], 'start_date' => [nil, start_date] } }
let_it_be(:noteable) { create(:issue, project: project) } shared_examples 'issuable getting date change notes' do
context 'when noteable is an issue' do
it_behaves_like 'a note with overridable created_at' it_behaves_like 'a note with overridable created_at'
it_behaves_like 'a system note' do it_behaves_like 'a system note' do
@ -43,16 +44,16 @@ RSpec.describe ::SystemNotes::TimeTrackingService do
context 'when due date is added' do context 'when due date is added' do
let(:changed_dates) { { 'due_date' => [nil, due_date] } } let(:changed_dates) { { 'due_date' => [nil, due_date] } }
it 'tracks the issue event in usage ping' do
expect(Gitlab::UsageDataCounters::IssueActivityUniqueCounter).to receive(:track_issue_due_date_changed_action).with(author: author)
subject
end
it 'sets the correct note message' do it 'sets the correct note message' do
expect(note.note).to eq("changed due date to #{due_date.to_s(:long)}") expect(note.note).to eq("changed due date to #{due_date.to_s(:long)}")
end end
it 'tracks the issue event in usage ping' do
expect(activity_counter_class).to receive(activity_counter_method).with(author: author)
subject
end
context 'and start date removed' do context 'and start date removed' do
let(:changed_dates) { { 'due_date' => [nil, due_date], 'start_date' => [start_date, nil] } } let(:changed_dates) { { 'due_date' => [nil, due_date], 'start_date' => [start_date, nil] } }
@ -97,14 +98,69 @@ RSpec.describe ::SystemNotes::TimeTrackingService do
end end
end end
context 'when noteable is a merge request' do context 'when noteable is an issue' do
let_it_be(:noteable) { create(:merge_request, source_project: project) } let(:noteable) { issue }
let(:activity_counter_class) { Gitlab::UsageDataCounters::IssueActivityUniqueCounter }
let(:activity_counter_method) { :track_issue_due_date_changed_action }
it_behaves_like 'issuable getting date change notes'
it 'does not track the work item event in usage ping' do
expect(Gitlab::UsageDataCounters::WorkItemActivityUniqueCounter).not_to receive(:track_work_item_date_changed_action)
subject
end
it 'tracks the issue event in usage ping' do
expect(Gitlab::UsageDataCounters::IssueActivityUniqueCounter).to receive(:track_issue_due_date_changed_action).with(author: author)
subject
end
context 'when only start_date is added' do
let(:changed_dates) { { 'start_date' => [nil, start_date] } }
it 'does not track the issue event in usage ping' do
expect(activity_counter_class).not_to receive(activity_counter_method)
subject
end
end
end
context 'when noteable is a work item' do
let(:noteable) { work_item }
let(:activity_counter_class) { Gitlab::UsageDataCounters::WorkItemActivityUniqueCounter }
let(:activity_counter_method) { :track_work_item_date_changed_action }
it_behaves_like 'issuable getting date change notes'
it 'does not track the issue event in usage ping' do it 'does not track the issue event in usage ping' do
expect(Gitlab::UsageDataCounters::IssueActivityUniqueCounter).not_to receive(:track_issue_due_date_changed_action) expect(Gitlab::UsageDataCounters::IssueActivityUniqueCounter).not_to receive(:track_issue_due_date_changed_action)
subject subject
end end
context 'when only start_date is added' do
let(:changed_dates) { { 'start_date' => [nil, start_date] } }
it 'tracks the issue event in usage ping' do
expect(activity_counter_class).to receive(activity_counter_method).with(author: author)
subject
end
end
end
context 'when noteable is a merge request' do
let(:noteable) { create(:merge_request, source_project: project) }
it 'does not track the issue event in usage ping' do
expect(Gitlab::UsageDataCounters::IssueActivityUniqueCounter).not_to receive(:track_issue_due_date_changed_action)
expect(Gitlab::UsageDataCounters::WorkItemActivityUniqueCounter).not_to receive(:track_work_item_date_changed_action)
subject
end
end end
end end

View file

@ -66,6 +66,16 @@ RSpec.describe WorkItems::UpdateService do
end end
end end
context 'when dates are changed' do
let(:opts) { { start_date: Date.today } }
it 'tracks users updating work item dates' do
expect(Gitlab::UsageDataCounters::WorkItemActivityUniqueCounter).to receive(:track_work_item_date_changed_action).with(author: current_user)
update_work_item
end
end
context 'when updating state_event' do context 'when updating state_event' do
context 'when state_event is close' do context 'when state_event is close' do
let(:opts) { { state_event: 'close' } } let(:opts) { { state_event: 'close' } }