Commit dfdf249c authored by Tiger's avatar Tiger

Remove kubernetes_agent_on_gitlab_com feature flag

https://gitlab.com/gitlab-org/gitlab/-/merge_requests/60081

Changelog: added
parent e830cace
---
name: kubernetes_agent_on_gitlab_com
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/53322
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/300960
milestone: '13.9'
type: development
group: group::configure
default_enabled: false
......@@ -6,13 +6,7 @@ module EE
override :display_cluster_agents?
def display_cluster_agents?(clusterable)
clusterable.is_a?(Project) && clusterable.feature_available?(:cluster_agents) && included_in_gitlab_com_rollout?(clusterable)
end
private
def included_in_gitlab_com_rollout?(project)
::Gitlab::Kas.included_in_gitlab_com_rollout?(project)
clusterable.is_a?(Project) && clusterable.feature_available?(:cluster_agents)
end
end
end
......@@ -4,7 +4,6 @@ module Clusters
module Agents
class CreateService < BaseService
def execute(name:)
return error_rollout_gitlab_com unless included_in_gitlab_com_rollout?
return error_not_premium_plan unless project.feature_available?(:cluster_agents)
return error_no_permissions unless cluster_agent_permissions?
......@@ -19,14 +18,6 @@ module Clusters
private
def included_in_gitlab_com_rollout?
Gitlab::Kas.included_in_gitlab_com_rollout?(project)
end
def error_rollout_gitlab_com
error(s_('ClusterAgent|This project is not included in the GitLab.com rollout for Kubernetes agent'))
end
def cluster_agent_permissions?
current_user.can?(:admin_pipeline, project) && current_user.can?(:create_cluster, project)
end
......
......@@ -34,32 +34,6 @@ RSpec.describe ClustersHelper do
expect(subject).to be_falsey
end
end
context 'GitLab.com' do
before do
allow(Gitlab).to receive(:com?).and_return(true)
end
context 'when kubernetes_agent_on_gitlab_com feature flag is disabled' do
before do
stub_feature_flags(kubernetes_agent_on_gitlab_com: false)
end
it 'does not allows agents to display' do
expect(subject).to be_falsey
end
end
context 'kubernetes_agent_on_gitlab_com feature flag enabled' do
before do
stub_feature_flags(kubernetes_agent_on_gitlab_com: clusterable)
end
it 'allows agents to display' do
expect(subject).to be_truthy
end
end
end
end
end
end
......@@ -77,36 +77,6 @@ RSpec.describe API::Internal::Kubernetes do
expect(response).to have_gitlab_http_status(:success)
end
context 'on GitLab.com' do
before do
allow(::Gitlab).to receive(:com?).and_return(true)
end
context 'kubernetes_agent_on_gitlab_com feature flag disabled' do
before do
stub_feature_flags(kubernetes_agent_on_gitlab_com: false)
end
it 'returns 403' do
send_request(params: payload, headers: { 'Authorization' => "Bearer #{agent_token.token}" })
expect(response).to have_gitlab_http_status(:forbidden)
end
end
context 'kubernetes_agent_on_gitlab_com feature flag enabled' do
before do
stub_feature_flags(kubernetes_agent_on_gitlab_com: agent_token.agent.project)
end
it 'returns success' do
send_request(params: { alert: payload }, headers: { 'Authorization' => "Bearer #{agent_token.token}" })
expect(response).to have_gitlab_http_status(:success)
end
end
end
context 'when payload is invalid' do
let(:payload) { { temp: {} } }
......
......@@ -66,57 +66,6 @@ RSpec.describe Clusters::Agents::CreateService do
message: ["Name can contain only lowercase letters, digits, and '-', but cannot start or end with '-'"]
})
end
context 'not on GitLab.com' do
before do
allow(::Gitlab).to receive(:com?).and_return(false)
end
context 'kubernetes_agent_on_gitlab_com feature flag disabled' do
before do
stub_feature_flags(kubernetes_agent_on_gitlab_com: project)
end
it 'returns success status', :aggregate_failures do
result = service.execute(name: 'success')
expect(result[:status]).to eq(:success)
expect(result[:message]).to be_nil
end
end
end
context 'on GitLab.com' do
before do
allow(::Gitlab).to receive(:com?).and_return(true)
end
context 'kubernetes_agent_on_gitlab_com feature flag disabled' do
before do
stub_feature_flags(kubernetes_agent_on_gitlab_com: false)
end
it 'returns errors when project is not in rollout' do
expect(service.execute(name: 'not-in-rollout')).to eq({
status: :error,
message: 'This project is not included in the GitLab.com rollout for Kubernetes agent'
})
end
end
context 'kubernetes_agent_on_gitlab_com feature flag enabled' do
before do
stub_feature_flags(kubernetes_agent_on_gitlab_com: project)
end
it 'returns success status', :aggregate_failures do
result = service.execute(name: 'success')
expect(result[:status]).to eq(:success)
expect(result[:message]).to be_nil
end
end
end
end
end
end
......@@ -53,8 +53,6 @@ module API
def check_agent_token
unauthorized! unless agent_token
forbidden! unless Gitlab::Kas.included_in_gitlab_com_rollout?(agent.project)
agent_token.track_usage
end
end
......
......@@ -25,12 +25,6 @@ module Gitlab
write_secret
end
def included_in_gitlab_com_rollout?(project)
return true unless ::Gitlab.com?
Feature.enabled?(:kubernetes_agent_on_gitlab_com, project, default_enabled: :yaml)
end
# Return GitLab KAS version
#
# @return [String] version
......
......@@ -6934,9 +6934,6 @@ msgstr ""
msgid "ClusterAgent|This feature is only available for premium plans"
msgstr ""
msgid "ClusterAgent|This project is not included in the GitLab.com rollout for Kubernetes agent"
msgstr ""
msgid "ClusterAgent|User has insufficient permissions to create a token for this project"
msgstr ""
......
......@@ -104,48 +104,4 @@ RSpec.describe Gitlab::Kas do
end
end
end
describe '.included_in_gitlab_com_rollout?' do
let_it_be(:project) { create(:project) }
context 'not GitLab.com' do
before do
allow(Gitlab).to receive(:com?).and_return(false)
end
it 'returns true' do
expect(described_class.included_in_gitlab_com_rollout?(project)).to be_truthy
end
end
context 'GitLab.com' do
before do
allow(Gitlab).to receive(:com?).and_return(true)
end
context 'kubernetes_agent_on_gitlab_com feature flag disabled' do
before do
stub_feature_flags(kubernetes_agent_on_gitlab_com: false)
end
it 'returns false' do
expect(described_class.included_in_gitlab_com_rollout?(project)).to be_falsey
end
end
context 'kubernetes_agent_on_gitlab_com feature flag enabled' do
before do
stub_feature_flags(kubernetes_agent_on_gitlab_com: project)
end
it 'returns true' do
expect(described_class.included_in_gitlab_com_rollout?(project)).to be_truthy
end
it 'returns false for another project' do
expect(described_class.included_in_gitlab_com_rollout?(create(:project))).to be_falsey
end
end
end
end
end
......@@ -133,36 +133,6 @@ RSpec.describe API::Internal::Kubernetes do
)
)
end
context 'on GitLab.com' do
before do
allow(::Gitlab).to receive(:com?).and_return(true)
end
context 'kubernetes_agent_on_gitlab_com feature flag disabled' do
before do
stub_feature_flags(kubernetes_agent_on_gitlab_com: false)
end
it 'returns 403' do
send_request(headers: { 'Authorization' => "Bearer #{agent_token.token}" })
expect(response).to have_gitlab_http_status(:forbidden)
end
end
context 'kubernetes_agent_on_gitlab_com feature flag enabled' do
before do
stub_feature_flags(kubernetes_agent_on_gitlab_com: agent_token.agent.project)
end
it 'returns success' do
send_request(headers: { 'Authorization' => "Bearer #{agent_token.token}" })
expect(response).to have_gitlab_http_status(:success)
end
end
end
end
end
......@@ -214,36 +184,6 @@ RSpec.describe API::Internal::Kubernetes do
expect(response).to have_gitlab_http_status(:not_found)
end
end
context 'on GitLab.com' do
before do
allow(::Gitlab).to receive(:com?).and_return(true)
end
context 'kubernetes_agent_on_gitlab_com feature flag disabled' do
before do
stub_feature_flags(kubernetes_agent_on_gitlab_com: false)
end
it 'returns 403' do
send_request(params: { id: project.id }, headers: { 'Authorization' => "Bearer #{agent_token.token}" })
expect(response).to have_gitlab_http_status(:forbidden)
end
end
context 'kubernetes_agent_on_gitlab_com feature flag enabled' do
before do
stub_feature_flags(kubernetes_agent_on_gitlab_com: agent_token.agent.project)
end
it 'returns success' do
send_request(params: { id: project.id }, headers: { 'Authorization' => "Bearer #{agent_token.token}" })
expect(response).to have_gitlab_http_status(:success)
end
end
end
end
context 'project is private' 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