summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/experimentation.rb19
-rw-r--r--lib/gitlab/phabricator_import/base_worker.rb82
-rw-r--r--lib/gitlab/phabricator_import/import_tasks_worker.rb10
-rw-r--r--lib/gitlab/usage_data.rb1
4 files changed, 11 insertions, 101 deletions
diff --git a/lib/gitlab/experimentation.rb b/lib/gitlab/experimentation.rb
index 9d14695c098..c689142d79d 100644
--- a/lib/gitlab/experimentation.rb
+++ b/lib/gitlab/experimentation.rb
@@ -53,14 +53,14 @@ module Gitlab
Experimentation.enabled_for_user?(experiment_key, experimentation_subject_index) || forced_enabled?(experiment_key)
end
- def track_experiment_event(experiment_key, action)
- track_experiment_event_for(experiment_key, action) do |tracking_data|
+ def track_experiment_event(experiment_key, action, value = nil)
+ track_experiment_event_for(experiment_key, action, value) do |tracking_data|
::Gitlab::Tracking.event(tracking_data.delete(:category), tracking_data.delete(:action), tracking_data)
end
end
- def frontend_experimentation_tracking_data(experiment_key, action)
- track_experiment_event_for(experiment_key, action) do |tracking_data|
+ def frontend_experimentation_tracking_data(experiment_key, action, value = nil)
+ track_experiment_event_for(experiment_key, action, value) do |tracking_data|
gon.push(tracking_data: tracking_data)
end
end
@@ -77,19 +77,20 @@ module Gitlab
experimentation_subject_id.delete('-').hex % 100
end
- def track_experiment_event_for(experiment_key, action)
+ def track_experiment_event_for(experiment_key, action, value)
return unless Experimentation.enabled?(experiment_key)
- yield experimentation_tracking_data(experiment_key, action)
+ yield experimentation_tracking_data(experiment_key, action, value)
end
- def experimentation_tracking_data(experiment_key, action)
+ def experimentation_tracking_data(experiment_key, action, value)
{
category: tracking_category(experiment_key),
action: action,
property: tracking_group(experiment_key),
- label: experimentation_subject_id
- }
+ label: experimentation_subject_id,
+ value: value
+ }.compact
end
def tracking_category(experiment_key)
diff --git a/lib/gitlab/phabricator_import/base_worker.rb b/lib/gitlab/phabricator_import/base_worker.rb
deleted file mode 100644
index d2c2ef8db48..00000000000
--- a/lib/gitlab/phabricator_import/base_worker.rb
+++ /dev/null
@@ -1,82 +0,0 @@
-# frozen_string_literal: true
-
-# All workers within a Phabricator import should inherit from this worker and
-# implement the `#import` method. The jobs should then be scheduled using the
-# `.schedule` class method instead of `.perform_async`
-#
-# Doing this makes sure that only one job of that type is running at the same time
-# for a certain project. This will avoid deadlocks. When a job is already running
-# we'll wait for it for 10 times 5 seconds to restart. If the running job hasn't
-# finished, by then, we'll retry in 30 seconds.
-#
-# It also makes sure that we keep the import state of the project up to date:
-# - It keeps track of the jobs so we know how many jobs are running for the
-# project
-# - It refreshes the import jid, so it doesn't get cleaned up by the
-# `StuckImportJobsWorker`
-# - It marks the import as failed if a job failed to many times
-# - It marks the import as finished when all remaining jobs are done
-module Gitlab
- module PhabricatorImport
- class BaseWorker
- include ApplicationWorker
- include ProjectImportOptions # This marks the project as failed after too many tries
- include Gitlab::ExclusiveLeaseHelpers
-
- feature_category :importers
-
- class << self
- def schedule(project_id, *args)
- perform_async(project_id, *args)
- add_job(project_id)
- end
-
- def add_job(project_id)
- worker_state(project_id).add_job
- end
-
- def remove_job(project_id)
- worker_state(project_id).remove_job
- end
-
- def worker_state(project_id)
- Gitlab::PhabricatorImport::WorkerState.new(project_id)
- end
- end
-
- def perform(project_id, *args)
- in_lock("#{self.class.name.underscore}/#{project_id}/#{args}", ttl: 2.hours, sleep_sec: 5.seconds) do
- project = Project.find_by_id(project_id)
- next unless project
-
- # Bail if the import job already failed
- next unless project.import_state&.in_progress?
-
- project.import_state.refresh_jid_expiration
-
- import(project, *args)
-
- # If this is the last running job, finish the import
- project.after_import if self.class.worker_state(project_id).running_count < 2
-
- self.class.remove_job(project_id)
- end
- rescue Gitlab::ExclusiveLeaseHelpers::FailedToObtainLockError
- # Reschedule a job if there was already a running one
- # Running them at the same time could cause a deadlock updating the same
- # resource
- self.class.perform_in(30.seconds, project_id, *args)
- end
-
- private
-
- def import(project, *args)
- importer_class.new(project, *args).execute
- end
-
- def importer_class
- raise NotImplementedError, "Implement `#{__method__}` on #{self.class}"
- end
- end
- end
-end
diff --git a/lib/gitlab/phabricator_import/import_tasks_worker.rb b/lib/gitlab/phabricator_import/import_tasks_worker.rb
deleted file mode 100644
index c36954a8d41..00000000000
--- a/lib/gitlab/phabricator_import/import_tasks_worker.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-# frozen_string_literal: true
-module Gitlab
- module PhabricatorImport
- class ImportTasksWorker < BaseWorker
- def importer_class
- Gitlab::PhabricatorImport::Issues::Importer
- end
- end
- end
-end
diff --git a/lib/gitlab/usage_data.rb b/lib/gitlab/usage_data.rb
index e00b49b9042..f10eb82e03e 100644
--- a/lib/gitlab/usage_data.rb
+++ b/lib/gitlab/usage_data.rb
@@ -78,6 +78,7 @@ module Gitlab
clusters_applications_runner: count(::Clusters::Applications::Runner.available),
clusters_applications_knative: count(::Clusters::Applications::Knative.available),
clusters_applications_elastic_stack: count(::Clusters::Applications::ElasticStack.available),
+ clusters_applications_jupyter: count(::Clusters::Applications::Jupyter.available),
in_review_folder: count(::Environment.in_review_folder),
grafana_integrated_projects: count(GrafanaIntegration.enabled),
groups: count(Group),