Skip to content
This repository was archived by the owner on Aug 29, 2018. It is now read-only.

Commit b972b93

Browse files
committed
Inform user of the need to scale up when enabling HA on a scaled application
Bug 1256952 https://bugzilla.redhat.com/show_bug.cgi?id=1256952 When an application with more than one gear ha HA enabled, a short message will now be given stating the possible need to scale the application up to actually receive the second haproxy instance. In addition to a adding a new test, the `app_spec.rb` now requires 'net/ssh/multi' to allow the spec to be run on its own outside of the RHC spec test suite. This has been resolved.
1 parent 5eb2f92 commit b972b93

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

lib/rhc/commands/app.rb

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,20 @@ def tidy(app)
376376
syntax "<app> [--namespace NAME]"
377377
takes_application :argument => true
378378
def enable_ha(app)
379-
app_action :enable_ha
379+
rest_app = find_app
380+
381+
scaleup_needed = false
382+
gear_groups = rest_app.gear_groups
383+
gear_groups.each do |gg|
384+
scaleup_needed = true if gg.attributes["scales_from"] > 1
385+
end
380386

381-
results { say "#{app} is now highly available" }
387+
rest_app.send :enable_ha
388+
results do
389+
say "#{app} is now highly available"
390+
# If the application was already scaled, a scale up may be required.
391+
say "You may need to scale up the application to create an additional haproxy instance." if scaleup_needed
392+
end
382393
0
383394
end
384395

spec/rhc/commands/app_spec.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
require 'rhc/config'
55
require 'rhc/servers'
66
require 'resolv'
7+
require 'net/ssh/multi'
78

89
describe RHC::Commands::App do
910
let!(:rest_client){ MockRestClient.new }
@@ -933,6 +934,22 @@
933934
end
934935
end
935936

937+
describe 'app enable-ha on scaled application' do
938+
before do
939+
@domain = rest_client.add_domain("mockdomain")
940+
@app = @domain.add_application("app1", "mock_type", true)
941+
@app.add_cartridge('mock_cart-1')
942+
@app.scale_up
943+
end
944+
945+
let(:arguments) { ['app', 'enable-ha', 'app1'] }
946+
947+
it "should suggest scaling up to receive additional haproxy instances" do
948+
run_output.should match(/You may need to scale up/)
949+
expect{ run }.to exit_with_code(0)
950+
end
951+
end
952+
936953
describe "#create_app" do
937954
it("should list cartridges when a server error happens") do
938955
subject.should_receive(:list_cartridges)

0 commit comments

Comments
 (0)