Skip to content
Snippets Groups Projects

chatops commands for Zoekt

Merged Dylan Griffith requested to merge 404534-chatops-commands-for-zoekt into master
All threads resolved!

In gitlab-org/gitlab!116650 (merged) we added some admin APIs that will be used during our production rollout of Zoekt. This MR makes just 2 of these endpoints accessible in chatops as these are the ones that require write access. The other data can be easily accessed from read-only consoles if needed. We may consider exposing those via chatops eventually but for now these are the ones we need to move the rollout forward.

Resolves gitlab-org/gitlab#404534 (closed)

How to test

  1. Setup local GDK with Zoekt following https://gitlab.com/gitlab-org/gitlab-development-kit/-/blob/main/doc/howto/zoekt.md
  2. Hack your local chatops to point at your local GDK
    diff --git a/lib/chatops/gitlab/client.rb b/lib/chatops/gitlab/client.rb
    index 9e4fa29..f3a0d9f 100644
    --- a/lib/chatops/gitlab/client.rb
    +++ b/lib/chatops/gitlab/client.rb
    @@ -14,7 +14,7 @@ module Chatops
           # token - The API token to use for authentication.
           # host - The hostname to use.
           def initialize(token:, host: DEFAULT_HOST, httparty: {})
    -        endpoint = "https://#{host}/api/v4"
    +        endpoint = "http://127.0.0.1:3000/api/v4"
  3. Go to http://127.0.0.1:3000/toolbox/gitlab-smoke-tests/edit#js-general-project-settings and make this project public
  4. Get the group id of group http://127.0.0.1:3000/toolbox (following steps assume it is 22)
  5. Get the project id of http://127.0.0.1:3000/toolbox/gitlab-smoke-tests (following steps assume it is 1)
  6. Get the id of ::Zoekt::Shard.first (following steps assume it is 1)
  7. Get an API token for your local root user on GDK
  8. Run env GITLAB_TOKEN='the-token' CHAT_INPUT='indexed_namespace_create 1 22' bundle exec ./bin/chatops zoekt
  9. Run `env GITLAB_TOKEN='the-token' CHAT_INPUT='force_index_project 1' bundle exec ./bin/chatops zoekt
  10. Search the project and confirm it's using zkt in the performance bar http://127.0.0.1:3000/search?search=Smok.*est&nav_source=navbar&project_id=1&group_id=22&search_code=true

My testing output

I tested locally and got this output:

16:31:24 dylangriffith@Dylan-GitLab-MBP:~/workspace/gitlab-com/chatops$ env GITLAB_TOKEN='the-token' CHAT_INPUT='indexed_namespace_create 1 22' bundle exec ./bin/chatops zoekt
2023-04-13 16:31:31.897820 I [{:user=>nil}] Chatops -- Command to be executed -- {:name=>"zoekt", :chat_input=>"indexed_namespace_create 1 22", :split_chat_input=>["indexed_namespace_create", "1", "22"]}
2023-04-13 16:31:31.922414 D [{:user=>nil}] Chatops::Gitlab::Client -- [HTTParty] [2023-04-13 16:31:31 +1000] 200 "PUT http://127.0.0.1:3000/api/v4/admin/zoekt/shards/1/indexed_namespaces/22" 45

Successfully created indexed namespace for shard 1 and namespace 22

16:31:31 dylangriffith@Dylan-GitLab-MBP:~/workspace/gitlab-com/chatops$ env GITLAB_TOKEN='the-token' CHAT_INPUT='force_index_project 1' bundle exec ./bin/chatops zoekt
2023-04-13 16:34:08.529529 I [{:user=>nil}] Chatops -- Command to be executed -- {:name=>"zoekt", :chat_input=>"force_index_project 1", :split_chat_input=>["force_index_project", "1"]}
2023-04-13 16:34:08.609893 D [{:user=>nil}] Chatops::Gitlab::Client -- [HTTParty] [2023-04-13 16:34:08 +1000] 200 "PUT http://127.0.0.1:3000/api/v4/admin/zoekt/projects/1/index" 37

Successfully triggered indexing for project 1 with job_id "f259b9636ecb59abf062da8c"
Edited by Dylan Griffith

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Steve Abrams removed review request for @sabrams

    removed review request for @sabrams

  • Dylan Griffith added 1 commit

    added 1 commit

    • 8b653f55 - Chatops commands for rolling out Zoekt

    Compare with previous version

  • Dylan Griffith added 1 commit

    added 1 commit

    • c670bd16 - Chatops commands for rolling out Zoekt

    Compare with previous version

  • Dylan Griffith marked this merge request as ready

    marked this merge request as ready

  • Dylan Griffith requested review from @sabrams

    requested review from @sabrams

  • Steve Abrams requested review from @rpereira2 and removed review request for @sabrams

    requested review from @rpereira2 and removed review request for @sabrams

  • Steve Abrams approved this merge request

    approved this merge request

  • Dylan Griffith added 2 commits

    added 2 commits

    • e00b6387 - 1 commit from branch master
    • ef413497 - Chatops commands for rolling out Zoekt

    Compare with previous version

  • Dylan Griffith added 1 commit

    added 1 commit

    • 2e428cf1 - Chatops commands for rolling out Zoekt

    Compare with previous version

  • Thank you @DylanGriffith I've left a comment

  • Dylan Griffith requested review from @nolith

    requested review from @nolith

  • Thanks for the suggestion @nolith . I applied it. Could you please give another review and merge if you don't have any other concerns :smile:

  • Dylan Griffith removed review request for @rpereira2

    removed review request for @rpereira2

  • Dylan Griffith added 1 commit

    added 1 commit

    • fa6aa098 - Chatops commands for rolling out Zoekt

    Compare with previous version

  • Dylan Griffith resolved all threads

    resolved all threads

  • Alessio Caiazza resolved all threads

    resolved all threads

  • Alessio Caiazza resolved all threads

    resolved all threads

  • Alessio Caiazza resolved all threads

    resolved all threads

  • Alessio Caiazza resolved all threads

    resolved all threads

  • Alessio Caiazza resolved all threads

    resolved all threads

  • mentioned in issue #157 (closed)

  • Alessio Caiazza approved this merge request

    approved this merge request

  • Dylan Griffith mentioned in commit f7370fa8

    mentioned in commit f7370fa8

  • Dylan Griffith mentioned in merge request !369 (merged)

    mentioned in merge request !369 (merged)

  • Please register or sign in to reply
    Loading