Commit f2c0274a authored by Mikolaj Wawrzyniak's avatar Mikolaj Wawrzyniak Committed by Dhiraj Bodicherla

Remove metrics_dashboard_annotations feature flag

Because we want to make annotations public available we need
to remove feature flag.
parent d6cfb4ac
...@@ -13,11 +13,7 @@ import trackDashboardLoad from '../monitoring_tracking_helper'; ...@@ -13,11 +13,7 @@ import trackDashboardLoad from '../monitoring_tracking_helper';
import getEnvironments from '../queries/getEnvironments.query.graphql'; import getEnvironments from '../queries/getEnvironments.query.graphql';
import getAnnotations from '../queries/getAnnotations.query.graphql'; import getAnnotations from '../queries/getAnnotations.query.graphql';
import statusCodes from '../../lib/utils/http_status'; import statusCodes from '../../lib/utils/http_status';
import { import { backOff, convertObjectPropsToCamelCase } from '../../lib/utils/common_utils';
backOff,
convertObjectPropsToCamelCase,
isFeatureFlagEnabled,
} from '../../lib/utils/common_utils';
import { s__, sprintf } from '../../locale'; import { s__, sprintf } from '../../locale';
import { import {
...@@ -116,14 +112,7 @@ export const clearExpandedPanel = ({ commit }) => { ...@@ -116,14 +112,7 @@ export const clearExpandedPanel = ({ commit }) => {
export const fetchData = ({ dispatch }) => { export const fetchData = ({ dispatch }) => {
dispatch('fetchEnvironmentsData'); dispatch('fetchEnvironmentsData');
dispatch('fetchDashboard'); dispatch('fetchDashboard');
/** dispatch('fetchAnnotations');
* Annotations data is not yet fetched. This will be
* ready after the BE piece is implemented.
* https://gitlab.com/gitlab-org/gitlab/-/issues/211330
*/
if (isFeatureFlagEnabled('metricsDashboardAnnotations')) {
dispatch('fetchAnnotations');
}
}; };
// Metrics dashboard // Metrics dashboard
......
...@@ -9,7 +9,6 @@ class Projects::EnvironmentsController < Projects::ApplicationController ...@@ -9,7 +9,6 @@ class Projects::EnvironmentsController < Projects::ApplicationController
authorize_metrics_dashboard! authorize_metrics_dashboard!
push_frontend_feature_flag(:prometheus_computed_alerts) push_frontend_feature_flag(:prometheus_computed_alerts)
push_frontend_feature_flag(:metrics_dashboard_annotations, project)
end end
before_action :authorize_read_environment! before_action :authorize_read_environment!
before_action :authorize_create_environment!, only: [:new, :create] before_action :authorize_create_environment!, only: [:new, :create]
......
...@@ -18,7 +18,6 @@ module Resolvers ...@@ -18,7 +18,6 @@ module Resolvers
def resolve(**args) def resolve(**args)
return [] unless dashboard return [] unless dashboard
return [] unless Feature.enabled?(:metrics_dashboard_annotations, dashboard.environment&.project)
::Metrics::Dashboards::AnnotationsFinder.new(dashboard: dashboard, params: args).execute ::Metrics::Dashboards::AnnotationsFinder.new(dashboard: dashboard, params: args).execute
end end
......
...@@ -11,8 +11,7 @@ module Types ...@@ -11,8 +11,7 @@ module Types
description: 'Path to a file with the dashboard definition' description: 'Path to a file with the dashboard definition'
field :annotations, Types::Metrics::Dashboards::AnnotationType.connection_type, null: true, field :annotations, Types::Metrics::Dashboards::AnnotationType.connection_type, null: true,
description: 'Annotations added to the dashboard. Will always return `null` ' \ description: 'Annotations added to the dashboard',
'if `metrics_dashboard_annotations` feature flag is disabled',
resolver: Resolvers::Metrics::Dashboards::AnnotationResolver resolver: Resolvers::Metrics::Dashboards::AnnotationResolver
end end
# rubocop: enable Graphql/AuthorizeTypes # rubocop: enable Graphql/AuthorizeTypes
......
---
title: Add metrics dashboard annotations feature, which enables marking interesting
events over metrics dashboard charts
merge_request: 30371
author:
type: added
...@@ -6027,7 +6027,7 @@ type Metadata { ...@@ -6027,7 +6027,7 @@ type Metadata {
type MetricsDashboard { type MetricsDashboard {
""" """
Annotations added to the dashboard. Will always return `null` if `metrics_dashboard_annotations` feature flag is disabled Annotations added to the dashboard
""" """
annotations( annotations(
""" """
......
...@@ -16917,7 +16917,7 @@ ...@@ -16917,7 +16917,7 @@
"fields": [ "fields": [
{ {
"name": "annotations", "name": "annotations",
"description": "Annotations added to the dashboard. Will always return `null` if `metrics_dashboard_annotations` feature flag is disabled", "description": "Annotations added to the dashboard",
"args": [ "args": [
{ {
"name": "from", "name": "from",
......
...@@ -28,8 +28,6 @@ module API ...@@ -28,8 +28,6 @@ module API
post ':id/metrics_dashboard/annotations' do post ':id/metrics_dashboard/annotations' do
annotations_source_object = annotations_source[:class].find(params[:id]) annotations_source_object = annotations_source[:class].find(params[:id])
not_found! unless Feature.enabled?(:metrics_dashboard_annotations, annotations_source_object.project)
forbidden! unless can?(current_user, :create_metrics_dashboard_annotation, annotations_source_object) forbidden! unless can?(current_user, :create_metrics_dashboard_annotation, annotations_source_object)
create_service_params = declared(params).merge(annotations_source[:create_service_param_key] => annotations_source_object) create_service_params = declared(params).merge(annotations_source[:create_service_param_key] => annotations_source_object)
......
...@@ -97,7 +97,11 @@ describe('Monitoring store actions', () => { ...@@ -97,7 +97,11 @@ describe('Monitoring store actions', () => {
null, null,
state, state,
[], [],
[{ type: 'fetchEnvironmentsData' }, { type: 'fetchDashboard' }], [
{ type: 'fetchEnvironmentsData' },
{ type: 'fetchDashboard' },
{ type: 'fetchAnnotations' },
],
); );
}); });
......
...@@ -21,6 +21,7 @@ describe 'Getting Metrics Dashboard Annotations' do ...@@ -21,6 +21,7 @@ describe 'Getting Metrics Dashboard Annotations' do
create(:metrics_dashboard_annotation, environment: environment, starting_at: to.advance(minutes: 5), dashboard_path: path) create(:metrics_dashboard_annotation, environment: environment, starting_at: to.advance(minutes: 5), dashboard_path: path)
end end
let(:args) { "from: \"#{from}\", to: \"#{to}\"" }
let(:fields) do let(:fields) do
<<~QUERY <<~QUERY
#{all_graphql_fields_for('MetricsDashboardAnnotation'.classify)} #{all_graphql_fields_for('MetricsDashboardAnnotation'.classify)}
...@@ -47,63 +48,40 @@ describe 'Getting Metrics Dashboard Annotations' do ...@@ -47,63 +48,40 @@ describe 'Getting Metrics Dashboard Annotations' do
) )
end end
context 'feature flag metrics_dashboard_annotations' do before do
let(:args) { "from: \"#{from}\", to: \"#{to}\"" } project.add_developer(current_user)
post_graphql(query, current_user: current_user)
end
before do it_behaves_like 'a working graphql query'
project.add_developer(current_user)
end
context 'is off' do it 'returns annotations' do
before do annotations = graphql_data.dig('project', 'environments', 'nodes')[0].dig('metricsDashboard', 'annotations', 'nodes')
stub_feature_flags(metrics_dashboard_annotations: false)
post_graphql(query, current_user: current_user)
end
it 'returns empty nodes array' do expect(annotations).to match_array [{
annotations = graphql_data.dig('project', 'environments', 'nodes')[0].dig('metricsDashboard', 'annotations', 'nodes') "description" => annotation.description,
"id" => annotation.to_global_id.to_s,
"panelId" => annotation.panel_xid,
"startingAt" => annotation.starting_at.iso8601,
"endingAt" => nil
}]
end
expect(annotations).to be_empty context 'arguments' do
end context 'from is missing' do
end let(:args) { "to: \"#{from}\"" }
context 'is on' do it 'returns error' do
before do
stub_feature_flags(metrics_dashboard_annotations: true)
post_graphql(query, current_user: current_user) post_graphql(query, current_user: current_user)
end
it_behaves_like 'a working graphql query' expect(graphql_errors[0]).to include("message" => "Field 'annotations' is missing required arguments: from")
it 'returns annotations' do
annotations = graphql_data.dig('project', 'environments', 'nodes')[0].dig('metricsDashboard', 'annotations', 'nodes')
expect(annotations).to match_array [{
"description" => annotation.description,
"id" => annotation.to_global_id.to_s,
"panelId" => annotation.panel_xid,
"startingAt" => annotation.starting_at.iso8601,
"endingAt" => nil
}]
end end
end
context 'arguments' do context 'to is missing' do
context 'from is missing' do let(:args) { "from: \"#{from}\"" }
let(:args) { "to: \"#{from}\"" }
it 'returns error' do
post_graphql(query, current_user: current_user)
expect(graphql_errors[0]).to include("message" => "Field 'annotations' is missing required arguments: from")
end
end
context 'to is missing' do
let(:args) { "from: \"#{from}\"" }
it_behaves_like 'a working graphql query' it_behaves_like 'a working graphql query'
end
end
end end
end end
end end
...@@ -19,75 +19,55 @@ describe API::Metrics::Dashboard::Annotations do ...@@ -19,75 +19,55 @@ describe API::Metrics::Dashboard::Annotations do
end end
context "with :source_type == #{source_type.pluralize}" do context "with :source_type == #{source_type.pluralize}" do
context 'feature flag metrics_dashboard_annotations' do context 'with correct permissions' do
context 'is on' do context 'with valid parameters' do
before do it 'creates a new annotation', :aggregate_failures do
stub_feature_flags(metrics_dashboard_annotations: { enabled: true, thing: project }) post api(url, user), params: params
end
context 'with correct permissions' do expect(response).to have_gitlab_http_status(:created)
context 'with valid parameters' do expect(json_response["#{source_type}_id"]).to eq(source.id)
it 'creates a new annotation', :aggregate_failures do expect(json_response['starting_at'].to_time).to eq(starting_at.to_time)
post api(url, user), params: params expect(json_response['ending_at'].to_time).to eq(ending_at.to_time)
expect(json_response['description']).to eq(params[:description])
expect(response).to have_gitlab_http_status(:created) expect(json_response['dashboard_path']).to eq(dashboard)
expect(json_response["#{source_type}_id"]).to eq(source.id)
expect(json_response['starting_at'].to_time).to eq(starting_at.to_time)
expect(json_response['ending_at'].to_time).to eq(ending_at.to_time)
expect(json_response['description']).to eq(params[:description])
expect(json_response['dashboard_path']).to eq(dashboard)
end
end
context 'with invalid parameters' do
it 'returns error messsage' do
post api(url, user), params: { dashboard_path: nil, starting_at: nil, description: nil }
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']).to include({ "starting_at" => ["can't be blank"], "description" => ["can't be blank"], "dashboard_path" => ["can't be blank"] })
end
end
context 'with undeclared params' do
before do
params[:undeclared_param] = 'xyz'
end
it 'filters out undeclared params' do
expect(::Metrics::Dashboard::Annotations::CreateService).to receive(:new).with(user, hash_excluding(:undeclared_param))
post api(url, user), params: params
end
end
end end
end
context 'without correct permissions' do context 'with invalid parameters' do
let_it_be(:guest) { create(:user) } it 'returns error messsage' do
post api(url, user), params: { dashboard_path: nil, starting_at: nil, description: nil }
before do
project.add_guest(guest)
end
it 'returns error messsage' do
post api(url, guest), params: params
expect(response).to have_gitlab_http_status(:forbidden) expect(response).to have_gitlab_http_status(:bad_request)
end expect(json_response['message']).to include({ "starting_at" => ["can't be blank"], "description" => ["can't be blank"], "dashboard_path" => ["can't be blank"] })
end end
end end
context 'is off' do context 'with undeclared params' do
before do before do
stub_feature_flags(metrics_dashboard_annotations: { enabled: false }) params[:undeclared_param] = 'xyz'
end end
it 'returns error messsage' do it 'filters out undeclared params' do
post api(url, user), params: params expect(::Metrics::Dashboard::Annotations::CreateService).to receive(:new).with(user, hash_excluding(:undeclared_param))
expect(response).to have_gitlab_http_status(:not_found) post api(url, user), params: params
end end
end end
end end
context 'without correct permissions' do
let_it_be(:guest) { create(:user) }
before do
project.add_guest(guest)
end
it 'returns error message' do
post api(url, guest), params: params
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end end
end end
......
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