Skip to content
Snippets Groups Projects
Commit ee973e1e authored by Ravi Kumar's avatar Ravi Kumar
Browse files

Remove the FF zoekt_initial_indexing_task

This FF is enabled and working fine. So, the code related to this
FF can be removed.

Changelog: other
MR: !170274
EE: true
parent f763d671
No related branches found
No related tags found
1 merge request!170274Remove feature flag zoekt_initial_indexing_task
......@@ -113,7 +113,6 @@ Gitlab/FeatureFlagWithoutActor:
- 'ee/app/services/phone_verification/telesign_client/risk_score_service.rb'
- 'ee/app/services/phone_verification/users/rate_limit_service.rb'
- 'ee/app/services/phone_verification/users/send_verification_code_service.rb'
- 'ee/app/services/search/zoekt/scheduling_service.rb'
- 'ee/app/views/admin/application_settings/_ee_package_registry.haml'
- 'ee/app/views/admin/application_settings/_elasticsearch_form.html.haml'
- 'ee/app/views/admin/application_settings/_git_two_factor_session_expiry.html.haml'
......
......@@ -125,7 +125,6 @@ Rails/Date:
- 'ee/spec/services/personal_access_tokens/create_service_audit_log_spec.rb'
- 'ee/spec/services/projects/update_service_spec.rb'
- 'ee/spec/services/search/elastic/destroy_expired_subscription_service_spec.rb'
- 'ee/spec/services/search/zoekt/scheduling_service_spec.rb'
- 'ee/spec/services/timebox/event_aggregation_service_spec.rb'
- 'ee/spec/services/timebox_report_service_spec.rb'
- 'ee/spec/support/shared_examples/requests/api/graphql/issue_list_shared_examples.rb'
......
......@@ -515,7 +515,6 @@ RSpec/BeEq:
- 'ee/spec/services/search/project_service_spec.rb'
- 'ee/spec/services/search/rake_task_executor_service_spec.rb'
- 'ee/spec/services/search/zoekt/indexing_task_service_spec.rb'
- 'ee/spec/services/search/zoekt/scheduling_service_spec.rb'
- 'ee/spec/services/security/configuration/project_set_continuous_vulnerability_scanning_service_spec.rb'
- 'ee/spec/services/security/orchestration/create_bot_service_spec.rb'
- 'ee/spec/services/security/scan_result_policies/generate_policy_violation_comment_service_spec.rb'
......
......@@ -32,7 +32,6 @@ RSpec/RepeatedSubjectCall:
- 'ee/spec/services/sbom/ingestion/tasks/ingest_components_spec.rb'
- 'ee/spec/services/sbom/ingestion/tasks/ingest_occurrences_spec.rb'
- 'ee/spec/services/sbom/ingestion/tasks/ingest_sources_spec.rb'
- 'ee/spec/services/search/zoekt/scheduling_service_spec.rb'
- 'ee/spec/services/security/orchestration/assign_service_spec.rb'
- 'ee/spec/workers/namespaces/cascade_duo_features_enabled_worker_spec.rb'
- 'ee/spec/workers/search/zoekt/lost_node_event_worker_spec.rb'
......
......@@ -73,7 +73,6 @@ RSpec/VerifiedDoubleReference:
- 'ee/spec/services/sbom/ingestion/ingest_reports_service_spec.rb'
- 'ee/spec/services/sbom/ingestion/tasks/base_spec.rb'
- 'ee/spec/services/search/rake_task_executor_service_spec.rb'
- 'ee/spec/services/search/zoekt/scheduling_service_spec.rb'
- 'ee/spec/services/security/findings/dismiss_service_spec.rb'
- 'ee/spec/services/security/scan_result_policies/update_license_approvals_service_spec.rb'
- 'ee/spec/services/vulnerabilities/findings/find_or_create_from_security_finding_service_spec.rb'
......
......@@ -19,7 +19,6 @@ class Index < ApplicationRecord
has_many :zoekt_repositories, foreign_key: :zoekt_index_id, inverse_of: :zoekt_index,
class_name: '::Search::Zoekt::Repository'
after_commit :index, on: :create
after_commit :delete_from_index, on: :destroy
enum state: {
......@@ -116,12 +115,6 @@ def free_storage_bytes
private
def index
return if Feature.enabled?(:zoekt_initial_indexing_task, Feature.current_request)
::Search::Zoekt::NamespaceIndexerWorker.perform_async(zoekt_enabled_namespace.root_namespace_id, :index)
end
def delete_from_index
::Search::Zoekt::NamespaceIndexerWorker.perform_async(namespace_id, :delete, zoekt_node_id)
end
......
......@@ -85,7 +85,7 @@ def info(task, **payload)
# An initial implementation of eviction logic. For now, it's a .com-only task
def eviction
return false unless ::Gitlab::Saas.feature_available?(:exact_code_search)
return false if Feature.disabled?(:zoekt_reallocation_task)
return false if Feature.disabled?(:zoekt_reallocation_task, Feature.current_request)
execute_every 5.minutes, cache_key: :eviction do
nodes = ::Search::Zoekt::Node.online.find_each.to_a
......@@ -157,7 +157,7 @@ def unassign_namespaces_from_node(node, namespaces_to_move, node_original_used_b
# rubocop:disable CodeReuse/ActiveRecord -- this is a temporary task, which will be removed after the rollout
def dot_com_rollout
return false unless ::Gitlab::Saas.feature_available?(:exact_code_search)
return false if Feature.disabled?(:zoekt_dot_com_rollout)
return false if Feature.disabled?(:zoekt_dot_com_rollout, Feature.current_request)
search_enabled_count = Search::Zoekt::EnabledNamespace.with_all_ready_indices
.where(search: false, created_at: ..DOT_COM_ROLLOUT_ENABLE_SEARCH_AFTER.ago)
......@@ -252,7 +252,7 @@ def node_assignment
replica: Replica.for_enabled_namespace!(zoekt_enabled_namespace),
reserved_storage_bytes: space_required
)
zoekt_index.state = :ready if Feature.disabled?(:zoekt_initial_indexing_task) || space_required == 0
zoekt_index.state = :ready if space_required == 0
zoekt_indices << zoekt_index
node.used_bytes += space_required
else
......@@ -295,8 +295,6 @@ def mark_indices_as_ready
end
def initial_indexing
return false if Feature.disabled?(:zoekt_initial_indexing_task)
execute_every 10.minutes, cache_key: :initial_indexing do
Index.pending.find_each do |index|
Gitlab::EventStore.publish(InitialIndexingEvent.new(data: { index_id: index.id }))
......@@ -318,7 +316,7 @@ def auto_index_self_managed
end
def update_replica_states
return false if Feature.disabled?(:zoekt_replica_state_updates)
return false if Feature.disabled?(:zoekt_replica_state_updates, Feature.current_request)
execute_every 2.minutes, cache_key: :update_replica_states do
ReplicaStateService.execute
......
---
name: zoekt_initial_indexing_task
feature_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/442883
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/149365
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/463049
milestone: '17.1'
group: group::global search
type: ops
default_enabled: false
......@@ -44,46 +44,12 @@
end
describe 'callbacks' do
let_it_be(:namespace_2) { create(:group) }
let_it_be(:another_enabled_namespace) { create(:zoekt_enabled_namespace, namespace: namespace_2) }
describe '#create!' do
context 'when feature flag zoekt_initial_indexing_task is disabled' do
before do
stub_feature_flags(zoekt_initial_indexing_task: false)
end
it 'triggers indexing for the namespace' do
expect(::Search::Zoekt::NamespaceIndexerWorker).to receive(:perform_async)
.with(another_enabled_namespace.root_namespace_id, :index)
another_replica = create(:zoekt_replica, zoekt_enabled_namespace: another_enabled_namespace)
described_class.create!(zoekt_enabled_namespace: another_enabled_namespace, node: zoekt_node,
namespace_id: another_enabled_namespace.root_namespace_id, replica: another_replica)
end
end
it 'does not triggers indexing for the namespace' do
expect(::Search::Zoekt::NamespaceIndexerWorker).not_to receive(:perform_async)
.with(another_enabled_namespace.root_namespace_id, :index)
another_replica = create(:zoekt_replica, zoekt_enabled_namespace: another_enabled_namespace)
described_class.create!(zoekt_enabled_namespace: another_enabled_namespace, node: zoekt_node,
namespace_id: another_enabled_namespace.root_namespace_id, replica: another_replica)
end
end
describe '#destroy!' do
it 'removes index for the namespace' do
another_zoekt_index = create(:zoekt_index, zoekt_enabled_namespace: another_enabled_namespace,
namespace_id: another_enabled_namespace.root_namespace_id)
expect(::Search::Zoekt::NamespaceIndexerWorker).to receive(:perform_async)
.with(another_enabled_namespace.root_namespace_id, :delete, another_zoekt_index.zoekt_node_id)
it 'calls Search::Zoekt::NamespaceIndexerWorker for the namespace with delete operation' do
expect(Search::Zoekt::NamespaceIndexerWorker).to receive(:perform_async)
.with(zoekt_enabled_namespace.root_namespace_id, :delete, zoekt_node.id)
another_zoekt_index.destroy!
zoekt_index.destroy!
end
end
end
......
......@@ -3,7 +3,7 @@
require 'spec_helper'
RSpec.describe ::Search::Zoekt::SchedulingService, :clean_gitlab_redis_shared_state, feature_category: :global_search do
let(:logger) { instance_double('Logger') }
let(:logger) { instance_double(Logger) }
let(:service) { described_class.new(task.to_s) }
let_it_be_with_reload(:node) { create(:zoekt_node, :enough_free_space) }
......@@ -100,7 +100,7 @@
end
it 'returns false unless saas' do
expect(execute_task).to eq(false)
expect(execute_task).to be(false)
end
context 'when on .com', :saas do
......@@ -144,7 +144,7 @@
)
expect { execute_task }.to change { Search::Zoekt::Index.pending_deletion.count }.from(0).to(1)
expect(zoekt_index2.zoekt_enabled_namespace.reload.search).to eq(false)
expect(zoekt_index2.zoekt_enabled_namespace.reload.search).to be(false)
end
end
......@@ -156,7 +156,7 @@
let(:task) { :dot_com_rollout }
it 'returns false unless saas' do
expect(execute_task).to eq(false)
expect(execute_task).to be(false)
end
context 'when on .com', :saas do
......@@ -172,9 +172,8 @@
created_at: rollout_cutoff, updated_at: rollout_cutoff)
create(:zoekt_index, :ready, zoekt_enabled_namespace: ns_1)
ns_2 = create(:zoekt_enabled_namespace, search: false)
expect { execute_task }.to change { ns_1.reload.search }.from(false).to(true)
expect { execute_task }.not_to change { ns_2.reload.search }.from(false)
expect(ns_1.reload.search).to be true
end
context 'when feature flag is disabled' do
......@@ -185,7 +184,7 @@
it 'returns false' do
create(:zoekt_enabled_namespace)
expect(execute_task).to eq(false)
expect(execute_task).to be(false)
end
end
......@@ -254,11 +253,11 @@
let(:task) { :remove_expired_subscriptions }
it 'returns false unless saas' do
expect(execute_task).to eq(false)
expect(execute_task).to be(false)
end
context 'when on .com', :saas do
let_it_be(:expiration_date) { Date.today - Search::Zoekt::EXPIRED_SUBSCRIPTION_GRACE_PERIOD }
let_it_be(:expiration_date) { Time.zone.today - Search::Zoekt::EXPIRED_SUBSCRIPTION_GRACE_PERIOD }
let_it_be(:zkt_enabled_namespace) { create(:zoekt_enabled_namespace) }
let_it_be(:zkt_enabled_namespace2) { create(:zoekt_enabled_namespace) }
let_it_be(:subscription) { create(:gitlab_subscription, namespace: zkt_enabled_namespace2.namespace) }
......@@ -289,7 +288,7 @@
end
it 'returns false' do
expect(execute_task).to eq(false)
expect(execute_task).to be(false)
end
end
......@@ -312,7 +311,7 @@
end
it 'returns false and does nothing' do
expect(execute_task).to eq(false)
expect(execute_task).to be(false)
expect(Search::Zoekt::EnabledNamespace).not_to receive(:with_missing_indices)
end
end
......@@ -432,26 +431,6 @@
end
end
context 'when feature flag zoekt_initial_indexing_task is disabled' do
before do
stub_feature_flags(zoekt_initial_indexing_task: false)
end
it 'creates a record of Search::Zoekt::Index with state ready' do
expect(zkt_enabled_namespace.indices).to be_empty
expect(zkt_enabled_namespace2.indices).to be_empty
expect(Search::Zoekt::Node).to receive(:online).and_call_original
expect(logger).to receive(:error).with({ 'class' => described_class.to_s, 'task' => task,
'message' => "RootStorageStatistics isn't available",
'zoekt_enabled_namespace_id' => zkt_enabled_namespace.id }
)
expect { execute_task }.to change { Search::Zoekt::Index.count }.by(1)
expect(zkt_enabled_namespace.indices).to be_empty
index = zkt_enabled_namespace2.indices.last
expect(index).to be_ready
end
end
it 'assigns the index to a replica' do
expect(zkt_enabled_namespace.indices).to be_empty
expect(zkt_enabled_namespace2.indices).to be_empty
......@@ -508,16 +487,6 @@
let(:task) { :initial_indexing }
let_it_be_with_reload(:index) { create(:zoekt_index, state: :pending) }
context 'when feature flag zoekt_initial_indexing_task is disabled' do
before do
stub_feature_flags(zoekt_initial_indexing_task: false)
end
it 'returns false' do
expect(execute_task).to eq(false)
end
end
context 'when there are no zoekt_indices in pending state' do
before do
Search::Zoekt::Index.update_all(state: :initializing)
......@@ -585,7 +554,7 @@
it 'returns false and does not do anything' do
expect(::Search::Zoekt::ReplicaStateService).not_to receive(:execute)
expect(execute_task).to eq(false)
expect(execute_task).to be(false)
end
end
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment