Skip to content

Send callback requests to Rails

Ravi Kumar requested to merge 25-send-callback-requests-to-rails into main

What does this MR do and why?

Send the callback to Rails on indexing. In addition to that rename the DiskStatus to DiskStats

How to set up and validate locally

  • Run indexer in GDK mode
  • Open the rails console
bundle exec rails c
  • Setup Zoekt for a namespace
::Feature.enable(:index_code_with_zoekt)
::Feature.enable(:search_code_with_zoekt)
zoekt_node = ::Search::Zoekt::Node.find_or_create_by!(index_base_url: 'http://127.0.0.1:6080/', search_base_url: 'http://127.0.0.1:6090/', uuid: '00000000-0000-0000-0000-000000000000')
namespace = Namespace.find_by_full_path("flightjs") # Some namespace you want to enable
::Zoekt::IndexedNamespace.find_or_create_by!(node: zoekt_node, namespace: namespace.root_ancestor)
  • Add Callback in the request
diff --git a/ee/lib/gitlab/search/zoekt/client.rb b/ee/lib/gitlab/search/zoekt/client.rb
index 85d881f81530..4f0550a8a395 100644
--- a/ee/lib/gitlab/search/zoekt/client.rb
+++ b/ee/lib/gitlab/search/zoekt/client.rb
@@ -153,7 +153,11 @@ def indexing_payload(project, force:)
             },
             RepoId: project.id,
             FileSizeLimit: Gitlab::CurrentSettings.elasticsearch_indexed_file_size_limit_kb.kilobytes,
-            Timeout: "#{INDEXING_TIMEOUT_S}s"
+            Timeout: "#{INDEXING_TIMEOUT_S}s",
+            Callback: {
+              name: 'index',
+              payload: {}
+            }
           }
 
           payload[:Force] = force if force
  • Run the Zoekt indexer
Zoekt::IndexerWorker.new.perform(namespace.id)
  • Tail the log file log/api_json.log
tail -f log/api_json.log
  • You must see in your log something like this:
{"time":"2023-12-07T13:04:38.072Z","severity":"INFO","duration_s":0.00052,"db_duration_s":0.0,"view_duration_s":0.00052,"status":415,"method":"POST","path":"/api/v4/internal/search/zoekt/ee43cf9f-093c-4606-92d9-0f6703434b51/callback","params":[{"key":"{\"name\":\"index\",\"payload\":{\"index_file_count\":2,\"size_in_bytes\":1165580},\"success\":true}","value":null}],"host":"localhost","remote_ip":"127.0.0.1","ua":"Go-http-client/1.1","route":"/api/:version/internal/search/zoekt/:uuid/callback","queue_duration_s":0.014746,"redis_calls":6,"redis_duration_s":0.000586,"redis_read_bytes":1189,"redis_write_bytes":385,"redis_feature_flag_calls":6,"redis_feature_flag_duration_s":0.000586,"redis_feature_flag_read_bytes":1189,"redis_feature_flag_write_bytes":385,"db_count":1,"db_write_count":0,"db_cached_count":0,"db_replica_count":0,"db_primary_count":1,"db_main_count":1,"db_ci_count":0,"db_main_replica_count":0,"db_ci_replica_count":0,"db_replica_cached_count":0,"db_primary_cached_count":0,"db_main_cached_count":0,"db_ci_cached_count":0,"db_main_replica_cached_count":0,"db_ci_replica_cached_count":0,"db_replica_wal_count":0,"db_primary_wal_count":0,"db_main_wal_count":0,"db_ci_wal_count":0,"db_main_replica_wal_count":0,"db_ci_replica_wal_count":0,"db_replica_wal_cached_count":0,"db_primary_wal_cached_count":0,"db_main_wal_cached_count":0,"db_ci_wal_cached_count":0,"db_main_replica_wal_cached_count":0,"db_ci_replica_wal_cached_count":0,"db_replica_duration_s":0.0,"db_primary_duration_s":0.003,"db_main_duration_s":0.003,"db_ci_duration_s":0.0,"db_main_replica_duration_s":0.0,"db_ci_replica_duration_s":0.0,"cpu_s":0.013248,"pid":59451,"worker_id":"puma_0","rate_limiting_gates":[],"correlation_id":"01HH262MN4YP1K14E37VATJ179","meta.remote_ip":"127.0.0.1","meta.client_id":"ip/127.0.0.1","content_length":"88","request_urgency":"medium","target_duration_s":0.5}

Closes #25 (closed)

Edited by Ravi Kumar

Merge request reports

Loading