Permalink
Browse files

Reduce bosh vms timeout from 30 seconds to 5.

Change-Id: Iebef52d589058b357337bd0db52c627f26735b0a
  • Loading branch information...
1 parent 0968cb0 commit 0a724f7f7cbad8c9185f07104015f41180f4db8d Vadim Spivak committed Nov 9, 2012
Showing with 13 additions and 12 deletions.
  1. +2 −3 director/lib/director/jobs/vm_state.rb
  2. +11 −9 director/spec/unit/jobs/vm_state_spec.rb
@@ -3,13 +3,13 @@
module Bosh::Director
module Jobs
class VmState < BaseJob
+ TIMEOUT = 5
@queue = :normal
# @param [Integer] deployment_id Deployment id
def initialize(deployment_id)
super
-
@deployment_id = deployment_id
end
@@ -30,14 +30,13 @@ def perform
def process_vm(vm)
ips = []
- # TODO: properly handle nil agent_id
- agent = AgentClient.new(vm.agent_id)
job_name = nil
job_state = nil
resource_pool = nil
index = nil
begin
+ agent = AgentClient.new(vm.agent_id, :timeout => TIMEOUT)
agent_state = agent.get_state
agent_state["networks"].each_value do |network|
ips << network["ip"]
@@ -5,15 +5,16 @@
describe Bosh::Director::Jobs::VmState do
before(:each) do
- @deployment = Bosh::Director::Models::Deployment.make
+ @deployment = BD::Models::Deployment.make
@result_file = mock("result_file")
- Bosh::Director::Config.stub!(:result).and_return(@result_file)
+ BD::Config.stub!(:result).and_return(@result_file)
end
it "parses agent info into vm_state" do
- vm = Bosh::Director::Models::Vm.make(:deployment => @deployment, :agent_id => "agent-1", :cid => "vm-1")
+ BDM::Vm.make(:deployment => @deployment,
+ :agent_id => "agent-1", :cid => "vm-1")
agent = mock("agent")
- Bosh::Director::AgentClient.stub!(:new).with("agent-1").and_return(agent)
+ BD::AgentClient.stub!(:new).with("agent-1", :timeout => 5).and_return(agent)
agent_state = { "vm_cid" => "vm-1",
"networks" => {"test" => {"ip" => "1.1.1.1"}},
"agent_id" => "agent-1",
@@ -30,15 +31,16 @@
status["resource_pool"].should == "test_resource_pool"
end
- job = Bosh::Director::Jobs::VmState.new(@deployment.id)
+ job = BD::Jobs::VmState.new(@deployment.id)
job.perform
end
it "should handle unresponsive agents" do
- vm = Bosh::Director::Models::Vm.make(:deployment => @deployment, :agent_id => "agent-1", :cid => "vm-1")
+ BDM::Vm.make(:deployment => @deployment, :agent_id => "agent-1",
+ :cid => "vm-1")
agent = mock("agent")
- Bosh::Director::AgentClient.stub!(:new).with("agent-1").and_return(agent)
- agent.should_receive(:get_state).and_raise(Bosh::Director::RpcTimeout)
+ BD::AgentClient.stub!(:new).with("agent-1", :timeout => 5).and_return(agent)
+ agent.should_receive(:get_state).and_raise(BD::RpcTimeout)
@result_file.should_receive(:write).with do |agent_status|
status = JSON.parse(agent_status)
@@ -47,7 +49,7 @@
status["job_state"].should == "unresponsive agent"
end
- job = Bosh::Director::Jobs::VmState.new(@deployment.id)
+ job = BD::Jobs::VmState.new(@deployment.id)
job.perform
end
end

0 comments on commit 0a724f7

Please sign in to comment.