Commit c546e9b8 authored by Vitali Tatarintev's avatar Vitali Tatarintev

Move Alert::NotifyService dependencies to CE

Contributes to migration of Prometheus alerts to Core
parent ee0c3cc7
...@@ -14,6 +14,7 @@ class Environment < ApplicationRecord ...@@ -14,6 +14,7 @@ class Environment < ApplicationRecord
has_many :successful_deployments, -> { success }, class_name: 'Deployment' has_many :successful_deployments, -> { success }, class_name: 'Deployment'
has_many :active_deployments, -> { active }, class_name: 'Deployment' has_many :active_deployments, -> { active }, class_name: 'Deployment'
has_many :prometheus_alerts, inverse_of: :environment has_many :prometheus_alerts, inverse_of: :environment
has_many :self_managed_prometheus_alert_events, inverse_of: :environment
has_one :last_deployment, -> { success.order('deployments.id DESC') }, class_name: 'Deployment' has_one :last_deployment, -> { success.order('deployments.id DESC') }, class_name: 'Deployment'
has_one :last_deployable, through: :last_deployment, source: 'deployable', source_type: 'CommitStatus' has_one :last_deployable, through: :last_deployment, source: 'deployable', source_type: 'CommitStatus'
......
...@@ -254,6 +254,8 @@ class Project < ApplicationRecord ...@@ -254,6 +254,8 @@ class Project < ApplicationRecord
has_many :prometheus_metrics has_many :prometheus_metrics
has_many :prometheus_alerts, inverse_of: :project has_many :prometheus_alerts, inverse_of: :project
has_many :prometheus_alert_events, inverse_of: :project
has_many :self_managed_prometheus_alert_events, inverse_of: :project
# Container repositories need to remove data from the container registry, # Container repositories need to remove data from the container registry,
# which is not managed by the DB. Hence we're still using dependent: :destroy # which is not managed by the DB. Hence we're still using dependent: :destroy
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
class PrometheusAlertEvent < ApplicationRecord class PrometheusAlertEvent < ApplicationRecord
include AlertEventLifecycle include AlertEventLifecycle
belongs_to :project, required: true, validate: true, inverse_of: :prometheus_alert_events belongs_to :project, optional: false, validate: true, inverse_of: :prometheus_alert_events
belongs_to :prometheus_alert, required: true, validate: true, inverse_of: :prometheus_alert_events belongs_to :prometheus_alert, optional: false, validate: true, inverse_of: :prometheus_alert_events
has_and_belongs_to_many :related_issues, class_name: 'Issue', join_table: :issues_prometheus_alert_events has_and_belongs_to_many :related_issues, class_name: 'Issue', join_table: :issues_prometheus_alert_events # rubocop:disable Rails/HasAndBelongsToMany
validates :payload_key, uniqueness: { scope: :prometheus_alert_id } validates :payload_key, uniqueness: { scope: :prometheus_alert_id }
validates :started_at, presence: true validates :started_at, presence: true
......
...@@ -5,7 +5,7 @@ class SelfManagedPrometheusAlertEvent < ApplicationRecord ...@@ -5,7 +5,7 @@ class SelfManagedPrometheusAlertEvent < ApplicationRecord
belongs_to :project, validate: true, inverse_of: :self_managed_prometheus_alert_events belongs_to :project, validate: true, inverse_of: :self_managed_prometheus_alert_events
belongs_to :environment, validate: true, inverse_of: :self_managed_prometheus_alert_events belongs_to :environment, validate: true, inverse_of: :self_managed_prometheus_alert_events
has_and_belongs_to_many :related_issues, class_name: 'Issue', join_table: :issues_self_managed_prometheus_alert_events has_and_belongs_to_many :related_issues, class_name: 'Issue', join_table: :issues_self_managed_prometheus_alert_events # rubocop:disable Rails/HasAndBelongsToMany
validates :started_at, presence: true validates :started_at, presence: true
validates :payload_key, uniqueness: { scope: :project_id } validates :payload_key, uniqueness: { scope: :project_id }
......
...@@ -528,6 +528,13 @@ ...@@ -528,6 +528,13 @@
:resource_boundary: :unknown :resource_boundary: :unknown
:weight: 2 :weight: 2
:idempotent: :idempotent:
- :name: incident_management:incident_management_process_prometheus_alert
:feature_category: :incident_management
:has_external_dependencies:
:urgency: :low
:resource_boundary: :cpu
:weight: 2
:idempotent:
- :name: jira_importer:jira_import_advance_stage - :name: jira_importer:jira_import_advance_stage
:feature_category: :importers :feature_category: :importers
:has_external_dependencies: :has_external_dependencies:
......
...@@ -7,8 +7,6 @@ module EE ...@@ -7,8 +7,6 @@ module EE
include ::Gitlab::Utils::StrongMemoize include ::Gitlab::Utils::StrongMemoize
prepended do prepended do
has_many :self_managed_prometheus_alert_events, inverse_of: :environment
# Returns environments where its latest deployment is to a cluster # Returns environments where its latest deployment is to a cluster
scope :deployed_to_cluster, -> (cluster) do scope :deployed_to_cluster, -> (cluster) do
environments = model.arel_table environments = model.arel_table
......
...@@ -82,9 +82,6 @@ module EE ...@@ -82,9 +82,6 @@ module EE
has_many :webide_pipelines, -> { webide_source }, class_name: 'Ci::Pipeline', inverse_of: :project has_many :webide_pipelines, -> { webide_source }, class_name: 'Ci::Pipeline', inverse_of: :project
has_many :prometheus_alert_events, inverse_of: :project
has_many :self_managed_prometheus_alert_events, inverse_of: :project
has_many :operations_feature_flags, class_name: 'Operations::FeatureFlag' has_many :operations_feature_flags, class_name: 'Operations::FeatureFlag'
has_one :operations_feature_flags_client, class_name: 'Operations::FeatureFlagsClient' has_one :operations_feature_flags_client, class_name: 'Operations::FeatureFlagsClient'
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
:idempotent: true :idempotent: true
- :name: cronjob:elastic_metrics_update - :name: cronjob:elastic_metrics_update
:feature_category: :global_search :feature_category: :global_search
:has_external_dependencies: :has_external_dependencies:
:urgency: :low :urgency: :low
:resource_boundary: :unknown :resource_boundary: :unknown
:weight: 1 :weight: 1
...@@ -381,13 +381,6 @@ ...@@ -381,13 +381,6 @@
:resource_boundary: :unknown :resource_boundary: :unknown
:weight: 1 :weight: 1
:idempotent: :idempotent:
- :name: incident_management:incident_management_process_prometheus_alert
:feature_category: :incident_management
:has_external_dependencies:
:urgency: :low
:resource_boundary: :cpu
:weight: 2
:idempotent:
- :name: jira_connect:jira_connect_sync_branch - :name: jira_connect:jira_connect_sync_branch
:feature_category: :integrations :feature_category: :integrations
:has_external_dependencies: :has_external_dependencies:
......
...@@ -107,6 +107,8 @@ describe Project do ...@@ -107,6 +107,8 @@ describe Project do
it { is_expected.to have_many(:external_pull_requests) } it { is_expected.to have_many(:external_pull_requests) }
it { is_expected.to have_many(:sourced_pipelines) } it { is_expected.to have_many(:sourced_pipelines) }
it { is_expected.to have_many(:source_pipelines) } it { is_expected.to have_many(:source_pipelines) }
it { is_expected.to have_many(:prometheus_alert_events) }
it { is_expected.to have_many(:self_managed_prometheus_alert_events) }
it_behaves_like 'model with repository' do it_behaves_like 'model with repository' do
let_it_be(:container) { create(:project, :repository, path: 'somewhere') } let_it_be(:container) { create(:project, :repository, path: 'somewhere') }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment