Class: Bosh::Director::LogsFetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/bosh/director/logs_fetcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(instance_manager, log_bundles_cleaner, logger) ⇒ LogsFetcher

Returns a new instance of LogsFetcher.

Parameters:



6
7
8
9
10
# File 'lib/bosh/director/logs_fetcher.rb', line 6

def initialize(instance_manager, log_bundles_cleaner, logger)
  @instance_manager = instance_manager
  @log_bundles_cleaner = log_bundles_cleaner
  @logger = logger
end

Instance Method Details

#fetch(instance, log_type, filters) ⇒ Object

Parameters:



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/bosh/director/logs_fetcher.rb', line 15

def fetch(instance, log_type, filters)
  @logger.info("Fetching logs from agent with log_type=#{log_type} filters=#{filters}")

  @log_bundles_cleaner.clean

  agent = @instance_manager.agent_client_for(instance)
  blobstore_id = nil

  stage = Config.event_log.begin_stage("Fetching logs for #{instance.job}/#{instance.uuid} (#{instance.index})", 1)
  stage.advance_and_track('Finding and packing log files') do
    fetch_logs_result = agent.fetch_logs(log_type, filters)
    blobstore_id = fetch_logs_result['blobstore_id']
  end

  if blobstore_id.nil?
    raise AgentTaskNoBlobstoreId,
          "Agent didn't return a blobstore object id for packaged logs"
  end

  @log_bundles_cleaner.register_blobstore_id(blobstore_id)

  blobstore_id
end