Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Chandler <wchandler@gitlab.com>2023-01-06 18:24:32 +0300
committerWill Chandler <wchandler@gitlab.com>2023-01-17 20:28:17 +0300
commit0945b0262688bc2d88e2d0d3b47d5e4097f5b061 (patch)
tree474677e29151fddf175841d67b342a7b6733b7a3 /_support
parenta5fdcaca164e3eb99762e0b6087cb06e7569502c (diff)
benchmarking: Add gitaly role
Build Gitaly itself, along with Gitaly-Ruby and gitlab-shell. The versions to use for Go, Ruby, and Gitaly are all parsed on the client node, so that role must be run first. To support installing arbitrary version of Ruby, we use ruby-build to compile it from source. To ensure we are using the most relevant Git version, we build Gitaly with the bundled Git option enabled. Currently gitlab-shell is built so Gitaly can validate its presence, but is not used.
Diffstat (limited to '_support')
-rw-r--r--_support/benchmarking/configure.yml6
-rw-r--r--_support/benchmarking/roles/gitaly/tasks/initialize.yml44
-rw-r--r--_support/benchmarking/roles/gitaly/tasks/main.yml10
-rw-r--r--_support/benchmarking/roles/gitaly/tasks/setup_gitaly.yml114
-rw-r--r--_support/benchmarking/roles/gitaly/tasks/setup_gitlab_shell.yml42
-rw-r--r--_support/benchmarking/roles/gitaly/tasks/setup_go.yml14
-rw-r--r--_support/benchmarking/roles/gitaly/tasks/setup_ruby.yml33
-rw-r--r--_support/benchmarking/roles/gitaly/templates/config.toml.j261
-rw-r--r--_support/benchmarking/roles/gitaly/vars/main.yml2
9 files changed, 326 insertions, 0 deletions
diff --git a/_support/benchmarking/configure.yml b/_support/benchmarking/configure.yml
index dc21cce37..d7c292be2 100644
--- a/_support/benchmarking/configure.yml
+++ b/_support/benchmarking/configure.yml
@@ -4,3 +4,9 @@
roles:
- client
become: true
+
+- name: Gitaly setup
+ hosts: gitaly
+ roles:
+ - gitaly
+ become: true
diff --git a/_support/benchmarking/roles/gitaly/tasks/initialize.yml b/_support/benchmarking/roles/gitaly/tasks/initialize.yml
new file mode 100644
index 000000000..e5e5e1795
--- /dev/null
+++ b/_support/benchmarking/roles/gitaly/tasks/initialize.yml
@@ -0,0 +1,44 @@
+---
+- name: Install client SSH pubkey
+ authorized_key:
+ user: root
+ key: "{{ hostvars[groups['client'][0]]['client_ssh_key'] | b64decode }}"
+
+# Set high uid to ensure it's not squashed by another service
+- name: Create 'git' user
+ user:
+ name: git
+ uid: 1999
+ groups: admin,google-sudoers
+ append: true
+
+- name: Mount repositories disk
+ mount:
+ path: /mnt/git-repositories
+ src: /dev/disk/by-id/google-repository-disk
+ fstype: ext4
+ opts: discard,defaults
+ state: mounted
+
+- name: Set git as owner of git-repositories directory
+ file:
+ path: /mnt/git-repositories
+ owner: git
+ group: git
+ state: directory
+ recurse: yes
+
+- name: Create /src directory
+ file:
+ path: /src
+ state: directory
+ mode: '0755'
+ owner: git
+ group: git
+
+# Match limits set by Omnibus
+- name: Set file-max
+ shell: echo "1000000" > /proc/sys/fs/file-max
+
+- name: Update apt cache
+ apt: update_cache=yes
diff --git a/_support/benchmarking/roles/gitaly/tasks/main.yml b/_support/benchmarking/roles/gitaly/tasks/main.yml
new file mode 100644
index 000000000..7f6fa7b3e
--- /dev/null
+++ b/_support/benchmarking/roles/gitaly/tasks/main.yml
@@ -0,0 +1,10 @@
+---
+- name: Show ref and commit being used
+ debug:
+ msg: "Building Gitaly at {{ gitaly_revision }} on {{ hostvars[groups['client'][0]]['gitaly_commit'] }}"
+
+- include_tasks: initialize.yml
+- include_tasks: setup_go.yml
+- include_tasks: setup_ruby.yml
+- include_tasks: setup_gitaly.yml
+- include_tasks: setup_gitlab_shell.yml
diff --git a/_support/benchmarking/roles/gitaly/tasks/setup_gitaly.yml b/_support/benchmarking/roles/gitaly/tasks/setup_gitaly.yml
new file mode 100644
index 000000000..66bc9036b
--- /dev/null
+++ b/_support/benchmarking/roles/gitaly/tasks/setup_gitaly.yml
@@ -0,0 +1,114 @@
+---
+- name: Create /var/opt/gitaly directory
+ file:
+ path: /var/opt/gitaly
+ state: directory
+ mode: '0700'
+ owner: git
+ group: git
+
+- name: Create /opt/gitaly directory
+ file:
+ path: /opt/gitaly
+ state: directory
+ mode: '0755'
+ owner: git
+ group: git
+
+- name: Create runtime directory
+ file:
+ path: /var/opt/gitaly/run
+ state: directory
+ mode: '0700'
+ owner: git
+ group: git
+
+- name: Create log directory
+ file:
+ path: /var/log/gitaly
+ state: directory
+ mode: '0755'
+ owner: git
+ group: git
+
+- name: Create gitaly-ruby directory
+ file:
+ path: /opt/gitaly-ruby
+ state: directory
+ mode: '0755'
+ owner: git
+ group: git
+
+- name: Install Gitaly build dependencies
+ apt:
+ name:
+ - cmake
+ - libssl-dev
+ - pkg-config
+ state: present
+
+- name: Install Git build dependencies
+ apt:
+ name:
+ - dh-autoreconf
+ - libcurl4-gnutls-dev
+ - libexpat1-dev
+ - gettext
+ - libz-dev
+ - libssl-dev
+ - asciidoc
+ - libffi-dev
+ - xmlto
+ - docbook2x
+ - install-info
+ - libpcre2-dev
+ state: present
+
+- name: Clone Gitaly at specified commit
+ git:
+ repo: https://gitlab.com/gitlab-org/gitaly.git
+ dest: /src/gitaly
+ version: "{{ hostvars[groups['client'][0]]['gitaly_commit'] }}"
+ become_user: git
+
+- name: Build Gitaly
+ make:
+ target: build
+ params:
+ WITH_BUNDLED_GIT: YesPlease
+ jobs: "{{ ansible_processor_nproc }}"
+ chdir: /src/gitaly
+ environment:
+ PATH: '/usr/local/go/bin:{{ ansible_env.PATH }}'
+ BUNDLE_PATH: '/src/gitaly/.ruby'
+ become_user: git
+
+- name: Install Gitaly to /opt/gitaly
+ make:
+ target: install
+ params:
+ WITH_BUNDLED_GIT: YesPlease
+ PREFIX: /opt/gitaly
+ jobs: "{{ ansible_processor_nproc }}"
+ chdir: /src/gitaly
+ environment:
+ PATH: '/usr/local/go/bin:{{ ansible_env.PATH }}'
+ BUNDLE_PATH: '/src/gitaly/.ruby'
+ become_user: git
+
+- name: Copy Gitaly-Ruby to ruby directory
+ copy:
+ src: /src/gitaly/ruby/
+ dest: /opt/gitaly-ruby/
+ owner: git
+ group: git
+ mode: '0755'
+ remote_src: true
+
+- name: Install Gitaly config
+ template:
+ src: config.toml.j2
+ dest: /var/opt/gitaly/config.toml
+ owner: git
+ group: git
+ mode: '0600'
diff --git a/_support/benchmarking/roles/gitaly/tasks/setup_gitlab_shell.yml b/_support/benchmarking/roles/gitaly/tasks/setup_gitlab_shell.yml
new file mode 100644
index 000000000..86726320b
--- /dev/null
+++ b/_support/benchmarking/roles/gitaly/tasks/setup_gitlab_shell.yml
@@ -0,0 +1,42 @@
+---
+- name: Create /opt/gitlab-shell directory
+ file:
+ path: /opt/gitlab-shell
+ state: directory
+ mode: '0755'
+ owner: git
+ group: git
+
+- name: Clone gitlab-shell
+ git:
+ repo: https://gitlab.com/gitlab-org/gitlab-shell.git
+ dest: /src/gitlab-shell
+ version: HEAD
+ become_user: git
+
+- name: Build gitlab-shell
+ make:
+ target: build
+ jobs: "{{ ansible_processor_nproc }}"
+ chdir: /src/gitlab-shell
+ environment:
+ PATH: '/usr/local/go/bin:{{ ansible_env.PATH }}'
+ become_user: git
+
+- name: Install gitlab-shell to /opt/gitlab-shell
+ make:
+ target: install
+ params:
+ PREFIX: /opt/gitlab-shell
+ jobs: "{{ ansible_processor_nproc }}"
+ chdir: /src/gitlab-shell
+ environment:
+ PATH: '/usr/local/go/bin:{{ ansible_env.PATH }}'
+
+- name: Create gitlab-shell secret
+ file:
+ path: /var/opt/gitaly/shell.secret
+ state: touch
+ mode: '0400'
+ owner: git
+ group: git
diff --git a/_support/benchmarking/roles/gitaly/tasks/setup_go.yml b/_support/benchmarking/roles/gitaly/tasks/setup_go.yml
new file mode 100644
index 000000000..afafb220a
--- /dev/null
+++ b/_support/benchmarking/roles/gitaly/tasks/setup_go.yml
@@ -0,0 +1,14 @@
+---
+- name: Create /usr/local/go directory
+ file:
+ path: /usr/local/go
+ state: directory
+ mode: 0755
+
+# Relies on client setup detecting Go version first
+- name: Install Go
+ unarchive:
+ src: "https://go.dev/dl/go{{ hostvars[groups['client'][0]]['golang_version'] }}.linux-amd64.tar.gz"
+ dest: /usr/local
+ remote_src: true
+ creates: /usr/local/go/bin/go
diff --git a/_support/benchmarking/roles/gitaly/tasks/setup_ruby.yml b/_support/benchmarking/roles/gitaly/tasks/setup_ruby.yml
new file mode 100644
index 000000000..0b07a72ee
--- /dev/null
+++ b/_support/benchmarking/roles/gitaly/tasks/setup_ruby.yml
@@ -0,0 +1,33 @@
+---
+- name: Install Ruby build dependencies
+ apt:
+ name:
+ - autogen
+ - autoconf
+ - build-essential
+ - libtool
+ - libyaml-dev
+ - libreadline6-dev
+ - libncurses5-dev
+ - libffi-dev
+ - libgdbm-dev
+ - zlib1g-dev
+ state: present
+
+- name: Get ruby-build source
+ unarchive:
+ src: "https://github.com/rbenv/ruby-build/archive/refs/tags/v{{ ruby_build_version }}.tar.gz"
+ dest: /src
+ remote_src: true
+ creates: "/src/ruby-build-{{ ruby_build_version }}"
+ register: ruby_build
+ become_user: git
+
+- name: Install ruby-build
+ shell: "PREFIX=/usr/local /src/ruby-build-{{ ruby_build_version }}/install.sh"
+ when: ruby_build.changed == True
+
+- name: Build Ruby
+ shell: "ruby-build {{ hostvars[groups['client'][0]]['ruby_version'] }} /usr/local"
+ args:
+ creates: /usr/local/bin/ruby
diff --git a/_support/benchmarking/roles/gitaly/templates/config.toml.j2 b/_support/benchmarking/roles/gitaly/templates/config.toml.j2
new file mode 100644
index 000000000..9a9b2c230
--- /dev/null
+++ b/_support/benchmarking/roles/gitaly/templates/config.toml.j2
@@ -0,0 +1,61 @@
+socket_path = "/var/opt/gitaly/gitaly.socket"
+
+# The directory where Gitaly's executables are stored
+bin_dir = "/opt/gitaly/bin"
+
+# The directory where Gitaly creates all data required at runtime.
+runtime_dir = "/var/opt/gitaly/run"
+
+# # Optional: listen on a TCP socket. This is insecure (no authentication)
+listen_addr = "0.0.0.0:8075"
+# tls_listen_addr = "127.0.0.1:8888
+
+# # Optional: export metrics via Prometheus
+prometheus_listen_addr = "127.0.0.1:9236"
+
+# # Optional: authenticate Gitaly requests using a shared secret
+[auth]
+# token = 'abc123secret'
+
+# transitioning = false # Set `transitioning` to true to temporarily allow unauthenticated while rolling out authentication.
+
+# [tls]
+# certificate_path = '/home/git/cert.cert'
+# key_path = '/home/git/key.pem'
+
+# # Git settings
+[git]
+use_bundled_binaries = true
+catfile_cache_size = 10
+ignore_gitconfig = true
+
+[[storage]]
+name = "default"
+path = "/mnt/git-repositories"
+
+# # You can optionally configure Gitaly to output JSON-formatted log messages to stdout
+[logging]
+level = "info"
+format = "json"
+dir = "/var/log/gitaly"
+
+[gitaly-ruby]
+# The directory where gitaly-ruby is installed
+dir = "/opt/gitaly-ruby"
+
+[gitlab-shell]
+# The directory where gitlab-shell is installed
+dir = "/opt/gitlab-shell"
+
+[gitlab]
+url = "http://127.0.0.1:3001"
+secret_file = "/var/opt/gitaly/shell.secret"
+
+[gitlab.http-settings]
+self_signed_cert = false
+
+[pack_objects_cache]
+enabled = true
+dir = "/mnt/git-repositories/+gitaly/PackObjectsCache"
+max_age = '5m'
+
diff --git a/_support/benchmarking/roles/gitaly/vars/main.yml b/_support/benchmarking/roles/gitaly/vars/main.yml
new file mode 100644
index 000000000..fe385e060
--- /dev/null
+++ b/_support/benchmarking/roles/gitaly/vars/main.yml
@@ -0,0 +1,2 @@
+---
+ruby_build_version: 20221206