As we reevaluate how to best support and maintain Staging Ref in the future, we encourage development teams using this environment to highlight their use cases in the following issue: https://gitlab.com/gitlab-com/gl-infra/software-delivery/framework/software-delivery-framework-issue-tracker/-/issues/36.

Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • idrozdov/gitlab-shell
  • mmj/gitlab-shell
2 results
Show changes
Commits on Source (1)
v3.0.0 v3.0.0
- Pipe RPUSH command to Redis via stdin to avoid overrunning command-line
- Remove rm-tag command (Robert Schilling) - Remove rm-tag command (Robert Schilling)
- Remove create-branch and rm-branch commands (Robert Schilling) - Remove create-branch and rm-branch commands (Robert Schilling)
- Update PostReceive worker so it logs a unique JID in Sidekiq - Update PostReceive worker so it logs a unique JID in Sidekiq
Loading
Loading
Loading
@@ -2,6 +2,7 @@ require_relative 'gitlab_init'
Loading
@@ -2,6 +2,7 @@ require_relative 'gitlab_init'
require_relative 'gitlab_net' require_relative 'gitlab_net'
require 'json' require 'json'
require 'base64' require 'base64'
require 'open3'
require 'securerandom' require 'securerandom'
class GitlabPostReceive class GitlabPostReceive
Loading
@@ -74,11 +75,20 @@ class GitlabPostReceive
Loading
@@ -74,11 +75,20 @@ class GitlabPostReceive
queue = "#{config.redis_namespace}:queue:post_receive" queue = "#{config.redis_namespace}:queue:post_receive"
msg = JSON.dump({ 'class' => 'PostReceive', 'args' => [@repo_path, @actor, changes], 'jid' => @jid }) 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') begin
return true result = Open3.popen2(*config.redis_command, '--pipe') do |stdin, stdout, wait_thr|
else stdin.write("RPUSH '#{queue}' '#{msg}'")
puts "GitLab: An unexpected error occurred (redis-cli returned #{$?.exitstatus})." stdin.close
wait_thr.value
end
return true if result == 0
puts "GitLab: An unexpected error occurred (redis-cli returned #{result.to_i})."
return false
rescue => e
puts "GitLab: An unexpected error occurred running redis-cli"
return false return false
end end
end end
Loading
Loading
# coding: utf-8
require 'spec_helper' require 'spec_helper'
require 'gitlab_post_receive' require 'gitlab_post_receive'
Loading
@@ -21,7 +22,7 @@ describe GitlabPostReceive do
Loading
@@ -21,7 +22,7 @@ describe GitlabPostReceive do
before do before do
GitlabConfig.any_instance.stub(redis_command: %w(env -i redis-cli)) GitlabConfig.any_instance.stub(redis_command: %w(env -i redis-cli))
allow(gitlab_post_receive).to receive(:system).and_return(true) allow(Open3).to receive(:popen2).and_return(0)
end end
it "prints the broadcast message" do it "prints the broadcast message" do
Loading
@@ -47,13 +48,15 @@ describe GitlabPostReceive do
Loading
@@ -47,13 +48,15 @@ describe GitlabPostReceive do
end end
it "pushes a Sidekiq job onto the queue" do it "pushes a Sidekiq job onto the queue" do
expect(gitlab_post_receive).to receive(:system).with( stdin = double('stdin')
expect(stdin).to receive(:write).with(
%Q/RPUSH 'resque:gitlab:queue:post_receive' '{"class":"PostReceive","args":["#{repo_path}","#{actor}",#{base64_changes.inspect}],"jid":"#{gitlab_post_receive.jid}"}'/)
expect(stdin).to receive(:close)
expect(Open3).to receive(:popen2).with(
*[ *[
*%w(env -i redis-cli rpush resque:gitlab:queue:post_receive), *%w(env -i redis-cli --pipe)
%Q/{"class":"PostReceive","args":["#{repo_path}","#{actor}",#{base64_changes.inspect}],"jid":"#{gitlab_post_receive.jid}"}/, ]).and_yield(stdin, double('stdout'), double('wait_thr', value: 0)).and_return(0)
{ err: "/dev/null", out: "/dev/null" }
]
).and_return(true)
gitlab_post_receive.exec gitlab_post_receive.exec
end end
Loading
@@ -72,7 +75,7 @@ describe GitlabPostReceive do
Loading
@@ -72,7 +75,7 @@ describe GitlabPostReceive do
context "when the redis command fails" do context "when the redis command fails" do
before do before do
allow(gitlab_post_receive).to receive(:system).and_return(false) allow(Open3).to receive(:popen2).and_return(1)
allow($?).to receive(:exitstatus).and_return(nil) allow($?).to receive(:exitstatus).and_return(nil)
end end
Loading
Loading