From 1ee838190e7f7e93dfe50ba26dde549d0fa1aa4e Mon Sep 17 00:00:00 2001
From: Lin Jen-Shin <godfat@godfat.org>
Date: Sat, 4 Feb 2017 00:21:29 +0800
Subject: [PATCH] No need to tick the queue when creating the runner

Feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/8664/diffs#note_22190504
---
 lib/ci/api/runners.rb | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/lib/ci/api/runners.rb b/lib/ci/api/runners.rb
index c10858f4c5e..bcc82969eb3 100644
--- a/lib/ci/api/runners.rb
+++ b/lib/ci/api/runners.rb
@@ -28,27 +28,23 @@ module Ci
         post "register" do
           required_attributes! [:token]
 
-          project = nil
+          attributes = attributes_for_keys(
+            [:description, :tag_list, :run_untagged, :locked]
+          )
+
           runner =
             if runner_registration_token_valid?
               # Create shared runner. Requires admin access
-              Ci::Runner.new(is_shared: true)
+              Ci::Runner.create(attributes.merge(is_shared: true))
             elsif project = Project.find_by(runners_token: params[:token])
-              Ci::Runner.new
+              # Create a specific runner for project.
+              project.runners.create(attributes)
             end
 
           return forbidden! unless runner
 
-          attributes = attributes_for_keys(
-            [:description, :tag_list, :run_untagged, :locked]
-          ).merge(get_runner_version_from_params || {})
-
-          Ci::UpdateRunnerService.new(runner).update(attributes)
-
-          # Assign the specific runner for the project
-          project.runners << runner if project
-
           if runner.id
+            runner.update(get_runner_version_from_params)
             present runner, with: Entities::Runner
           else
             not_found!
-- 
GitLab