Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

allow riak username and group to be specified #393

Closed
wants to merge 1 commit into from

1 participant

@jlambert121

This patch allows the username and group of the riak database to be supplied. The default remains 'riak:riak' but there are certain cases where users will have different accounts running the service. Spec tests updated as well.

@ghost

Done: 436e2fd
Thanks!

@jlambert121 P.S. You should be working from the develop branch :)

@ghost ghost closed this
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 15, 2013
  1. @jlambert121
This page is out of date. Refresh to see the latest.
Showing with 25 additions and 3 deletions.
  1. +11 −1 lib/backup/database/riak.rb
  2. +14 −2 spec/database/riak_spec.rb
View
12 lib/backup/database/riak.rb
@@ -20,6 +20,14 @@ class Riak < Base
# Path to riak-admin utility (optional)
attr_accessor :riak_admin_utility
+ ##
+ # Username for the riak instance (optional)
+ attr_accessor :user
+
+ ##
+ # Group for the riak instance (optional)
+ attr_accessor :group
+
attr_deprecate :utility_path, :version => '3.0.21',
:message => 'Use Riak#riak_admin_utility instead.',
:action => lambda {|klass, val| klass.riak_admin_utility = val }
@@ -32,6 +40,8 @@ def initialize(model, &block)
instance_eval(&block) if block_given?
@riak_admin_utility ||= utility('riak-admin')
+ @user ||= 'riak'
+ @group ||= 'riak'
end
##
@@ -41,7 +51,7 @@ def perform!
super
# have to make riak the owner since the riak-admin tool runs
# as the riak user in a default setup.
- FileUtils.chown_R('riak', 'riak', @dump_path)
+ FileUtils.chown_R(@user, @group, @dump_path)
backup_file = File.join(@dump_path, name)
run("#{ riakadmin } #{ backup_file } node")
View
16 spec/database/riak_spec.rb
@@ -10,6 +10,8 @@
db.node = 'riak@localhost'
db.cookie = 'riak'
db.riak_admin_utility = '/path/to/riak-admin'
+ db.user = 'riak1'
+ db.group = 'riak1'
end
end
@@ -36,6 +38,8 @@
db.node.should == 'riak@localhost'
db.cookie.should == 'riak'
db.riak_admin_utility.should == '/path/to/riak-admin'
+ db.user.should == 'riak1'
+ db.group.should == 'riak1'
end
end
@@ -52,6 +56,8 @@
db.node.should be_nil
db.cookie.should be_nil
db.riak_admin_utility.should == '/real/riak-admin'
+ db.user.should == 'riak'
+ db.group.should == 'riak'
end
end
end # context 'when no pre-configured defaults have been set'
@@ -63,6 +69,8 @@
db.node = 'db_node'
db.cookie = 'db_cookie'
db.riak_admin_utility = '/default/path/to/riak-admin'
+ db.user = 'riak2'
+ db.group = 'riak2'
end
end
@@ -74,6 +82,8 @@
db.node.should == 'riak@localhost'
db.cookie.should == 'riak'
db.riak_admin_utility.should == '/path/to/riak-admin'
+ db.user.should == 'riak1'
+ db.group.should == 'riak1'
end
end
@@ -85,6 +95,8 @@
db.node.should == 'db_node'
db.cookie.should == 'db_cookie'
db.riak_admin_utility.should == '/default/path/to/riak-admin'
+ db.user.should == 'riak2'
+ db.group.should == 'riak2'
end
end
end # context 'when no pre-configured defaults have been set'
@@ -104,7 +116,7 @@
context 'when no compressor is configured' do
it 'should only perform the riak-admin backup command' do
- FileUtils.expects(:chown_R).with('riak', 'riak', '/dump/path')
+ FileUtils.expects(:chown_R).with('riak1', 'riak1', '/dump/path')
db.expects(:run).in_sequence(s).
with('riakadmin_command /dump/path/mydatabase node')
@@ -119,7 +131,7 @@
end
it 'should compress the backup file and remove the source file' do
- FileUtils.expects(:chown_R).with('riak', 'riak', '/dump/path')
+ FileUtils.expects(:chown_R).with('riak1', 'riak1', '/dump/path')
db.expects(:run).in_sequence(s).
with('riakadmin_command /dump/path/mydatabase node')
db.expects(:run).in_sequence(s).with(
Something went wrong with that request. Please try again.