From c2a3e5c19f0c1bbe331d57c94fcbb78a54b6b6c5 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Wed, 22 Mar 2017 18:52:13 +0100 Subject: [PATCH] Make CI API to always use primary DB --- changelogs/unreleased/make-ci-api-to-always-use-primary.yml | 4 ++++ lib/api/runner.rb | 4 ++++ lib/ci/api/builds.rb | 4 ++++ 3 files changed, 12 insertions(+) create mode 100644 changelogs/unreleased/make-ci-api-to-always-use-primary.yml diff --git a/changelogs/unreleased/make-ci-api-to-always-use-primary.yml b/changelogs/unreleased/make-ci-api-to-always-use-primary.yml new file mode 100644 index 00000000000000..2c2f9765f1858a --- /dev/null +++ b/changelogs/unreleased/make-ci-api-to-always-use-primary.yml @@ -0,0 +1,4 @@ +--- +title: Make CI API to always use primary DB +merge_request: +author: diff --git a/lib/api/runner.rb b/lib/api/runner.rb index 4c9db2c8716159..a804afac27c803 100644 --- a/lib/api/runner.rb +++ b/lib/api/runner.rb @@ -61,6 +61,10 @@ class Runner < Grape::API end resource :jobs do + before do + Gitlab::Database::LoadBalancing::Session.current.use_primary! + end + desc 'Request a job' do success Entities::JobRequest::Response http_codes [[201, 'Job was scheduled'], diff --git a/lib/ci/api/builds.rb b/lib/ci/api/builds.rb index 746e76a1b1f1d8..c98e6f2fc06135 100644 --- a/lib/ci/api/builds.rb +++ b/lib/ci/api/builds.rb @@ -3,6 +3,10 @@ module API # Builds API class Builds < Grape::API resource :builds do + before do + Gitlab::Database::LoadBalancing::Session.current.use_primary! + end + # Runs oldest pending build by runner - Runners only # # Parameters: -- GitLab