auser-poolparty 0.2.42 → 0.2.44
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/cloud-maintain +1 -1
- data/bin/cloud-provision +0 -1
- data/lib/erlang/messenger/useful_snippets +6 -3
- data/lib/poolparty/base_packages/haproxy.rb +3 -1
- data/lib/poolparty/base_packages/poolparty.rb +4 -0
- data/lib/poolparty/net/remote.rb +1 -1
- data/lib/poolparty/net/remote_bases/ec2.rb +16 -7
- data/lib/poolparty/net/remoter.rb +27 -5
- data/lib/poolparty/net/remoter_base.rb +3 -2
- data/lib/poolparty/pool/cloud.rb +1 -0
- data/lib/poolparty/version.rb +1 -1
- data/poolparty.gemspec +1 -1
- data/spec/poolparty/net/remote_bases/ec2_spec.rb +1 -1
- data/spec/poolparty/net/remote_spec.rb +2 -1
- data/website/index.html +1 -1
- metadata +1 -1
data/bin/cloud-maintain
CHANGED
@@ -26,7 +26,7 @@ include Remote
|
|
26
26
|
vputs "#{list_of_running_instances.size} running instances of between #{minimum_instances} and #{maximum_instances}"
|
27
27
|
vputs "Launching new instance"
|
28
28
|
launch_minimum_number_of_instances
|
29
|
-
elsif
|
29
|
+
elsif maximum_number_of_instances_are_running?
|
30
30
|
vputs "#{list_of_running_instances.size} running instances of between #{minimum_instances} and #{maximum_instances}"
|
31
31
|
vputs "Shutting down non-master instance"
|
32
32
|
contract_cloud_if_necessary( !testing )
|
data/bin/cloud-provision
CHANGED
@@ -21,7 +21,6 @@ include Remote
|
|
21
21
|
|
22
22
|
if instance_num
|
23
23
|
@instance = get_instance_by_number( instance_num )
|
24
|
-
vputs "Provisioning instance: #{@instance.name} (#{instance_num})"
|
25
24
|
instance_num == 0 ? Provisioner.provision_master(self, testing) : Provisioner.provision_slave(@instance, self, testing)
|
26
25
|
else
|
27
26
|
if provision_slave
|
@@ -6,9 +6,12 @@
|
|
6
6
|
% erl -pa ./ebin -kernel inet_dist_listen_min 7000 inet_dist_listen_max 7050 -setcookie poolparty -boot pm_node_rel-0.1 -sname node1
|
7
7
|
|
8
8
|
% Starting the client on the master
|
9
|
-
% erl -pa /var/lib/gems/1.8/gems/poolparty-0.2.
|
9
|
+
% erl -pa /var/lib/gems/1.8/gems/poolparty-0.2.42/lib/erlang/messenger/ebin -kernel inet_dist_listen_min 7000 inet_dist_listen_max 7050 -sname client -setcookie poolparty -run pm_client start
|
10
10
|
|
11
11
|
% Get the load
|
12
|
-
% erl -pa /var/lib/gems/1.8/gems/poolparty-0.2.
|
12
|
+
% erl -pa /var/lib/gems/1.8/gems/poolparty-0.2.42/lib/erlang/messenger/ebin -kernel inet_dist_listen_min 7000 inet_dist_listen_max 7050 -sname client -setcookie poolparty -run pm_client start -run pm_client get_load cpu -run erlang init stop
|
13
13
|
|
14
|
-
% cd /var/poolparty && gem uninstall poolparty && wget http://github.com/auser/poolparty/tree/master%2Fpkg%2Fpoolparty-latest.gem?raw=true -O poolparty-latest.gem 2>&1 && gem install --no-ri --no-rdoc poolparty-latest.gem
|
14
|
+
% cd /var/poolparty && gem uninstall poolparty && wget http://github.com/auser/poolparty/tree/master%2Fpkg%2Fpoolparty-latest.gem?raw=true -O poolparty-latest.gem 2>&1 && gem install --no-ri --no-rdoc poolparty-latest.gem
|
15
|
+
|
16
|
+
% LOAD TESTING
|
17
|
+
% ab -n 10000 -c 5 http://75.101.162.232/
|
@@ -27,12 +27,14 @@ module PoolParty
|
|
27
27
|
|
28
28
|
# Service is required
|
29
29
|
has_service(:name => "haproxy", :ensures => "running")
|
30
|
+
|
31
|
+
has_exec(:name => "reloadhaproxy", :command => "/etc/init.d/haproxy reload", :requires => get_package("haproxy"))
|
30
32
|
|
31
33
|
# These can also be passed in via hash
|
32
34
|
has_remotefile(:name => "/etc/haproxy.cfg") do
|
33
35
|
mode 644
|
34
36
|
requires get_package("haproxy")
|
35
|
-
notify
|
37
|
+
notify get_exec("reloadhaproxy")
|
36
38
|
template File.join(File.dirname(__FILE__), "..", "templates/haproxy.conf")
|
37
39
|
end
|
38
40
|
end
|
@@ -60,6 +60,10 @@ module PoolParty
|
|
60
60
|
requires get_gempackage("poolparty-latest")
|
61
61
|
command(PoolParty::Remote::RemoteInstance.puppet_master_rerun_command)
|
62
62
|
end
|
63
|
+
has_cron(:name => "Load handler", :user => Base.user, :minute => "*/4") do
|
64
|
+
requires get_gempackage("poolparty-latest")
|
65
|
+
command(". /etc/profile && cloud-handle-load")
|
66
|
+
end
|
63
67
|
end
|
64
68
|
execute_on_node do
|
65
69
|
has_cron(:name => "puppetd runner", :user => Base.user, :minute => "*/5") do
|
data/lib/poolparty/net/remote.rb
CHANGED
@@ -12,7 +12,7 @@ module PoolParty
|
|
12
12
|
self.class.send :attr_reader, :remote_base
|
13
13
|
mod = "#{t}".preserved_module_constant
|
14
14
|
|
15
|
-
mod.send :include, PoolParty::Remote::RemoterBase
|
15
|
+
# mod.send :include, PoolParty::Remote::RemoterBase
|
16
16
|
self.class.send :include, mod
|
17
17
|
self.extend mod
|
18
18
|
|
@@ -18,11 +18,12 @@ module PoolParty
|
|
18
18
|
:availability_zone => nil,
|
19
19
|
:size => "#{size || Base.size}")
|
20
20
|
begin
|
21
|
-
|
22
|
-
|
21
|
+
h = EC2ResponseObject.get_hash_from_response(instance)
|
22
|
+
h = instance.instancesSet.item.first
|
23
23
|
rescue Exception => e
|
24
|
+
h = instance
|
24
25
|
end
|
25
|
-
|
26
|
+
h
|
26
27
|
end
|
27
28
|
# Terminate an instance by id
|
28
29
|
def terminate_instance!(instance_id=nil)
|
@@ -46,15 +47,22 @@ module PoolParty
|
|
46
47
|
:hostname => h[:ip],
|
47
48
|
:ip => h[:ip].convert_from_ec2_to_ip
|
48
49
|
})
|
49
|
-
end
|
50
|
+
end
|
50
51
|
end
|
51
52
|
# Get the s3 description for the response in a hash format
|
52
53
|
def get_instances_description
|
53
54
|
EC2ResponseObject.get_descriptions(ec2.describe_instances).sort_by {|a| a[:launching_time]}
|
54
55
|
end
|
55
56
|
|
56
|
-
def after_launch_master(instance=nil)
|
57
|
-
|
57
|
+
def after_launch_master(instance=nil)
|
58
|
+
begin
|
59
|
+
when_no_pending_instances do
|
60
|
+
ec2.associate_address(:instance_id => instance.instanceId, :public_ip => set_master_ip_to) if set_master_ip_to && instance
|
61
|
+
end
|
62
|
+
rescue Exception => e
|
63
|
+
end
|
64
|
+
reset_remoter_base!
|
65
|
+
when_all_assigned_ips {wait "2.seconds"}
|
58
66
|
end
|
59
67
|
|
60
68
|
# Help create a keypair for the cloud
|
@@ -92,7 +100,7 @@ module PoolParty
|
|
92
100
|
]
|
93
101
|
end
|
94
102
|
|
95
|
-
def
|
103
|
+
def reset_base!
|
96
104
|
@describe_instances = @cached_descriptions = nil
|
97
105
|
end
|
98
106
|
end
|
@@ -131,6 +139,7 @@ class EC2ResponseObject
|
|
131
139
|
rs ||= rs.respond_to?(:instancesSet) ? rs.instancesSet : rs
|
132
140
|
rs.reject! {|a| a.nil? || a.empty? }
|
133
141
|
rescue Exception => e
|
142
|
+
resp
|
134
143
|
end
|
135
144
|
rs
|
136
145
|
end
|
@@ -105,9 +105,12 @@ module PoolParty
|
|
105
105
|
out
|
106
106
|
end
|
107
107
|
def request_launch_master_instance
|
108
|
-
|
108
|
+
inst = launch_new_instance!
|
109
|
+
wait "5.seconds"
|
110
|
+
when_no_pending_instances {after_launch_master(inst)}
|
109
111
|
end
|
110
|
-
def after_launch_master(h={})
|
112
|
+
def after_launch_master(h={})
|
113
|
+
vputs "After launch master in remoter"
|
111
114
|
end
|
112
115
|
# Let's terminate an instance that is not the master instance
|
113
116
|
def request_termination_of_non_master_instance
|
@@ -116,12 +119,16 @@ module PoolParty
|
|
116
119
|
end
|
117
120
|
# Can we start a new instance?
|
118
121
|
def can_start_a_new_instance?
|
119
|
-
maximum_number_of_instances_are_not_running?
|
122
|
+
maximum_number_of_instances_are_not_running? && list_of_pending_instances.size == 0
|
120
123
|
end
|
121
|
-
# Are the maximum number of instances running?
|
124
|
+
# Are the maximum number of instances not running?
|
122
125
|
def maximum_number_of_instances_are_not_running?
|
123
126
|
list_of_running_instances.size < maximum_instances.to_i
|
124
127
|
end
|
128
|
+
# Are the maximum number of instances running?
|
129
|
+
def maximum_number_of_instances_are_running?
|
130
|
+
list_of_running_instances.size >= maximum_instances.to_i
|
131
|
+
end
|
125
132
|
# Launch new instance while waiting for the number of pending instances
|
126
133
|
# to be zero before actually launching. This ensures that we only
|
127
134
|
# launch one instance at a time
|
@@ -140,6 +147,19 @@ module PoolParty
|
|
140
147
|
when_no_pending_instances(&block)
|
141
148
|
end
|
142
149
|
end
|
150
|
+
# A convenience method for waiting until all the instances have an ip
|
151
|
+
# assigned to them. This is useful when shifting the ip addresses
|
152
|
+
# around on the instances
|
153
|
+
def when_all_assigned_ips(&block)
|
154
|
+
reset!
|
155
|
+
if list_of_nonterminated_instances.select {|a| a.ip == "not.assigned" }.empty?
|
156
|
+
block.call if block
|
157
|
+
else
|
158
|
+
vprint "."
|
159
|
+
wait "5.seconds"
|
160
|
+
when_all_assigned_ips(&block)
|
161
|
+
end
|
162
|
+
end
|
143
163
|
|
144
164
|
# This will launch the minimum_instances if the minimum number of instances are not running
|
145
165
|
# If the minimum number of instances are not running and if we can start a new instance
|
@@ -158,13 +178,14 @@ module PoolParty
|
|
158
178
|
when_no_pending_instances do
|
159
179
|
wait "10.seconds" # Give some time for ssh to startup
|
160
180
|
@num_instances = list_of_running_instances.size
|
181
|
+
vputs "(@num_instances - (num))..(@num_instances): #{(@num_instances - (num))..(@num_instances)}"
|
161
182
|
last_instances = nonmaster_nonterminated_instances[(@num_instances - (num))..(@num_instances)]
|
162
183
|
last_instances.each do |inst|
|
163
184
|
PoolParty::Provisioner.provision_slave(inst, self, false) unless inst.master?
|
164
185
|
cmd = ". /etc/profile && cloud-provision -i #{inst.name.gsub(/node/, '')} #{unix_hide_string} &"
|
165
186
|
Kernel.system cmd
|
166
187
|
end
|
167
|
-
PoolParty::Provisioner.reconfigure_master(self
|
188
|
+
PoolParty::Provisioner.reconfigure_master(self)
|
168
189
|
end
|
169
190
|
end
|
170
191
|
# Launch the master and let the master handle the starting of the cloud
|
@@ -176,6 +197,7 @@ module PoolParty
|
|
176
197
|
vputs "Requesting to launch new instance"
|
177
198
|
logger.debug "Launching master"
|
178
199
|
request_launch_master_instance if list_of_pending_instances.size.zero? && can_start_a_new_instance? && !is_master_running?
|
200
|
+
reset!
|
179
201
|
|
180
202
|
vputs "Waiting for there to be no pending instances..."
|
181
203
|
when_no_pending_instances do
|
@@ -77,7 +77,7 @@ module PoolParty
|
|
77
77
|
# If no keypair is passed, select them all
|
78
78
|
def list_of_instances(keyp=nil)
|
79
79
|
key = keyp ? keyp : keypair
|
80
|
-
@describe_instances ||= describe_instances.select {|a| key ? a[:keypair] == key : true }
|
80
|
+
@describe_instances ||= describe_instances.select {|a| key ? a[:keypair] == key : true }
|
81
81
|
end
|
82
82
|
# Instances
|
83
83
|
# Get the master from the cloud
|
@@ -90,8 +90,9 @@ module PoolParty
|
|
90
90
|
def create_keypair
|
91
91
|
end
|
92
92
|
# Reset the cache of descriptions
|
93
|
-
def
|
93
|
+
def reset_remoter_base!
|
94
94
|
@describe_instances = nil
|
95
|
+
reset_base!
|
95
96
|
end
|
96
97
|
def self.included(other)
|
97
98
|
PoolParty.register_remote_base(self.class.to_s.downcase.to_sym)
|
data/lib/poolparty/pool/cloud.rb
CHANGED
data/lib/poolparty/version.rb
CHANGED
data/poolparty.gemspec
CHANGED
@@ -41,7 +41,7 @@ describe "ec2 remote base" do
|
|
41
41
|
@tr.launch_new_instance!
|
42
42
|
end
|
43
43
|
it "should get the hash response from EC2ResponseObject" do
|
44
|
-
EC2ResponseObject.should_receive(:get_hash_from_response).
|
44
|
+
EC2ResponseObject.should_receive(:get_hash_from_response).and_return true
|
45
45
|
@tr.launch_new_instance!
|
46
46
|
end
|
47
47
|
end
|
@@ -12,6 +12,7 @@ module Hype
|
|
12
12
|
end
|
13
13
|
class TestClass
|
14
14
|
include Remote
|
15
|
+
include RemoterBase
|
15
16
|
|
16
17
|
def keypair
|
17
18
|
"fake_keypair"
|
@@ -134,7 +135,7 @@ describe "Remote" do
|
|
134
135
|
end
|
135
136
|
describe "can_start_a_new_instance?" do
|
136
137
|
it "should be true because the maximum instances are not running" do
|
137
|
-
@tc.can_start_a_new_instance?.should ==
|
138
|
+
@tc.can_start_a_new_instance?.should == false
|
138
139
|
end
|
139
140
|
it "should say that we cannot start a new instance because we are at the maximum instances" do
|
140
141
|
add_stub_instance_to(@tc, 7)
|
data/website/index.html
CHANGED
@@ -34,7 +34,7 @@
|
|
34
34
|
<h1>PoolParty</h1>
|
35
35
|
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/poolparty"; return false'>
|
36
36
|
<p>Get Version</p>
|
37
|
-
<a href="http://rubyforge.org/projects/poolparty" class="numbers">0.2.
|
37
|
+
<a href="http://rubyforge.org/projects/poolparty" class="numbers">0.2.44</a>
|
38
38
|
</div>
|
39
39
|
<h1>‘Easy cloud computing’</h1>
|
40
40
|
<h2>What</h2>
|