From ec99fe2bd0bfc215d1d1f3e230077bd863ac1abc Mon Sep 17 00:00:00 2001 From: aiionx Date: Wed, 13 Apr 2016 20:00:37 -0700 Subject: [PATCH] Update post receive worker so it logs a unique JID in sidekiq --- lib/gitlab_post_receive.rb | 6 ++++-- spec/gitlab_post_receive_spec.rb | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/gitlab_post_receive.rb b/lib/gitlab_post_receive.rb index ede64f2f4..0fff4794a 100644 --- a/lib/gitlab_post_receive.rb +++ b/lib/gitlab_post_receive.rb @@ -2,14 +2,16 @@ require_relative 'gitlab_init' require_relative 'gitlab_net' require 'json' require 'base64' +require 'securerandom' class GitlabPostReceive - attr_reader :config, :repo_path, :changes + attr_reader :config, :repo_path, :changes, :jid def initialize(repo_path, actor, changes) @config = GitlabConfig.new @repo_path, @actor = repo_path.strip, actor @changes = changes + @jid = SecureRandom.hex(12) end def exec @@ -71,7 +73,7 @@ class GitlabPostReceive changes = Base64.encode64(@changes) queue = "#{config.redis_namespace}:queue:post_receive" - msg = JSON.dump({ 'class' => 'PostReceive', 'args' => [@repo_path, @actor, changes] }) + msg = JSON.dump({ 'class' => 'PostReceive', 'args' => [@repo_path, @actor, changes], 'jid' => @jid }) if system(*config.redis_command, 'rpush', queue, msg, err: '/dev/null', out: '/dev/null') return true diff --git a/spec/gitlab_post_receive_spec.rb b/spec/gitlab_post_receive_spec.rb index 3c1f3625f..9d7696e01 100644 --- a/spec/gitlab_post_receive_spec.rb +++ b/spec/gitlab_post_receive_spec.rb @@ -50,7 +50,7 @@ describe GitlabPostReceive do expect(gitlab_post_receive).to receive(:system).with( *[ *%w(env -i redis-cli rpush resque:gitlab:queue:post_receive), - %Q/{"class":"PostReceive","args":["#{repo_path}","#{actor}",#{base64_changes.inspect}]}/, + %Q/{"class":"PostReceive","args":["#{repo_path}","#{actor}",#{base64_changes.inspect}],"jid":"#{gitlab_post_receive.jid}"}/, { err: "/dev/null", out: "/dev/null" } ] ).and_return(true) -- GitLab