foreman_maintain 0.7.14 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f85f48176164ae330cdc34b3358f7a28e9db102b0a4a1a3f56096545914a80d7
4
- data.tar.gz: 218abc9daddc63f1ea18f4a652fe7c0ab29471d1ba57025b6fe4bfec1ef517ee
3
+ metadata.gz: ed8b16b2a22acb7bf2e2768976f2df46eb6a1b51b883904cbee0bb180869c5a4
4
+ data.tar.gz: 46473f96dba47ffc94f08fbb15fa031073852cdc234c8c701d5568a7727d269d
5
5
  SHA512:
6
- metadata.gz: 6298d9c15def6a3e6f3fca79c1a917c583f4af0bc0281559abdc96e82f15820975ad109d9443bbb412da8396a5df7b3b94a6a7a00cd28fce2b3af6cb5d97eaa0
7
- data.tar.gz: e572a81b1e74edc22985ef67e8e9d9e84af85161bb78105d32617962a90ddf016447e77a17cd7299254819e9987304709f991a65a2c4b4b59a95081c5c7c2490
6
+ metadata.gz: 76da2fe52b25ac48af18295caaa92dad1e2cb106a8aaded53adc02804da1ef2c021a6d336e10e4abea87d6aed1f9950a9b994cc6dba075b8b116a31ea9c6b706
7
+ data.tar.gz: d25955e6f87bfb863d050935bf4ed253c2afa55e1552ec17edcc76500c6d563d7fe318b84d68877c942c63facdd3c93d973591df5e93fedd9fd445a4ff4c845a
@@ -37,6 +37,6 @@ class Features::DynflowSidekiq < ForemanMaintain::Feature
37
37
  end
38
38
 
39
39
  def configured_instances
40
- Dir['/etc/foreman/dynflow/*.yml'].map { |config| File.basename(config, '.yml') }
40
+ Dir['/etc/foreman/dynflow/*'].map { |config| File.basename(config, '.yml') }
41
41
  end
42
42
  end
@@ -16,9 +16,14 @@ class Features::Katello < ForemanMaintain::Feature
16
16
  end
17
17
 
18
18
  def services
19
- [
20
- system_service('elasticsearch', 30)
21
- ]
19
+ if feature(:pulp2)
20
+ []
21
+ else
22
+ [
23
+ system_service('qpidd', 10),
24
+ system_service('qdrouterd', 10)
25
+ ]
26
+ end
22
27
  end
23
28
 
24
29
  # rubocop:disable Metrics/MethodLength
@@ -5,7 +5,7 @@ class Features::Pulp < ForemanMaintain::Feature
5
5
  label :pulp2
6
6
 
7
7
  confine do
8
- find_package('pulp-server')
8
+ find_package('pulp-server') && !check_min_version('katello-common', '4.0')
9
9
  end
10
10
  end
11
11
 
@@ -34,10 +34,4 @@ class Features::Pulp < ForemanMaintain::Feature
34
34
  '/etc/default/pulp_workers'
35
35
  ]
36
36
  end
37
-
38
- def exclude_from_backup
39
- # Exclude /var/lib/pulp/katello-export and /var/lib/pulp/cache
40
- # since the tar is run from /var/lib/pulp, list subdir paths only
41
- ['katello-export', 'cache']
42
- end
43
37
  end
@@ -11,21 +11,13 @@ class Features::Pulpcore < ForemanMaintain::Feature
11
11
  end
12
12
 
13
13
  def services
14
- self.class.pulpcore_common_services + configured_workers + [
14
+ self.class.pulpcore_common_services + [
15
15
  system_service('rh-redis5-redis', 5),
16
+ system_service('pulpcore-worker@*', 20, :all => true, :skip_enablement => true),
16
17
  system_service('httpd', 30)
17
18
  ]
18
19
  end
19
20
 
20
- def configured_workers
21
- names = Dir['/etc/systemd/system/multi-user.target.wants/pulpcore-worker@*.service']
22
- names = names.map { |f| File.basename(f) }
23
- names.map do |name|
24
- system_service(name, 20, :skip_enablement => true,
25
- :instance_parent_unit => 'pulpcore-worker@')
26
- end
27
- end
28
-
29
21
  def self.pulpcore_migration_services
30
22
  pulpcore_common_services + [
31
23
  ForemanMaintain::Utils.system_service('pulpcore-worker@1', 20),
@@ -137,7 +137,7 @@ class Features::Service < ForemanMaintain::Feature
137
137
 
138
138
  def filter_disabled_services!(action, service_list)
139
139
  if %w[start stop restart status].include?(action)
140
- service_list.select! { |service| !service.respond_to?(:enabled?) || service.enabled? }
140
+ service_list.select!(&:enabled?)
141
141
  end
142
142
  service_list
143
143
  end
@@ -30,7 +30,7 @@ module Procedures::Backup
30
30
  feature(:tar).run(
31
31
  :archive => File.join(@backup_dir, 'pulp_data.tar'),
32
32
  :command => 'create',
33
- :exclude => feature(:pulp2).exclude_from_backup,
33
+ :exclude => ['var/lib/pulp/katello-export'],
34
34
  :listed_incremental => File.join(@backup_dir, '.pulp.snar'),
35
35
  :transform => 's,^,var/lib/pulp/,S',
36
36
  :volume_size => @tar_volume_size,
@@ -3,13 +3,11 @@ module Procedures::Content
3
3
  metadata do
4
4
  description 'Prepare content for Pulp 3'
5
5
  for_feature :pulpcore
6
- param :quiet, 'Keep the output on a single line', :flag => true, :default => false
7
6
  end
8
7
 
9
8
  def run
10
9
  # use interactive to get realtime output
11
- env_vars = @quiet ? '' : 'preserve_output=true '
12
- puts execute!("#{env_vars}foreman-rake katello:pulp3_migration", :interactive => true)
10
+ puts execute!('foreman-rake katello:pulp3_migration', :interactive => true)
13
11
  end
14
12
  end
15
13
  end
@@ -2,10 +2,11 @@ module ForemanMaintain::Scenarios
2
2
  module Content
3
3
  class ContentBase < ForemanMaintain::Scenario
4
4
  def enable_and_start_services
5
+ add_step(Procedures::Service::Start)
5
6
  add_step(Procedures::Service::Enable.
6
7
  new(:only => Features::Pulpcore.pulpcore_migration_services))
7
8
  add_step(Procedures::Service::Start.
8
- new(:include => Features::Pulpcore.pulpcore_migration_services))
9
+ new(:only => Features::Pulpcore.pulpcore_migration_services))
9
10
  end
10
11
 
11
12
  def disable_and_stop_services
@@ -26,18 +27,12 @@ module ForemanMaintain::Scenarios
26
27
  def compose
27
28
  if feature(:satellite) && feature(:satellite).at_least_version?('6.9')
28
29
  enable_and_start_services
29
- add_step(Procedures::Content::Prepare.new(quiet: quiet?))
30
+ add_step(Procedures::Content::Prepare)
30
31
  disable_and_stop_services
31
32
  elsif !feature(:satellite)
32
- add_step(Procedures::Content::Prepare.new(quiet: quiet?))
33
+ add_step(Procedures::Content::Prepare)
33
34
  end
34
35
  end
35
-
36
- private
37
-
38
- def quiet?
39
- !!context.get(:quiet)
40
- end
41
36
  end
42
37
 
43
38
  class Switchover < ContentBase
@@ -65,7 +60,6 @@ module ForemanMaintain::Scenarios
65
60
 
66
61
  def compose
67
62
  if !feature(:satellite) || feature(:satellite).at_least_version?('6.9')
68
- enable_and_start_services if feature(:satellite)
69
63
  add_step(Procedures::Content::PrepareAbort)
70
64
  end
71
65
  end
@@ -103,24 +97,6 @@ module ForemanMaintain::Scenarios
103
97
  end
104
98
  end
105
99
 
106
- class CleanupRepositoryMetadata < ContentBase
107
- metadata do
108
- label :cleanup_repository_metadata
109
- description 'Remove old leftover repository metadata'
110
- param :remove_files, 'Actually remove the files? Otherwise a dryrun is performed.'
111
-
112
- manual_detection
113
- end
114
-
115
- def compose
116
- add_step_with_context(Procedures::Pulp::CleanupOldMetadataFiles)
117
- end
118
-
119
- def set_context_mapping
120
- context.map(:remove_files, Procedures::Pulp::CleanupOldMetadataFiles => :remove_files)
121
- end
122
- end
123
-
124
100
  class RemovePulp2 < ContentBase
125
101
  metadata do
126
102
  label :content_remove_pulp2
@@ -28,7 +28,6 @@ module Scenarios::Satellite_6_8
28
28
  add_steps(find_checks(:default))
29
29
  add_steps(find_checks(:pre_upgrade))
30
30
  add_step(Checks::Foreman::CheckpointSegments)
31
- add_step(Checks::Disk::AvailableSpacePostgresql12)
32
31
  add_step(Checks::Repositories::Validate.new(:version => '6.8'))
33
32
  end
34
33
  end
@@ -28,7 +28,6 @@ module Scenarios::Satellite_6_9
28
28
  add_steps(find_checks(:default))
29
29
  add_steps(find_checks(:pre_upgrade))
30
30
  add_step(Checks::Foreman::CheckpointSegments)
31
- add_step(Checks::Disk::AvailableSpacePostgresql12)
32
31
  add_step(Checks::Repositories::Validate.new(:version => '6.9'))
33
32
  end
34
33
  end
@@ -2,9 +2,8 @@ module ForemanMaintain
2
2
  module Cli
3
3
  class ContentCommand < Base
4
4
  subcommand 'prepare', 'Prepare content for Pulp 3' do
5
- option ['-q', '--quiet'], :flag, 'Keep the output on a single line'
6
5
  def execute
7
- run_scenarios_and_exit(Scenarios::Content::Prepare.new(:quiet => quiet?))
6
+ run_scenarios_and_exit(Scenarios::Content::Prepare.new)
8
7
  end
9
8
  end
10
9
 
@@ -35,17 +34,6 @@ module ForemanMaintain
35
34
  end
36
35
  end
37
36
 
38
- subcommand 'cleanup-repository-metadata', 'Cleanup old repository metadata under Pulp 2' do
39
- option ['-r', '--remove-files'], :flag, 'Remove the files instead of just listing them.',
40
- :attribute_name => :remove_files
41
-
42
- def execute
43
- run_scenarios_and_exit(
44
- Scenarios::Content::CleanupRepositoryMetadata.new(:remove_files => @remove_files)
45
- )
46
- end
47
- end
48
-
49
37
  subcommand 'remove-pulp2', 'Remove pulp2 and mongodb packages and data' do
50
38
  def execute
51
39
  run_scenarios_and_exit(Scenarios::Content::RemovePulp2.new)
@@ -15,7 +15,6 @@ module ForemanMaintain
15
15
  @reporter = reporter
16
16
  @scenarios = Array(scenarios)
17
17
  @quit = false
18
- @rescue = false
19
18
  @last_scenario = nil
20
19
  @last_scenario_continuation_confirmed = false
21
20
  @exit_code = 0
@@ -30,17 +29,12 @@ module ForemanMaintain
30
29
  @assumeyes
31
30
  end
32
31
 
33
- def rescue?
34
- @rescue
35
- end
36
-
37
32
  def run
38
33
  @scenarios.each do |scenario|
39
34
  run_scenario(scenario)
40
35
  next unless @quit
41
36
 
42
37
  if @rescue_scenario
43
- @rescue = true
44
38
  logger.debug('=== Rescue scenario found. Executing ===')
45
39
  execute_scenario_steps(@rescue_scenario, true)
46
40
  end
@@ -50,10 +44,10 @@ module ForemanMaintain
50
44
 
51
45
  def run_scenario(scenario)
52
46
  return if scenario.steps.empty?
53
- raise 'The runner is already in quit state' if quit? && !rescue?
47
+ raise 'The runner is already in quit state' if quit?
54
48
 
55
49
  confirm_scenario(scenario)
56
- return if quit? && !rescue?
50
+ return if quit?
57
51
 
58
52
  execute_scenario_steps(scenario)
59
53
  ensure
@@ -59,15 +59,12 @@ module ForemanMaintain
59
59
 
60
60
  private
61
61
 
62
- # rubocop:disable Metrics/MethodLength
63
62
  def run_interactively
64
63
  # use tmp files to capture output and exit status of the command when
65
64
  # running interactively
66
65
  log_file = Tempfile.open('captured-output')
67
66
  exit_file = Tempfile.open('captured-exit-code')
68
- Kernel.system(
69
- "bash -c '#{full_command}; echo $? > #{exit_file.path}' | tee -i #{log_file.path}"
70
- )
67
+ Kernel.system("script -qc '#{full_command}; echo $? > #{exit_file.path}' #{log_file.path}")
71
68
  File.open(log_file.path) { |f| @output = f.read }
72
69
  File.open(exit_file.path) do |f|
73
70
  exit_status = f.read.strip
@@ -81,7 +78,6 @@ module ForemanMaintain
81
78
  log_file.close
82
79
  exit_file.close
83
80
  end
84
- # rubocop:enable Metrics/MethodLength
85
81
 
86
82
  def run_non_interactively
87
83
  IO.popen(full_command, 'r+') do |f|
@@ -26,10 +26,6 @@ module ForemanMaintain
26
26
  execute!("df #{dir}|awk {'print $5'}|tail -1").to_i
27
27
  end
28
28
 
29
- def space_used
30
- convert_kb_to_mb(execute!("du -ks #{dir} | awk {'print $1'}").to_i)
31
- end
32
-
33
29
  private
34
30
 
35
31
  # In fio command, --direct option bypass the cache page
@@ -1,3 +1,3 @@
1
1
  module ForemanMaintain
2
- VERSION = '0.7.14'.freeze
2
+ VERSION = '0.8.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_maintain
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.14
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Nečas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-27 00:00:00.000000000 Z
11
+ date: 2021-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clamp
@@ -126,7 +126,6 @@ files:
126
126
  - definitions/checks/check_tmout.rb
127
127
  - definitions/checks/disk/available_space.rb
128
128
  - definitions/checks/disk/available_space_candlepin.rb
129
- - definitions/checks/disk/available_space_postgresql12.rb
130
129
  - definitions/checks/disk/performance.rb
131
130
  - definitions/checks/env_proxy.rb
132
131
  - definitions/checks/foreman/check_checkpoint_segments.rb
@@ -260,7 +259,6 @@ files:
260
259
  - definitions/procedures/packages/update_all_confirmation.rb
261
260
  - definitions/procedures/passenger_recycler.rb
262
261
  - definitions/procedures/prep_6_10_upgrade.rb
263
- - definitions/procedures/pulp/cleanup_old_metadata_files.rb
264
262
  - definitions/procedures/pulp/migrate.rb
265
263
  - definitions/procedures/pulp/remove.rb
266
264
  - definitions/procedures/pulpcore/migrate.rb
@@ -1,45 +0,0 @@
1
- module Checks
2
- module Disk
3
- class AvailableSpacePostgresql12 < ForemanMaintain::Check
4
- metadata do
5
- label :available_space_for_postgresql12
6
- description 'Check to make sure PostgreSQL 12 work directory has enough space for upgrade'
7
- confine do
8
- (feature(:foreman_database) || feature(:candlepin_database)) && \
9
- (file_exists?('/var/lib/pgsql') && \
10
- file_exists?('/var/opt/rh/rh-postgresql12'))
11
- end
12
- end
13
-
14
- def run
15
- assert(psql_12_available_space >= psql_9_consumed_space, warning_message, :warn => true)
16
- end
17
-
18
- def pgsql_dir(version)
19
- if version == 9
20
- '/var/lib/pgsql/'
21
- elsif version == 12
22
- '/var/opt/rh/rh-postgresql12/'
23
- end
24
- end
25
-
26
- def psql_9_consumed_space
27
- io_obj = ForemanMaintain::Utils::Disk::IODevice.new(pgsql_dir(9))
28
- io_obj.space_used
29
- end
30
-
31
- def psql_12_available_space
32
- io_obj = ForemanMaintain::Utils::Disk::IODevice.new(pgsql_dir(12))
33
- io_obj.available_space
34
- end
35
-
36
- def warning_message
37
- sat_version = feature(:satellite).current_version.version[0..2]
38
- "Satellite #{sat_version} uses PostgreSQL 12. \nThis changes PostgreSQL "\
39
- "work directory to #{pgsql_dir(12)}\n"\
40
- "The new work directory requires at least #{psql_9_consumed_space}"\
41
- 'MiB free space for upgrade!'
42
- end
43
- end
44
- end
45
- end
@@ -1,75 +0,0 @@
1
- require 'find'
2
- require 'rexml/document'
3
-
4
- module Procedures::Pulp
5
- class CleanupOldMetadataFiles < ForemanMaintain::Procedure
6
- metadata do
7
- description 'Cleanup old and unneeded yum metadata files from /var/lib/pulp/'
8
- confine do
9
- check_max_version('katello-common', '4.0')
10
- end
11
- param :remove_files, 'If true, will actually delete files, otherwise will print them out.'
12
- end
13
-
14
- PULP_METADATA_DIR = '/var/lib/pulp/published/yum/master/yum_distributor/'.freeze
15
- REPOMD_FILE = 'repomd.xml'.freeze
16
-
17
- def run
18
- return unless File.directory?(PULP_METADATA_DIR)
19
- found = []
20
-
21
- puts 'Warning: This command may cause reduced performance related to content operations.'
22
- message = 'Locating repository metadata (this may take a while)'
23
- with_spinner(message) do |spinner|
24
- Find.find(PULP_METADATA_DIR) do |path|
25
- next if File.basename(path) != REPOMD_FILE
26
- found << path
27
- spinner.update("#{message}: Found #{found.count} repos.")
28
- end
29
- end
30
-
31
- found.each do |repo_md_path|
32
- handle(repo_md_path, @remove_files)
33
- end
34
- end
35
-
36
- def handle(repo_md_path, remove_files)
37
- base_path = File.dirname(repo_md_path)
38
- to_remove = list_existing_files(repo_md_path) - list_repomd_files(repo_md_path)
39
-
40
- if to_remove.empty?
41
- "Skipping #{base_path}, no files to remove."
42
- elsif remove_files
43
- puts '================================================================================'
44
- puts "Removing #{to_remove.count} files from #{base_path}"
45
- to_remove.each { |file| File.delete(File.join(base_path, file)) }
46
- else
47
- puts '================================================================================'
48
- puts "For #{base_path} would remove, but --remove-files was not specified:"
49
- to_remove.each { |file| puts " #{file}" }
50
- end
51
- end
52
-
53
- def list_repomd_files(repo_md_path)
54
- doc = REXML::Document.new(File.new(repo_md_path))
55
- filenames = []
56
- doc.root.elements.each do |data|
57
- locations = data.elements['location']
58
- next unless locations
59
-
60
- if locations.attributes
61
- filenames << locations.attributes['href']
62
- end
63
- end
64
- base_names(filenames.flatten)
65
- end
66
-
67
- def list_existing_files(repo_md_path)
68
- base_names(Dir[File.dirname(repo_md_path) + '/*']) - [REPOMD_FILE]
69
- end
70
-
71
- def base_names(file_list)
72
- file_list.map { |file| File.basename(file) }
73
- end
74
- end
75
- end