Browse files

Removing staging task logs and redis.

[#45814227]

Change-Id: I6e72fb3aaf862810043926e36273bd93a4f00213
  • Loading branch information...
1 parent 4876523 commit e4028e79847f453f0942ac2f2095726904dda5cb Bleicke and Tony Hansmann committed Mar 14, 2013
View
1 lib/cloud_controller.rb
@@ -5,6 +5,7 @@
require "sequel"
require "thin"
require "yajl"
+# require "yaml"
require "eventmachine/schedule_sync"
View
9 lib/cloud_controller/api/files.rb
@@ -19,15 +19,6 @@ def files(id, search_param, path = nil, opts = {})
opts = { :allow_redirect => true }.merge(opts)
app = find_id_and_validate_access(:read, id)
- if path == "logs/staging.log"
- redis_client = Redis.new(:host => @config[:redis][:host],
- :port => @config[:redis][:port],
- :password => @config[:redis][:password])
- log = StagingTaskLog.fetch(id, redis_client)
- return [HTTP::OK, log.task_log] if log
- return HTTP::NOT_FOUND
- end
-
info = get_file_uri_for_search_param(app, path, search_param)
headers = {}
View
16 lib/cloud_controller/app_stager.rb
@@ -1,24 +1,17 @@
# Copyright (c) 2009-2012 VMware, Inc.
require "vcap/stager/client"
-require "redis"
-require "cloud_controller/staging_task_log"
require "cloud_controller/multi_response_nats_request"
module VCAP::CloudController
module AppStager
class << self
attr_reader :config, :message_bus, :stager_pool
- def configure(config, message_bus, stager_pool, redis_client = nil)
+ def configure(config, message_bus, stager_pool)
@config = config
@message_bus = message_bus
@stager_pool = stager_pool
- @redis_client = redis_client || Redis.new(
- :host => @config[:redis][:host],
- :port => @config[:redis][:port],
- :password => @config[:redis][:password]
- )
end
def run
@@ -30,7 +23,7 @@ def stage_app(app, options={}, &completion_callback)
raise Errors::AppPackageInvalid.new("The app package hash is empty")
end
- task = AppStagerTask.new(@config, @message_bus, @redis_client, app, stager_pool)
+ task = AppStagerTask.new(@config, @message_bus, app, stager_pool)
task.stage(options, &completion_callback)
end
@@ -58,10 +51,9 @@ def streaming_log_url
attr_reader :config
attr_reader :message_bus
- def initialize(config, message_bus, redis_client, app, stager_pool)
+ def initialize(config, message_bus, app, stager_pool)
@config = config
@message_bus = message_bus
- @redis_client = redis_client
@app = app
@stager_pool = stager_pool
end
@@ -183,8 +175,6 @@ def ensure_staging_is_current!
end
def staging_completion(stager_response)
- StagingTaskLog.new(@app.guid, stager_response.log, @redis_client).save
-
droplet_hash = Digest::SHA1.file(@upload_handle.upload_path).hexdigest
LegacyStaging.store_droplet(@app.guid, @upload_handle.upload_path)
View
35 lib/cloud_controller/staging_task_log.rb
@@ -1,35 +0,0 @@
-require 'steno'
-
-module VCAP::CloudController
- class StagingTaskLog
- class << self
-
- def key_for_id(app_id)
- "staging_task_log:#{app_id}"
- end
-
- def fetch(app_id, redis)
- key = key_for_id(app_id)
-
- logger = Steno.logger('vcap.stager.task_result.fetch')
- logger.debug("Fetching result for key '#{key}' from redis")
-
- res = redis.get(key)
- res ? StagingTaskLog.new(app_id, res, redis) : nil
- end
- end
-
- attr_reader :app_id, :task_log
-
- def initialize(app_id, task_log, redis)
- @app_id = app_id
- @task_log = task_log
- @redis = redis
- end
-
- def save
- key = self.class.key_for_id(@app_id)
- @redis.set(key, @task_log)
- end
- end
-end
View
30 spec/api/files_spec.rb
@@ -43,36 +43,6 @@ module VCAP::CloudController
last_response.status.should == 400
end
- it "should return the staging task log if it exists" do
- redis_client = MockRedis.new
-
- task_log = StagingTaskLog.new(@app.guid, "task log", redis_client)
- Redis.stub(:new).and_return(redis_client)
- StagingTaskLog.should_receive(:fetch).with(@app.guid, redis_client)
- .and_return(task_log)
-
- get("/v2/apps/#{@app.guid}/instances/1/files/logs/staging.log",
- {},
- headers_for(@developer))
-
- last_response.status.should == 200
- last_response.body.should == "task log"
- end
-
- it "should return 404 if staging task log is absent" do
- redis_client = MockRedis.new
-
- Redis.stub(:new).and_return(redis_client)
- StagingTaskLog.should_receive(:fetch).with(@app.guid, redis_client)
- .and_return(nil)
-
- get("/v2/apps/#{@app.guid}/instances/1/files/logs/staging.log",
- {},
- headers_for(@developer))
-
- last_response.status.should == 404
- end
-
context "dea returns file uri v1" do
it "should return 400 when accessing of the file URL fails", :use_nginx => false do
instance = 5
View
11 spec/app_stager_spec.rb
@@ -11,7 +11,7 @@ module VCAP::CloudController
before { MessageBus.instance.nats.client = mock_nats }
let(:mock_redis) { mock(:mock_redis).as_null_object }
- before { AppStager.configure({}, nil, stager_pool, mock_redis) }
+ before { AppStager.configure({}, nil, stager_pool) }
let(:stager_pool) { StagerPool.new({}, nil) }
before { stager_pool.stub(:find_stager => "staging-id") }
@@ -76,7 +76,7 @@ def self.it_requests_staging(options={})
with_em_and_thread { stage }
- task = AppStagerTask.new(nil, nil, nil, app, stager_pool)
+ task = AppStagerTask.new(nil, nil, app, stager_pool)
expected_data = task.staging_request(options[:async])
data_in_request.should == JSON.dump(expected_data)
end
@@ -123,11 +123,6 @@ def self.it_completes_staging
with_em_and_thread { stage }
end
- it "saves off staging log for short time" do
- mock_redis.should_receive(:set).with(StagingTaskLog.key_for_id(app.guid), "task-log")
- with_em_and_thread { stage }
- end
-
it "calls provided callback" do
callback_called = false
with_em_and_thread { stage { callback_called = true } }
@@ -481,7 +476,7 @@ def reply_with_staging_completion
end
def request(async=false)
- AppStagerTask.new(nil, nil, nil, @app, stager_pool).staging_request(async)
+ AppStagerTask.new(nil, nil, @app, stager_pool).staging_request(async)
end
def store_app_package(app)
View
47 spec/staging_task_log_spec.rb
@@ -1,47 +0,0 @@
-# Copyright (c) 2009-2012 VMware, Inc.
-
-require File.expand_path("../spec_helper", __FILE__)
-require "cloud_controller/staging_task_log"
-
-module VCAP::CloudController
- describe VCAP::CloudController::StagingTaskLog do
- before :each do
- @task_id = 'test_task'
- @log = 'Hello'
- @redis_mock = mock("mock redis")
- @task_log = StagingTaskLog.new(@task_id, @log, @redis_mock)
- @task_key = StagingTaskLog.key_for_id(@task_id)
- end
-
- describe '#save' do
- it 'should set a task result blob in redis' do
- @redis_mock.should_receive(:set).with(@task_key, @task_log.task_log)
- @task_log.save
- end
- end
-
- describe '#fetch' do
- it 'should fetch and decode an existing task result' do
- @redis_mock.should_receive(:get).with(@task_key).and_return(@log)
- res = StagingTaskLog.fetch(@task_id, @redis_mock)
- res.should be_instance_of(StagingTaskLog)
- end
-
- it 'should return nil if no key exists' do
- @redis_mock.should_receive(:get).with(@task_key).and_return(nil)
- res = StagingTaskLog.fetch(@task_id, @redis_mock)
- res.should be_nil
- end
-
- it 'should raise error when redis fetching fails' do
- error = RuntimeError.new("Mock Runtime Error from redis")
- @redis_mock.should_receive(:get).with(@task_key).and_raise(error)
- expect {
- StagingTaskLog.fetch(@task_id, @redis_mock)
- }.to raise_error { |e|
- e.should == error
- }
- end
- end
- end
-end

0 comments on commit e4028e7

Please sign in to comment.