Commit ef88f5c5 authored by Hordur Freyr Yngvason's avatar Hordur Freyr Yngvason Committed by Kerri Miller

Put deprecated serverless features behind feature flag

The flag is enabled by default, but can be switched off immediately to
hide the feature.

See https://gitlab.com/gitlab-org/gitlab/-/issues/352753

Changelog: changed
parent 590b2ee3
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
module Projects module Projects
module Serverless module Serverless
class FunctionsController < Projects::ApplicationController class FunctionsController < Projects::ApplicationController
before_action :ensure_feature_enabled!
before_action :authorize_read_cluster! before_action :authorize_read_cluster!
feature_category :not_owned feature_category :not_owned
...@@ -69,6 +70,10 @@ module Projects ...@@ -69,6 +70,10 @@ module Projects
def serialize_function(function) def serialize_function(function)
Projects::Serverless::ServiceSerializer.new(current_user: @current_user, project: project).represent(function) Projects::Serverless::ServiceSerializer.new(current_user: @current_user, project: project).represent(function)
end end
def ensure_feature_enabled!
render_404 unless Feature.enabled?(:deprecated_serverless, project, default_enabled: :yaml, type: :ops)
end
end end
end end
end end
---
name: deprecated_serverless
introduced_by_url: 'https://gitlab.com/gitlab-org/gitlab/-/merge_requests/81493'
rollout_issue_url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/353901'
milestone: '14.9'
type: ops
group: 'group::configure'
default_enabled: true
...@@ -64,7 +64,7 @@ module Sidebars ...@@ -64,7 +64,7 @@ module Sidebars
end end
def serverless_menu_item def serverless_menu_item
unless can?(context.current_user, :read_cluster, context.project) unless Feature.enabled?(:deprecated_serverless, context.project, default_enabled: :yaml, type: :ops) && can?(context.current_user, :read_cluster, context.project)
return ::Sidebars::NilMenuItem.new(item_id: :serverless) return ::Sidebars::NilMenuItem.new(item_id: :serverless)
end end
......
...@@ -39,9 +39,24 @@ RSpec.describe Projects::Serverless::FunctionsController do ...@@ -39,9 +39,24 @@ RSpec.describe Projects::Serverless::FunctionsController do
project_id: project.to_param) project_id: project.to_param)
end end
shared_examples_for 'behind :deprecated_serverless feature flag' do
before do
stub_feature_flags(deprecated_serverless: false)
end
it 'returns 404' do
action
expect(response).to have_gitlab_http_status(:not_found)
end
end
describe 'GET #index' do describe 'GET #index' do
let(:expected_json) { { 'knative_installed' => knative_state, 'functions' => functions } } let(:expected_json) { { 'knative_installed' => knative_state, 'functions' => functions } }
it_behaves_like 'behind :deprecated_serverless feature flag' do
let(:action) { get :index, params: params({ format: :json }) }
end
context 'when cache is being read' do context 'when cache is being read' do
let(:knative_state) { 'checking' } let(:knative_state) { 'checking' }
let(:functions) { [] } let(:functions) { [] }
...@@ -147,6 +162,10 @@ RSpec.describe Projects::Serverless::FunctionsController do ...@@ -147,6 +162,10 @@ RSpec.describe Projects::Serverless::FunctionsController do
end end
describe 'GET #show' do describe 'GET #show' do
it_behaves_like 'behind :deprecated_serverless feature flag' do
let(:action) { get :show, params: params({ format: :json, environment_id: "*", id: "foo" }) }
end
context 'with function that does not exist' do context 'with function that does not exist' do
it 'returns 404' do it 'returns 404' do
get :show, params: params({ format: :json, environment_id: "*", id: "foo" }) get :show, params: params({ format: :json, environment_id: "*", id: "foo" })
...@@ -239,6 +258,10 @@ RSpec.describe Projects::Serverless::FunctionsController do ...@@ -239,6 +258,10 @@ RSpec.describe Projects::Serverless::FunctionsController do
end end
describe 'GET #metrics' do describe 'GET #metrics' do
it_behaves_like 'behind :deprecated_serverless feature flag' do
let(:action) { get :metrics, params: params({ format: :json, environment_id: "*", id: "foo" }) }
end
context 'invalid data' do context 'invalid data' do
it 'has a bad function name' do it 'has a bad function name' do
get :metrics, params: params({ format: :json, environment_id: "*", id: "foo" }) get :metrics, params: params({ format: :json, environment_id: "*", id: "foo" })
......
...@@ -92,6 +92,14 @@ RSpec.describe Sidebars::Projects::Menus::InfrastructureMenu do ...@@ -92,6 +92,14 @@ RSpec.describe Sidebars::Projects::Menus::InfrastructureMenu do
let(:item_id) { :serverless } let(:item_id) { :serverless }
it_behaves_like 'access rights checks' it_behaves_like 'access rights checks'
context 'when feature :deprecated_serverless is disabled' do
before do
stub_feature_flags(deprecated_serverless: false)
end
it { is_expected.to be_nil }
end
end end
describe 'Terraform' do describe 'Terraform' do
......
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