our-eel-hacks 0.0.13 → 0.0.14
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/lib/our-eel-hacks/autoscaler.rb +5 -4
- data/spec/autoscaler.rb +27 -0
- metadata +11 -7
@@ -99,6 +99,7 @@ module OurEelHacks
|
|
99
99
|
logger.info{ "Autoscaler configured for #{flavor || "{{unknown flavor}}"}"}
|
100
100
|
|
101
101
|
update_dynos(dyno_info.count, Time.now)
|
102
|
+
update_scaling_delay(0)
|
102
103
|
end
|
103
104
|
|
104
105
|
MILLIS_PER_DAY = 24 * 60 * 60 * 1000
|
@@ -152,7 +153,7 @@ module OurEelHacks
|
|
152
153
|
|
153
154
|
set_dynos(target_dynos, moment)
|
154
155
|
|
155
|
-
|
156
|
+
update_scaling_delay(starting_wait)
|
156
157
|
rescue => ex
|
157
158
|
logger.warn{ "Problem scaling: #{ex.inspect} \t#{ex.backtrace.join("\t\n")}" }
|
158
159
|
end
|
@@ -193,15 +194,15 @@ module OurEelHacks
|
|
193
194
|
return 0
|
194
195
|
end
|
195
196
|
|
196
|
-
def
|
197
|
+
def update_scaling_delay(starting_wait)
|
198
|
+
@millis_til_next_scale = scaling_frequency * @dynos
|
197
199
|
if starting_wait > millis_til_next_scale
|
198
|
-
@millis_til_next_scale = rand((starting_wait
|
200
|
+
@millis_til_next_scale = rand((@millis_til_next_scale..starting_wait))
|
199
201
|
end
|
200
202
|
end
|
201
203
|
|
202
204
|
def update_dynos(new_value, moment)
|
203
205
|
if new_value != dynos
|
204
|
-
@millis_til_next_scale = scaling_frequency * new_value
|
205
206
|
@last_scaled = moment
|
206
207
|
@entered_soft = moment
|
207
208
|
end
|
data/spec/autoscaler.rb
CHANGED
@@ -56,10 +56,19 @@ describe OurEelHacks::Autoscaler do
|
|
56
56
|
Time.now
|
57
57
|
end
|
58
58
|
|
59
|
+
before :each do
|
60
|
+
@time_index = 0
|
61
|
+
end
|
62
|
+
|
59
63
|
def time_adjust(millis)
|
64
|
+
@time_index = millis
|
60
65
|
Time.stub!(:now).and_return(Time.at(starting_time, millis * 1000))
|
61
66
|
end
|
62
67
|
|
68
|
+
def time_advance(millis)
|
69
|
+
time_adjust(@time_index + millis)
|
70
|
+
end
|
71
|
+
|
63
72
|
let :logger do
|
64
73
|
Logger.new($stdout).tap{|lgr| lgr.level = Logger::DEBUG }
|
65
74
|
end
|
@@ -125,6 +134,24 @@ describe OurEelHacks::Autoscaler do
|
|
125
134
|
heroku.should_receive(:ps_scale).with(app_name, hash_including(:qty => 2))
|
126
135
|
autoscaler.scale(hard_low)
|
127
136
|
end
|
137
|
+
|
138
|
+
it "should adjust its timing to break cadence after scaling down", :pending => "building VCR cassette" do
|
139
|
+
autoscaler.scale(hard_low)
|
140
|
+
autoscaler.millis_til_next_scale.should < expected_scale_frequency
|
141
|
+
autoscaler.millis_til_next_scale.should > 2 * scaling_freq
|
142
|
+
|
143
|
+
time_advance(autoscaler.millis_til_next_scale + 5)
|
144
|
+
|
145
|
+
autoscaler.scale(ideal_value)
|
146
|
+
|
147
|
+
autoscaler.millis_til_next_scale.should == 2 * scaling_freq
|
148
|
+
|
149
|
+
time_advance((2 * scaling_freq) + 5)
|
150
|
+
|
151
|
+
autoscaler.scale(hard_low)
|
152
|
+
autoscaler.millis_til_next_scale.should < 2 * scaling_freq
|
153
|
+
autoscaler.millis_til_next_scale.should > scaling_freq
|
154
|
+
end
|
128
155
|
end
|
129
156
|
|
130
157
|
describe "soft upper limit" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: our-eel-hacks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.14
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-05-24 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: corundum
|
16
|
-
requirement: &
|
16
|
+
requirement: &81350710 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,18 +21,22 @@ dependencies:
|
|
21
21
|
version: 0.0.1
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *81350710
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: heroku
|
27
|
-
requirement: &
|
27
|
+
requirement: &81465420 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 2.25.0
|
33
|
+
segments:
|
34
|
+
- 2
|
35
|
+
- 25
|
36
|
+
- 0
|
33
37
|
type: :runtime
|
34
38
|
prerelease: false
|
35
|
-
version_requirements: *
|
39
|
+
version_requirements: *81465420
|
36
40
|
description: ! " Middleware for Rack and Sidekiq to scale heroku.\n\n A heroku process
|
37
41
|
knows everything it needs in order to scale itself. A little configuration, and
|
38
42
|
you're set.\n"
|
@@ -64,7 +68,7 @@ rdoc_options:
|
|
64
68
|
- --main
|
65
69
|
- doc/README
|
66
70
|
- --title
|
67
|
-
- our-eel-hacks-0.0.
|
71
|
+
- our-eel-hacks-0.0.14 RDoc
|
68
72
|
require_paths:
|
69
73
|
- lib/
|
70
74
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -75,7 +79,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
75
79
|
version: '0'
|
76
80
|
segments:
|
77
81
|
- 0
|
78
|
-
hash:
|
82
|
+
hash: 962110657
|
79
83
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
84
|
none: false
|
81
85
|
requirements:
|