Puppet Plan: cd4peadm::install::from_4x::migrate_database

Defined in:
plans/install/from_4x/migrate_database.pp

Summary

Migrate data from the cd4pe and query databases of a 4.x instance

Overview

Migrates the cd4pe and query tables from an existing v4 instance to a v5 instance.

Overwrites any existing data in the 5.x target database.

Parameters:

  • cd4pe_4_target (Target)

    The target with kubectl access to the v4 instance



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'plans/install/from_4x/migrate_database.pp', line 10

plan cd4peadm::install::from_4x::migrate_database(
  Target $cd4pe_4_target,
) {
  $config = cd4peadm::config()
  $kubernetes_namespace = cd4peadm::default_for_value($cd4pe_4_target.vars['kubernetes_namespace'], 'default')

  $migration_timestamp = Timestamp.new.strftime('%Y-%m-%dT%H_%M_%S')
  # TODO We should probably check whether there is enough space in this dest dir,
  # maybe as a preflight? For now we document that they should have at least 10GB in /tmp.
  $dump_root = "/tmp/cd4pe-migration-${migration_timestamp}"
  $cd4pe_db_dump_path = file::join($dump_root, 'cd4pe_db_dump.tar')
  $query_db_dump_path = file::join($dump_root, 'query_db_dump.tar')

  $tmp_directory = run_plan('cd4peadm::install::from_4x::migrate_database_read_data',
    'cd4pe_4_target'      => $cd4pe_4_target,
    'dump_root'           => $dump_root,
  )

  run_plan('cd4peadm::install::from_4x::migrate_database_write_data',
    'dump_root' => $dump_root,
  )

  run_command("rm ${tmp_directory}/cd4pe_db_dump.tar", 'localhost')
  run_command("rm ${tmp_directory}/query_db_dump.tar", 'localhost')
  run_command("rmdir ${tmp_directory}", 'localhost')
}