Permalink
Browse files

distinct end points for droplet download / upload

  CC reverts to the old way of handing out distinct end points to
stagers and DEA's. More specifically,
  - stagers upload through POST /staging/droplets/:guid
  - DEA's download through GET /staged_droplets/:id

  nginx emphatically warns against use of the "if" directive, as a dummy
I am really scared of the risk, plus our internal API doesn't have to
look shiny, so I'm playing safe.

  Test plan: deploy with nginx enabled, manually push an app and make
sure it stages and starts.

Change-Id: I95c91f7eb5fecbbc8ed42e313a23d57f40eb4238
  • Loading branch information...
1 parent c160f9f commit b0457b1937899c1f17a520135421e1e311d56f38 @d d committed Oct 3, 2012
View
@@ -82,9 +82,6 @@ http {
# Droplet uploads from the stager should be authenticated
location /staging/droplets/ {
- if ($request_method = GET) {
- proxy_pass http://cloud_controller;
- }
# Pass along auth header
set $auth_header $upstream_http_x_auth;
proxy_set_header Authorization $auth_header;
@@ -73,7 +73,7 @@ def staging_request(app)
:app_id => app.guid,
:properties => staging_task_properties(app),
:download_uri => LegacyStaging.app_uri(app.guid),
- :upload_uri => LegacyStaging.droplet_uri(app.guid)
+ :upload_uri => LegacyStaging.droplet_upload_uri(app.guid)
}
end
@@ -272,7 +272,7 @@ def start_app_message(app)
:prod => app.production,
:sha1 => app.droplet_hash,
:executableFile => AppStager.droplet_path(app),
- :executableUri => LegacyStaging.droplet_uri(app.guid),
+ :executableUri => LegacyStaging.droplet_download_uri(app.guid),
:version => app.version,
:services => app.service_bindings.map do |sb|
svc = sb.service_instance.service_plan.service
@@ -25,8 +25,12 @@ def app_uri(id)
staging_uri("#{APP_PATH}/#{id}")
end
- def droplet_uri(id)
- staging_uri("#{DROPLET_PATH}/#{id}")
+ def droplet_upload_uri(id)
+ staging_uri("/staging/droplets/#{id}")
+ end
+
+ def droplet_download_uri(id)
+ staging_uri("/staged_droplets/#{id}")
end
def with_upload_handle(id)
@@ -181,8 +185,8 @@ def tmpdir
end
end
- get "#{APP_PATH}/:id", :download_app
- post "#{DROPLET_PATH}/:id", :upload_droplet
- get "#{DROPLET_PATH}/:id", :download_droplet
+ get "/staging/apps/:id", :download_app
+ post "/staging/droplets/:id", :upload_droplet
+ get "/staged_droplets/:id", :download_droplet
end
end
@@ -57,9 +57,9 @@ module VCAP::CloudController
end
end
- describe "droplet_uri" do
+ describe "droplet_upload_uri" do
it "should return a uri to our cc" do
- uri = LegacyStaging.droplet_uri(app_guid)
+ uri = LegacyStaging.droplet_upload_uri(app_guid)
uri.should == "http://#{staging_user}:#{staging_password}@#{cc_addr}:#{cc_port}/staging/droplets/#{app_guid}"
end
end
@@ -149,7 +149,7 @@ module VCAP::CloudController
include_examples "staging bad auth", :post
end
- describe "GET /staging/droplets/:id" do
+ describe "GET /staged_droplets/:id" do
let(:app_obj) { Models::App.make }
before do
@@ -164,7 +164,7 @@ module VCAP::CloudController
f.write("droplet contents")
end
- get "/staging/droplets/#{app_obj.guid}"
+ get "/staged_droplets/#{app_obj.guid}"
last_response.status.should == 200
last_response.body.should == "droplet contents"
end
@@ -175,22 +175,22 @@ module VCAP::CloudController
f.write("droplet contents")
end
- get "/staging/droplets/#{app_obj.guid}"
+ get "/staged_droplets/#{app_obj.guid}"
last_response.status.should == 200
last_response.headers["X-Accel-Redirect"].should == "/droplets/droplet_#{app_obj.guid}"
end
end
context "with a valid app but no droplet" do
it "should return an error" do
- get "/staging/droplets/#{app_obj.guid}"
+ get "/staged_droplets/#{app_obj.guid}"
last_response.status.should == 400
end
end
context "with an invalid app" do
it "should return an error" do
- get "/staging/droplets/bad"
+ get "/staged_droplets/bad"
last_response.status.should == 404
end
end

0 comments on commit b0457b1

Please sign in to comment.