From 2f941040d54b1aef0fb6c6700ee06ba8857538d4 Mon Sep 17 00:00:00 2001 From: Michele Cereda Date: Thu, 21 Nov 2024 00:56:34 +0100 Subject: [PATCH] feat(gitlab): enable advanced search with [elastic|open]search --- knowledge base/gitlab/README.md | 2 + snippets/gitlab/commands.fish | 3 ++ snippets/gitlab/package installation.sh | 54 +++++++++++++++++++------ 3 files changed, 47 insertions(+), 12 deletions(-) create mode 100644 snippets/gitlab/commands.fish diff --git a/knowledge base/gitlab/README.md b/knowledge base/gitlab/README.md index c58c7a5..4f6269c 100644 --- a/knowledge base/gitlab/README.md +++ b/knowledge base/gitlab/README.md @@ -731,6 +731,7 @@ Solution: set the correct ownership with - [The GitLab Handbook] - [Icons] - [Upgrade Path tool] +- [Elasticsearch] ### Sources @@ -788,6 +789,7 @@ Solution: set the correct ownership with [code owners]: https://docs.gitlab.com/ee/user/project/codeowners/ [command-line options]: https://docs.gitlab.com/charts/installation/command-line-options.html [deployment]: https://docs.gitlab.com/charts/installation/deployment.html +[elasticsearch]: https://docs.gitlab.com/ee/integration/advanced_search/elasticsearch.html [environment variables]: https://docs.gitlab.com/ee/administration/environment_variables.html [forks]: https://docs.gitlab.com/ee/user/project/repository/forking_workflow.html [gitlab ha scaling runner vending machine for aws ec2 asg]: https://gitlab.com/guided-explorations/aws/gitlab-runner-autoscaling-aws-asg#gitlab-runners-on-aws-spot-best-practices diff --git a/snippets/gitlab/commands.fish b/snippets/gitlab/commands.fish new file mode 100644 index 0000000..e740dd1 --- /dev/null +++ b/snippets/gitlab/commands.fish @@ -0,0 +1,3 @@ +#!/usr/bin/env fish + +gitlab-rake 'gitlab:elastic:info' diff --git a/snippets/gitlab/package installation.sh b/snippets/gitlab/package installation.sh index b5f6f8c..bc9f73a 100644 --- a/snippets/gitlab/package installation.sh +++ b/snippets/gitlab/package installation.sh @@ -196,21 +196,51 @@ sudo dnf -y remove --noautoremove 'gitlab-ee' ## Removal - end --------------------- # +## +# Opensearch integration - start +## + +# Estimate the required cluster size based on the total size of the repositories +sudo gitlab-rake 'gitlab:elastic:estimate_cluster_size' + +# Estimate the required shard sizes for each index based on approximate database counts +# Does *not* include repository data (code, commits, and wikis) +sudo gitlab-rake 'gitlab:elastic:estimate_shard_sizes' + +# Enable advanced search with Elasticsearch +sudo gitlab-rake 'gitlab:elastic:enable_search_with_elasticsearch' + +# Disable advanced search with Elasticsearch +sudo gitlab-rake 'gitlab:elastic:disable_search_with_elasticsearch' + +# Get information +sudo gitlab-rake 'gitlab:elastic:info' + +# Index the entire instance +# Deletes all existing indices +sudo gitlab-rake 'gitlab:elastic:index' + +# Index specific data +sudo gitlab-rake 'gitlab:elastic:index_epics' +sudo gitlab-rake 'gitlab:elastic:index_work_items' +sudo gitlab-rake 'gitlab:elastic:index_group_wikis' +sudo gitlab-rake 'gitlab:elastic:index_namespaces' +sudo gitlab-rake 'gitlab:elastic:index_projects' +sudo gitlab-rake 'gitlab:elastic:index_snippets' +sudo gitlab-rake 'gitlab:elastic:index_users' + +# Delete indexes +sudo gitlab-rake gitlab:elastic:delete_index + +# Get logs +tail -f '/var/log/gitlab/gitlab-rails/elasticsearch.log' + +## Opensearch integration - end --------------------- # + + # Check the included PostgreSQL version sudo gitlab-psql -c 'SELECT version();' # Check the status of batched background migrations # Should the query return zero rows, all batched background migrations are complete sudo gitlab-psql -c "SELECT job_class_name, table_name, column_name, job_arguments FROM batched_background_migrations WHERE status NOT IN(3, 6);" - - -# Opensearch integration -# Estimate the required cluster size based on the total size of the repositories -sudo gitlab-rake 'gitlab:elastic:estimate_cluster_size' -# Estimate the required shard sizes for each index based on approximate database counts -# Does *not* include repository data (code, commits, and wikis) -sudo gitlab-rake 'gitlab:elastic:estimate_shard_sizes' -# Enable advanced search with Elasticsearch. -sudo gitlab-rake 'gitlab:elastic:enable_search_with_elasticsearch' -# Disable advanced search with Elasticsearch. -sudo gitlab-rake 'gitlab:elastic:disable_search_with_elasticsearch'