auser-poolparty 0.2.40 → 0.2.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Manifest.txt +1 -0
- data/lib/poolparty/base_packages/poolparty.rb +4 -2
- data/lib/poolparty/core/string.rb +1 -1
- data/lib/poolparty/helpers/provisioner_base.rb +1 -0
- data/lib/poolparty/helpers/provisioners/master.rb +8 -11
- data/lib/poolparty/helpers/provisioners/slave.rb +2 -3
- data/lib/poolparty/modules/thread_pool.rb +107 -0
- data/lib/poolparty/net/remoter.rb +2 -4
- data/lib/poolparty/version.rb +1 -1
- data/poolparty.gemspec +2 -1
- data/spec/poolparty/net/remote_spec.rb +2 -1
- metadata +2 -1
data/Manifest.txt
CHANGED
@@ -336,6 +336,7 @@ lib/poolparty/modules/pretty_printer.rb
|
|
336
336
|
lib/poolparty/modules/resourcing_dsl.rb
|
337
337
|
lib/poolparty/modules/s3_string.rb
|
338
338
|
lib/poolparty/modules/safe_instance.rb
|
339
|
+
lib/poolparty/modules/thread_pool.rb
|
339
340
|
lib/poolparty/monitors/base_monitor.rb
|
340
341
|
lib/poolparty/monitors/monitors/cpu_monitor.rb
|
341
342
|
lib/poolparty/monitors/monitors/memory_monitor.rb
|
@@ -56,19 +56,21 @@ module PoolParty
|
|
56
56
|
# Custom run puppet to minimize footprint
|
57
57
|
# TODO: Update the offsetted times
|
58
58
|
execute_on_master do
|
59
|
-
has_cron(:name => "puppetd runner", :user => Base.user, :minute => "*/
|
59
|
+
has_cron(:name => "puppetd runner", :user => Base.user, :minute => "*/5") do
|
60
|
+
requires get_gempackage("poolparty-latest")
|
60
61
|
command(PoolParty::Remote::RemoteInstance.puppet_master_rerun_command)
|
61
62
|
end
|
62
63
|
end
|
63
64
|
execute_on_node do
|
64
65
|
has_cron(:name => "puppetd runner", :user => Base.user, :minute => "*/5") do
|
66
|
+
requires get_gempackage("poolparty-latest")
|
65
67
|
command(PoolParty::Remote::RemoteInstance.puppet_rerun_commad)
|
66
68
|
end
|
67
69
|
end
|
68
70
|
|
69
71
|
# These are all requirements on the master
|
70
72
|
execute_on_master do
|
71
|
-
has_cron({:name => "maintain script", :command => ". /etc/profile && which cloud-maintain | /bin/sh", :minute => "*/3"})
|
73
|
+
has_cron({:name => "maintain script", :command => ". /etc/profile && which cloud-maintain | /bin/sh", :minute => "*/3", :requires => get_gempackage("poolparty-latest")})
|
72
74
|
# TODO: Update this so it only runs when needed
|
73
75
|
has_exec(:name => "start master messenger", :command => ". /etc/profile && server-start-master", :requires => [get_gempackage("poolparty-latest"), get_exec("build_messenger")], :onlyif => "ps aux | grep beam | grep master")
|
74
76
|
|
@@ -108,17 +108,14 @@ wget http://rubyforge.org/frs/download.php/45546/rubyforge-1.0.1.gem -O rubyforg
|
|
108
108
|
wget http://rubyforge.org/frs/download.php/43954/rake-0.8.3.gem -O rake.gem 2>&1
|
109
109
|
wget http://rubyforge.org/frs/download.php/45589/sexp_processor-3.0.0.gem -O sexp_processor.gem 2>&1
|
110
110
|
wget http://github.com/auser/poolparty/tree/master%2Fpkg%2Fpoolparty-latest.gem?raw=true -O poolparty-latest.gem 2>&1
|
111
|
-
wget http://rubyforge.org/frs/download.php/43666/amazon-ec2-0.3.1.gem -O
|
111
|
+
wget http://rubyforge.org/frs/download.php/43666/amazon-ec2-0.3.1.gem -O amazon-ec2.gem 2>&1
|
112
112
|
|
113
113
|
#{
|
114
114
|
%w(rake lockfile rubyforge hoe ZenTest sexp_processor flexmock logging activesupport
|
115
|
-
RubyInline ParseTree ruby2ruby xml-simple poolparty-latest
|
116
|
-
"gem install --ignore-dependencies -y --no-ri --no-rdoc #{dep}.gem"
|
115
|
+
RubyInline ParseTree ruby2ruby xml-simple poolparty-latest amazon-ec2).map do |dep|
|
116
|
+
"gem install --ignore-dependencies -y --no-ri --no-rdoc #{dep}.gem #{unix_hide_string}"
|
117
117
|
end.join("\n")
|
118
118
|
}
|
119
|
-
|
120
|
-
# gem install -y --no-ri --no-rdoc --source http://gems.github.com grempe-amazon-ec2
|
121
|
-
# gem install -y --no-ri --no-rdoc --source http://gems.github.com auser-poolparty
|
122
119
|
EOE
|
123
120
|
end
|
124
121
|
|
@@ -127,11 +124,11 @@ wget http://rubyforge.org/frs/download.php/43666/amazon-ec2-0.3.1.gem -O grempe-
|
|
127
124
|
def start_puppetmaster
|
128
125
|
<<-EOS
|
129
126
|
. /etc/profile
|
130
|
-
|
131
|
-
|
127
|
+
/etc/init.d/puppetmaster stop #{unix_hide_string}
|
128
|
+
ps aux | grep puppetmaster | awk '{print $2}' | xargs kill #{unix_hide_string} # just in case
|
132
129
|
rm -rf /etc/puppet/ssl
|
133
|
-
|
134
|
-
/etc/init.d/puppetmaster start
|
130
|
+
# Start it back up
|
131
|
+
/etc/init.d/puppetmaster start #{unix_hide_string}
|
135
132
|
EOS
|
136
133
|
end
|
137
134
|
|
@@ -167,7 +164,7 @@ cp #{Base.remote_storage_path}/poolparty.pp /etc/puppet/manifests/classes/poolpa
|
|
167
164
|
|
168
165
|
def restart_puppetd
|
169
166
|
<<-EOS
|
170
|
-
. /etc/profile && /usr/sbin/puppetd --onetime --no-daemonize --logdest syslog --server master
|
167
|
+
. /etc/profile && /usr/sbin/puppetd --onetime --no-daemonize --logdest syslog --server master #{unix_hide_string}
|
171
168
|
EOS
|
172
169
|
end
|
173
170
|
end
|
@@ -25,7 +25,7 @@ module PoolParty
|
|
25
25
|
def setup_configs
|
26
26
|
<<-EOS
|
27
27
|
echo "#{open(File.join(template_directory, "puppet.conf")).read}" > /etc/puppet/puppet.conf
|
28
|
-
/etc/init.d/puppetmaster stop
|
28
|
+
/etc/init.d/puppetmaster stop #{unix_hide_string}
|
29
29
|
# /usr/bin/puppetrerun
|
30
30
|
EOS
|
31
31
|
end
|
@@ -34,8 +34,7 @@ module PoolParty
|
|
34
34
|
# puppetd --listen --fqdn #{@instance.name}
|
35
35
|
def start_puppet
|
36
36
|
<<-EOS
|
37
|
-
. /etc/profile && /usr/sbin/puppetd --onetime --no-daemonize --logdest syslog --server master
|
38
|
-
. /etc/profile && /usr/sbin/puppetd --onetime --no-daemonize --logdest syslog --server master 2>&1 > /dev/null &
|
37
|
+
. /etc/profile && /usr/sbin/puppetd --onetime --no-daemonize --logdest syslog --server master #{unix_hide_string}
|
39
38
|
EOS
|
40
39
|
end
|
41
40
|
|
@@ -0,0 +1,107 @@
|
|
1
|
+
require 'thread'
|
2
|
+
begin
|
3
|
+
require 'fasttread'
|
4
|
+
rescue LoadError
|
5
|
+
$stderr.puts "Using the ruby-core thread implementation"
|
6
|
+
end
|
7
|
+
|
8
|
+
class ThreadPool
|
9
|
+
class Worker
|
10
|
+
def initialize(thread_queue)
|
11
|
+
@mutex = Mutex.new
|
12
|
+
@cv = ConditionVariable.new
|
13
|
+
@queue = thread_queue
|
14
|
+
@running = true
|
15
|
+
@thread = Thread.new do
|
16
|
+
@mutex.synchronize do
|
17
|
+
while @running
|
18
|
+
@cv.wait(@mutex)
|
19
|
+
block = get_block
|
20
|
+
if block
|
21
|
+
@mutex.unlock
|
22
|
+
block.call
|
23
|
+
@mutex.lock
|
24
|
+
reset_block
|
25
|
+
end
|
26
|
+
@queue << self
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def name
|
33
|
+
@thread.inspect
|
34
|
+
end
|
35
|
+
|
36
|
+
def get_block
|
37
|
+
@block
|
38
|
+
end
|
39
|
+
|
40
|
+
def set_block(block)
|
41
|
+
@mutex.synchronize do
|
42
|
+
raise RuntimeError, "Thread already busy." if @block
|
43
|
+
@block = block
|
44
|
+
# Signal the thread in this class, that there's a job to be done
|
45
|
+
@cv.signal
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def reset_block
|
50
|
+
@block = nil
|
51
|
+
end
|
52
|
+
|
53
|
+
def busy?
|
54
|
+
@mutex.synchronize { !@block.nil? }
|
55
|
+
end
|
56
|
+
|
57
|
+
def stop
|
58
|
+
@mutex.synchronize do
|
59
|
+
@running = false
|
60
|
+
@cv.signal
|
61
|
+
end
|
62
|
+
@thread.join
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
attr_accessor :max_size
|
67
|
+
|
68
|
+
def initialize(max_size = 10)
|
69
|
+
@max_size = max_size
|
70
|
+
@queue = Queue.new
|
71
|
+
@workers = []
|
72
|
+
end
|
73
|
+
|
74
|
+
def size
|
75
|
+
@workers.size
|
76
|
+
end
|
77
|
+
|
78
|
+
def busy?
|
79
|
+
@queue.size < @workers.size
|
80
|
+
end
|
81
|
+
|
82
|
+
def shutdown
|
83
|
+
@workers.each { |w| w.stop }
|
84
|
+
@workers = []
|
85
|
+
end
|
86
|
+
|
87
|
+
alias :join :shutdown
|
88
|
+
|
89
|
+
def process(block=nil,&blk)
|
90
|
+
block = blk if block_given?
|
91
|
+
worker = get_worker
|
92
|
+
worker.set_block(block)
|
93
|
+
end
|
94
|
+
|
95
|
+
private
|
96
|
+
|
97
|
+
def get_worker
|
98
|
+
if !@queue.empty? or @workers.size == @max_size
|
99
|
+
return @queue.pop
|
100
|
+
else
|
101
|
+
worker = Worker.new(@queue)
|
102
|
+
@workers << worker
|
103
|
+
worker
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
@@ -194,11 +194,9 @@ module PoolParty
|
|
194
194
|
reset!
|
195
195
|
wait "20.seconds" # Give some time for ssh to startup
|
196
196
|
@num_instances = nonmaster_nonterminated_instances.size
|
197
|
-
last_instances = nonmaster_nonterminated_instances[(@num_instances - @num)
|
197
|
+
last_instances = nonmaster_nonterminated_instances[(@num_instances - (@num + 1))..(@num_instances)]
|
198
198
|
last_instances.each do |inst|
|
199
|
-
|
200
|
-
cmd = ". /etc/profile && cloud-provision -i #{inst.name.gsub(/node/, '')} #{unix_hide_string} &"
|
201
|
-
Kernel.system cmd
|
199
|
+
PoolParty::Provisioner.provision_slave(inst, self, false)
|
202
200
|
end
|
203
201
|
PoolParty::Provisioner.reconfigure_master(self, force)
|
204
202
|
after_launched
|
data/lib/poolparty/version.rb
CHANGED
data/poolparty.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: poolparty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.41
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ari Lerner
|
@@ -439,6 +439,7 @@ files:
|
|
439
439
|
- lib/poolparty/modules/resourcing_dsl.rb
|
440
440
|
- lib/poolparty/modules/s3_string.rb
|
441
441
|
- lib/poolparty/modules/safe_instance.rb
|
442
|
+
- lib/poolparty/modules/thread_pool.rb
|
442
443
|
- lib/poolparty/monitors/base_monitor.rb
|
443
444
|
- lib/poolparty/monitors/monitors/cpu_monitor.rb
|
444
445
|
- lib/poolparty/monitors/monitors/memory_monitor.rb
|
@@ -233,7 +233,8 @@ describe "Remote" do
|
|
233
233
|
end
|
234
234
|
it "should call a new slave provisioner" do
|
235
235
|
@tc.stub!(:should_expand_cloud?).once.and_return true
|
236
|
-
|
236
|
+
PoolParty::Provisioner.should_receive(:provision_slave).at_least(1)
|
237
|
+
# Kernel.should_receive(:system).with(". /etc/profile && cloud-provision -i 5 2>&1 > /dev/null &").and_return true
|
237
238
|
end
|
238
239
|
it "should call reconfigure on the master to pick up the new slave" do
|
239
240
|
@tc.stub!(:should_expand_cloud?).once.and_return true
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: auser-poolparty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.41
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ari Lerner
|
@@ -439,6 +439,7 @@ files:
|
|
439
439
|
- lib/poolparty/modules/resourcing_dsl.rb
|
440
440
|
- lib/poolparty/modules/s3_string.rb
|
441
441
|
- lib/poolparty/modules/safe_instance.rb
|
442
|
+
- lib/poolparty/modules/thread_pool.rb
|
442
443
|
- lib/poolparty/monitors/base_monitor.rb
|
443
444
|
- lib/poolparty/monitors/monitors/cpu_monitor.rb
|
444
445
|
- lib/poolparty/monitors/monitors/memory_monitor.rb
|