Puppet Plan: cd4peadm::heap_dump

Defined in:
plans/heap_dump.pp

Summary

Download a JVM heap dump

Overview

This plan will download any heap dump that has been generated by an out-of-memory error in the pipelinesinfra Java service. If no such heap dump exists, no file will be downloaded. This plan does not trigger the creation of a heap dump.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'plans/heap_dump.pp', line 7

plan cd4peadm::heap_dump() {
  run_plan('cd4peadm::check_bolt_version')

  $config = cd4peadm::config()

  $downloads_path = cd4peadm::download_dir()
  if (!file::exists($downloads_path)) {
    without_default_logging() || {
      run_command("mkdir -p ${downloads_path}", 'localhost')
    }
  }

  out::message('Downloading backend heap dumps if available...')
  $heap_dump_volume = file::join(cd4peadm::runtime::volume_dir(), 'cd4pe-heap-dumps', '_data')
  $heap_dump_download_dir = file::join($downloads_path, 'heap_dumps', "${Timestamp.new.strftime('%Y-%m-%dT%H_%M_%S')}")
  $config['roles']['backend']['targets'].each |$target| {
    $heap_dump_dest = file::join($heap_dump_download_dir, $target.name)
    without_default_logging() || {
      cd4peadm::download_file($heap_dump_volume, $heap_dump_dest, $target, { '_run_as' => 'root', '_catch_errors' => true }, true)
    }
  }
  out::message("Find any downloaded heap dumps in ${heap_dump_download_dir}.")
}