Skip to content

Commit

Permalink
distinct end points for droplet download / upload
Browse files Browse the repository at this point in the history
  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
d committed Oct 4, 2012
1 parent c160f9f commit b0457b1
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 17 deletions.
3 changes: 0 additions & 3 deletions config/nginx.conf
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/cloud_controller/app_stager.rb
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/cloud_controller/dea/dea_client.rb
Expand Up @@ -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
Expand Down
14 changes: 9 additions & 5 deletions lib/cloud_controller/legacy_api/legacy_staging.rb
Expand Up @@ -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)
Expand Down Expand Up @@ -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
14 changes: 7 additions & 7 deletions spec/api/legacy_staging_spec.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit b0457b1

Please sign in to comment.