Permalink
Browse files

Pass cc host/port/task_id to stager

Supply the stager with the information it needs to interact with CC
apis.

Test plan:
- Unit tests pass
- Can deploy an app

Change-Id: I646e2d681696a03a5b204d69d7faca4e9dd84a88
  • Loading branch information...
1 parent 61aae1b commit 23be293fd3c694e77f96ede44e16c65ad5eb9932 mpage committed Oct 20, 2011
View
@@ -14,7 +14,7 @@ gem 'vcap_staging', '= 0.1.22'
# For queuing staging tasks
gem 'em-hiredis'
-gem 'vcap_stager_ipc'
+gem 'vcap_stager_ipc', '= 0.0.2'
# Databases
gem 'sqlite3'
@@ -137,7 +137,7 @@ GEM
tzinfo (0.3.26)
uuidtools (2.1.2)
vcap_logging (0.1.0)
- vcap_stager_ipc (0.0.1)
+ vcap_stager_ipc (0.0.2)
eventmachine
rake
vcap_common
@@ -181,6 +181,6 @@ DEPENDENCIES
uuidtools
vcap_common!
vcap_logging
- vcap_stager_ipc
+ vcap_stager_ipc (= 0.0.2)
vcap_staging (= 0.1.11)
yajl-ruby (>= 0.7.9)
@@ -36,6 +36,11 @@ def initialize(app, opts={})
tmpdir = opts[:tmpdir] || AppConfig[:directories][:tmpdir]
@upload_path = File.join(tmpdir, "staged_upload_#{app.id}_#{@task_id}.tgz")
@nats = opts[:nats] || NATS.client
+ @cc_info = {
+ :host => CloudController.bind_address,
+ :port => CloudController.external_port,
+ :task_id => @task_id,
+ }
end
def run(timeout=AppConfig[:staging][:max_staging_runtime])
@@ -45,6 +50,7 @@ def run(timeout=AppConfig[:staging][:max_staging_runtime])
@app.staging_task_properties,
@download_uri,
@upload_uri,
+ @cc_info,
timeout)
rescue VCAP::Stager::Ipc::RequestTimeoutError
result = {'error' => 'Timed out waiting for reply from stager'}
Binary file not shown.
Binary file not shown.
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
s.version = VCAP::CloudController::Ipc::VERSION
s.authors = ["mpage"]
s.email = ["mpage@vmware.com"]
- s.homepage = "www.cloudfoundry.com"
+ s.homepage = "http://www.cloudfoundry.com"
s.summary = %q{Library for communicating with Cloud Controllers}
s.description = %q{Provides clients for ineracting with CCs}
View
@@ -10,8 +10,8 @@ gem 'yajl-ruby', '>= 0.7.9'
gem 'vcap_common'
gem 'vcap_logging', '>= 0.1.1'
gem 'vcap_staging', '>= 0.1.11'
-gem 'vcap_stager_ipc'
-gem 'vcap_cloud_controller_ipc', :path => '../cloud_controller_ipc'
+gem 'vcap_stager_ipc', '= 0.0.2'
+gem 'vcap_cloud_controller_ipc'
group :test do
gem 'rspec'
View
@@ -1,10 +1,3 @@
-PATH
- remote: ../cloud_controller_ipc
- specs:
- vcap_cloud_controller_ipc (0.0.1)
- rake
- yajl-ruby
-
GEM
remote: http://rubygems.org/
specs:
@@ -44,6 +37,9 @@ GEM
eventmachine (>= 0.12.6)
rack (>= 1.0.0)
tilt (1.3.2)
+ vcap_cloud_controller_ipc (0.0.1)
+ rake
+ yajl-ruby
vcap_common (0.99)
eventmachine (~> 0.12.10)
logging (>= 1.5.0)
@@ -52,7 +48,7 @@ GEM
thin
yajl-ruby
vcap_logging (0.1.1)
- vcap_stager_ipc (0.0.1)
+ vcap_stager_ipc (0.0.2)
eventmachine
rake
vcap_common
@@ -80,10 +76,10 @@ DEPENDENCIES
rest-client (= 1.6.7)
rspec
sinatra
- vcap_cloud_controller_ipc!
+ vcap_cloud_controller_ipc
vcap_common
vcap_logging (>= 0.1.1)
- vcap_stager_ipc
+ vcap_stager_ipc (= 0.0.2)
vcap_staging (>= 0.1.11)
webmock
yajl-ruby (>= 0.7.9)
@@ -46,7 +46,7 @@ def run
# Stops receiving new tasks, waits for existing tasks to finish, then stops.
def shutdown
@logger.info("Shutdown initiated, waiting for remaining #{@task_mgr.num_tasks} task(s) to finish")
- @channels.each {|c| c.close }
+ teardown_subscriptions()
@task_mgr.on_idle do
@logger.info("All tasks completed. Exiting!")
EM.stop
@@ -103,6 +103,7 @@ def handle_request(msg)
req.args['app_properties'],
req.args['download_uri'],
req.args['upload_uri'],
+ req.args['cc_info'],
resp)
@task_mgr.add_task(task)
else
@@ -45,12 +45,13 @@ def set_defaults(defaults={})
# :resources => Resource limits
# @param download_uri String Where the stager can fetch the zipped application from.
# @param upload_uri String Where the stager should PUT the gzipped droplet
- def initialize(app_id, props, download_uri, upload_uri, response, opts={})
+ def initialize(app_id, props, download_uri, upload_uri, cc_info, response, opts={})
@task_id = VCAP.secure_uuid
@app_id = app_id
@app_props = props
@download_uri = download_uri
@upload_uri = upload_uri
+ @cc_info = cc_info
@response = response
@vcap_logger = VCAP::Logging.logger('vcap.stager.task')
@@ -82,7 +83,7 @@ def perform(&callback)
task_logger = VCAP::Stager::TaskLogger.new(@vcap_logger)
task_logger.info("Starting staging operation")
@vcap_logger.debug("app_id=#{@app_id}, properties=#{@app_props}")
- @vcap_logger.debug("download_uri=#{@download_uri} upload_uri=#{@upload_uri} notify_sub=#{@notify_subj}")
+ @vcap_logger.debug("download_uri=#{@download_uri} upload_uri=#{@upload_uri} cc_info=#{@cc_info}")
task_logger.info("Setting up temporary directories")
dirs = create_staging_dirs(@tmpdir_base)
@@ -84,7 +84,7 @@ class DummyHandler < Sinatra::Base
NATS.start(:uri => @nats_server.uri) do |nats|
cli = VCAP::Stager::Ipc::FiberedNatsClient.new(nats)
Fiber.new do
- result = cli.add_task(app_id, @app_props, dl_uri, ul_uri, 5)
+ result = cli.add_task(app_id, @app_props, dl_uri, ul_uri, {}, 5)
EM.stop
end.resume
end
@@ -60,9 +60,9 @@
tm = VCAP::Stager::TaskManager.new(3)
task = make_mock_task(1)
task.stub(:user).and_return(nil)
- tm.should_receive(:event).with(:task_completed, task, 'test')
+ tm.should_receive(:event).with(:task_completed, task, {})
tm.should_receive(:event).with(:idle)
- tm.send(:task_completed, task, 'test')
+ tm.send(:task_completed, task, {})
end
end
@@ -5,7 +5,7 @@
describe VCAP::Stager::Task do
describe '#creating_staging_dirs' do
it 'should create the basic directory structure needed for staging' do
- task = VCAP::Stager::Task.new(nil, nil, nil, nil, nil)
+ task = VCAP::Stager::Task.new(nil, nil, nil, nil, nil, nil)
dirs = task.send(:create_staging_dirs)
File.directory?(dirs[:base]).should be_true
File.directory?(dirs[:unstaged]).should be_true
@@ -17,7 +17,7 @@
describe '#download_app' do
before :each do
@tmp_dir = Dir.mktmpdir
- @task = VCAP::Stager::Task.new(1, nil, nil, nil, nil)
+ @task = VCAP::Stager::Task.new(1, nil, nil, nil, nil, nil)
end
after :each do
@@ -56,7 +56,7 @@
'fds' => 64,
},
}
- @task = VCAP::Stager::Task.new(1, @props, nil, nil, nil)
+ @task = VCAP::Stager::Task.new(1, @props, nil, nil, nil, nil)
end
after :each do
@@ -85,7 +85,7 @@
describe '#upload_app' do
before :each do
@tmp_dir = Dir.mktmpdir
- @task = VCAP::Stager::Task.new(1, nil, nil, nil, nil)
+ @task = VCAP::Stager::Task.new(1, nil, nil, nil, nil, nil)
end
after :each do
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -35,13 +35,18 @@ def initialize(nats, queue=VCAP::Stager::Ipc::REQUEST_QUEUE)
# :resources => Resource limits
# @param download_uri String Where the stager should fetch the app from
# @param upload_uri String Where the stager should upload the droplet to
+ # @param cc_info Hash Contact info for the interacting with the CC directly
+ # :host => IP of CC that issued the task
+ # :port => port
+ # :task_id => auth token that uniquely identifies this task
# @param timeout Integer How long to wait for a reply
- def add_task(app_id, props, download_uri, upload_uri, timeout=120)
+ def add_task(app_id, props, download_uri, upload_uri, cc_info, timeout=120)
args = {
:app_id => app_id,
:app_properties => props,
:download_uri => download_uri,
:upload_uri => upload_uri,
+ :cc_info => cc_info
}
req = VCAP::Stager::Ipc::Request.new(:add_task, args)
rep = send_request(req, @queue, timeout)
@@ -1,7 +1,7 @@
module VCAP
module Stager
module Ipc
- VERSION = '0.0.1'
+ VERSION = '0.0.2'
end
end
end
@@ -11,7 +11,7 @@
EM.run do
Fiber.new do
expect do
- client.add_task(1, {}, nil, nil, 0.1)
+ client.add_task(1, {}, nil, nil, {}, 0.1)
end.to raise_error(VCAP::Stager::Ipc::RequestTimeoutError)
EM.stop
end.resume

0 comments on commit 23be293

Please sign in to comment.