Add chatops command to override number of zoekt replicas
Closes gitlab-org/gitlab#565782 (closed)
AI Summary
This change adds a new chat command called
enabled_namespacethat allows administrators to manage replica settings for Zoekt search namespaces. The new command lets users set or clear the number of replicas (copies) for a specific namespace by providing either a namespace ID or group path, which helps control search performance and availability. The implementation includes proper error handling for invalid inputs and comprehensive tests to ensure the feature works correctly in various scenarios.
How to validate locally
- Setup local GDK with Zoekt following https://gitlab.com/gitlab-org/gitlab-development-kit/-/blob/main/doc/howto/zoekt.md
- Hack your local chatops to use 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"
- Set an override for a namespace
GITLAB_TOKEN=$GITLAB_TEST_TOKEN CHAT_INPUT='enabled_namespace set_replicas gitlab-org 1' bundle exec ./bin/chatops zoekt
- Verify that the override was made in gdk rails console
Namespace.find_by_full_path("gitlab-org").zoekt_enabled_namespace.number_of_replicas_override
- Remove the override for namespace by setting to
nil
GITLAB_TOKEN=$GITLAB_TEST_TOKEN CHAT_INPUT='enabled_namespace set_replicas gitlab-org nil' bundle exec ./bin/chatops zoekt
- Verify that the override was removed in gdk rails console
Namespace.find_by_full_path("gitlab-org").zoekt_enabled_namespace.number_of_replicas_override