Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2022-07-09 06:08:43 +00:00
parent 37e1f8c80e
commit 3a8425c520
9 changed files with 94 additions and 31 deletions

View File

@ -1135,6 +1135,14 @@ module Ci
Gitlab::Utils::UsageData.track_usage_event('ci_users_executing_deployment_job', user_id) if user_id.present? && count_user_deployment?
end
def track_verify_usage
Gitlab::Utils::UsageData.track_usage_event('ci_users_executing_verify_environment_job', user_id) if user_id.present? && count_user_verification?
end
def count_user_verification?
has_environment? && environment_action == 'verify'
end
def each_report(report_types)
job_artifacts_for_types(report_types).each do |report_artifact|
report_artifact.each_blob do |blob|

View File

@ -4,17 +4,13 @@ module Ci
class ArchiveTraceWorker # rubocop:disable Scalability/IdempotentWorker
include ApplicationWorker
data_consistency :sticky, feature_flag: :sticky_ci_archive_trace_worker
data_consistency :sticky
sidekiq_options retry: 3
include PipelineBackgroundQueue
def perform(job_id)
archivable_jobs = Ci::Build.without_archived_trace
if Feature.enabled?(:sticky_ci_archive_trace_worker)
archivable_jobs = archivable_jobs.eager_load_for_archiving_trace
end
archivable_jobs = Ci::Build.without_archived_trace.eager_load_for_archiving_trace
archivable_jobs.find_by_id(job_id).try do |job|
Ci::ArchiveTraceService.new.execute(job, worker_name: self.class.name)

View File

@ -40,6 +40,7 @@ module Ci
BuildHooksWorker.perform_async(build)
ChatNotificationWorker.perform_async(build.id) if build.pipeline.chat?
build.track_deployment_usage
build.track_verify_usage
if build.failed? && !build.auto_retry_expected?
::Ci::MergeRequests::AddTodoWhenBuildFailsWorker.perform_async(build.id)

View File

@ -1,8 +0,0 @@
---
name: sticky_ci_archive_trace_worker
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/87577
rollout_issue_url: https://gitlab.com/gitlab-com/gl-infra/scalability/-/issues/1681
milestone: '15.1'
type: development
group: group::scalability
default_enabled: false

View File

@ -0,0 +1,26 @@
---
key_path: redis_hll_counters.ci_users.ci_users_executing_verify_environment_job_monthly
description: Monthly counts of times users have executed verify jobs
product_section: ops
product_stage: release
product_group: release
product_category: continuous_delivery
value_type: number
status: active
milestone: "15.2"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/91925
time_frame: 28d
data_source: redis_hll
data_category: optional
instrumentation_class: RedisHLLMetric
performance_indicator_type: []
options:
events:
- ci_users_executing_verify_environment_job
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate

View File

@ -0,0 +1,26 @@
---
key_path: redis_hll_counters.ci_users.ci_users_executing_verify_environment_job_weekly
description: Weekly counts of times users have executed verify jobs
product_section: ops
product_stage: release
product_group: release
product_category: continuous_delivery
value_type: number
status: active
milestone: "15.2"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/91925
time_frame: 7d
data_source: redis_hll
data_category: optional
instrumentation_class: RedisHLLMetric
performance_indicator_type: []
options:
events:
- ci_users_executing_verify_environment_job
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate

View File

@ -3,3 +3,8 @@
redis_slot: ci_users
aggregation: weekly
feature_flag:
- name: ci_users_executing_verify_environment_job
category: ci_users
redis_slot: ci_users
aggregation: weekly
feature_flag:

View File

@ -1554,6 +1554,32 @@ RSpec.describe Ci::Build do
end
end
describe '#count_user_verification?' do
subject { build.count_user_verification? }
context 'when build is the verify action for the environment' do
let(:build) do
create(:ci_build,
ref: 'master',
environment: 'staging',
options: { environment: { action: 'verify' } })
end
it { is_expected.to be_truthy }
end
context 'when build is not the verify action for the environment' do
let(:build) do
create(:ci_build,
ref: 'master',
environment: 'staging',
options: { environment: { action: 'start' } })
end
it { is_expected.to be_falsey }
end
end
describe '#expanded_environment_name' do
subject { build.expanded_environment_name }

View File

@ -27,23 +27,6 @@ RSpec.describe Ci::ArchiveTraceWorker do
subject
end
context 'when sticky_ci_archive_trace_worker is disabled' do
before do
stub_feature_flags(sticky_ci_archive_trace_worker: false)
end
it 'does not preload associations' do
allow_next_instance_of(Ci::ArchiveTraceService) do |instance|
allow(instance).to receive(:execute) do |job|
expect(job.association(:project)).not_to be_loaded
expect(job.association(:pending_state)).not_to be_loaded
end
end
subject
end
end
end
context 'when job is not found' do