foreman_maintain 0.7.6 → 0.7.11

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: 743d74ea6833807f28ea4f14096821c03d080ede64f8cc74ee4146b4dd8eea26
4
- data.tar.gz: 4b54030179cb8019c0a5936f5accfb8a91f6a092c9221cd1b03e9d342c5bbaa3
3
+ metadata.gz: 89f8cd453e8f9b19bec3b8912f8c88c0bfe4d20c08268c42c77b3748a9b0ebcf
4
+ data.tar.gz: 8c1f5fcbba0d7c94e349290ee5b21e313435dc1ad55ab2c782b216b393481cb4
5
5
  SHA512:
6
- metadata.gz: 89f47a46c1061c416d9042c116dea5ad0acbf973418d4452e44500a8ebbb55cd598d3d3001332ec92970094dd2ebd36af8a92fde9d28835a5544e96d6bd333d0
7
- data.tar.gz: 370b409946044d658e102e0aa64733842163b5834289b7cf059dd16733ee2e6f1263aa6221212caa3b5fcb1f77fd81519c414e542357cac8df579f0d4031c7fd
6
+ metadata.gz: f2572cdbd94ca61bf489eb1ad9354125fe4993c5d448ba0804aaa211cb17559c0ea307c96d63b56ed1dfa76649ebfa3750b7778ca7e95e57758bd454931613fa
7
+ data.tar.gz: c31975cb3a4f4d27361b20834329262eef2409d73e65c29ead3207fa27d14288b37864c919cb9cb229f7760d95b09714a3ffe605d0cd73f09dffb6fb4f458508
@@ -0,0 +1,45 @@
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
@@ -37,6 +37,6 @@ class Features::DynflowSidekiq < ForemanMaintain::Feature
37
37
  end
38
38
 
39
39
  def configured_instances
40
- Dir['/etc/foreman/dynflow/*'].map { |config| File.basename(config, '.yml') }
40
+ Dir['/etc/foreman/dynflow/*.yml'].map { |config| File.basename(config, '.yml') }
41
41
  end
42
42
  end
@@ -141,13 +141,13 @@ class Features::Mongo < ForemanMaintain::Feature
141
141
  end
142
142
 
143
143
  def mongo_cmd_available?
144
- exit_status, _output = execute_with_status("which #{core.client_command}")
144
+ exit_status, _output = execute_with_status('which mongo')
145
145
  exit_status == 0
146
146
  end
147
147
 
148
148
  def raise_mongo_client_missing_error
149
- raise ForemanMaintain::Error::Fail, "The #{core.client_command} command not found."\
150
- " Make sure system has #{core.client_command} utility installed."
149
+ raise ForemanMaintain::Error::Fail, 'The mongo command not found.'\
150
+ ' Make sure system has mongo utility installed.'
151
151
  end
152
152
 
153
153
  private
@@ -25,9 +25,10 @@ class Features::Service < ForemanMaintain::Feature
25
25
  select(&:exist?)
26
26
  end
27
27
 
28
- def filtered_services(options)
28
+ def filtered_services(options, action = '')
29
29
  services = include_unregistered_services(existing_services, options[:include])
30
- services = filter_services(services, options)
30
+ services = filter_services(services, options, action)
31
+
31
32
  raise 'No services found matching your parameters' unless services.any?
32
33
  return services unless options[:reverse]
33
34
 
@@ -61,59 +62,49 @@ class Features::Service < ForemanMaintain::Feature
61
62
  def run_action_on_services(action, options, spinner)
62
63
  status = 0
63
64
  failed_services = []
64
- filtered_services(options).each_value do |group|
65
- systemctl_status, _output = execute_with_status('systemctl ' \
66
- "#{action} #{group.map(&:name).join(' ')}")
67
- display_status(group, options, action, spinner)
68
- if systemctl_status > 0
69
- status = systemctl_status
70
- failed_services |= failed_services_by_status(action, group, spinner)
65
+ filtered_services(options, action).each_value do |group|
66
+ fork_threads_for_services(action, group, spinner).each do |service, status_and_output|
67
+ spinner.update("#{action_noun(action)} #{service}") if action == 'status'
68
+ item_status, output = status_and_output
69
+ formatted = format_status(output, item_status, options)
70
+ puts formatted unless formatted.empty?
71
+
72
+ if item_status > 0
73
+ status = item_status
74
+ failed_services << service
75
+ end
71
76
  end
72
77
  end
73
78
  [status, failed_services]
74
79
  end
75
80
 
76
- def display_status(services, options, action, spinner)
81
+ def fork_threads_for_services(action, services, spinner)
82
+ services_and_statuses = []
77
83
  services.each do |service|
78
- spinner.update("#{action_noun(action)} #{service}")
79
- formatted = format_status(service.status, options, action)
80
- puts formatted unless formatted.empty?
84
+ spinner.update("#{action_noun(action)} #{service}") if action != 'status'
85
+ services_and_statuses << [service, Thread.new { service.send(action.to_sym) }]
81
86
  end
87
+ services_and_statuses.map! { |service, status| [service, status.value] }
82
88
  end
83
89
 
84
- def format_status(service_status, options, action)
85
- exit_code, output = service_status
90
+ def format_status(output, exit_code, options)
86
91
  status = ''
87
92
  if !options[:failing] || exit_code > 0
88
93
  if options[:brief]
89
94
  status += format_brief_status(exit_code)
90
- elsif include_output?(action, exit_code)
95
+ elsif !(output.nil? || output.empty?)
91
96
  status += "\n" + output
92
97
  end
93
98
  end
94
99
  status
95
100
  end
96
101
 
97
- def include_output?(action, status)
98
- (action == 'start' && status > 0) ||
99
- action == 'status'
100
- end
101
-
102
102
  def format_brief_status(exit_code)
103
103
  result = exit_code == 0 ? reporter.status_label(:success) : reporter.status_label(:fail)
104
104
  padding = reporter.max_length - reporter.last_line.to_s.length - 30
105
105
  "#{' ' * padding} #{result}"
106
106
  end
107
107
 
108
- def failed_services_by_status(action, services, spinner)
109
- failed_services = []
110
- services.each do |service|
111
- spinner.update("#{action_noun(action)} #{service}")
112
- failed_services << service unless service.running?
113
- end
114
- failed_services
115
- end
116
-
117
108
  def allowed_action?(action)
118
109
  %w[start stop restart status enable disable].include?(action)
119
110
  end
@@ -125,7 +116,8 @@ class Features::Service < ForemanMaintain::Feature
125
116
  service_list + socket_list
126
117
  end
127
118
 
128
- def filter_services(service_list, options)
119
+ # rubocop:disable Metrics/AbcSize
120
+ def filter_services(service_list, options, action)
129
121
  if options[:only] && options[:only].any?
130
122
  service_list = service_list.select do |service|
131
123
  options[:only].any? { |opt| service.matches?(opt) }
@@ -138,8 +130,17 @@ class Features::Service < ForemanMaintain::Feature
138
130
  end
139
131
 
140
132
  service_list = extend_service_list_with_sockets(service_list, options)
133
+ service_list = filter_disabled_services!(action, service_list)
141
134
  service_list.group_by(&:priority).to_h
142
135
  end
136
+ # rubocop:enable Metrics/AbcSize
137
+
138
+ def filter_disabled_services!(action, service_list)
139
+ if %w[start stop restart status].include?(action)
140
+ service_list.select!(&:enabled?)
141
+ end
142
+ service_list
143
+ end
143
144
 
144
145
  def include_unregistered_services(service_list, services_filter)
145
146
  return service_list unless services_filter
@@ -19,8 +19,11 @@ module Procedures::Content
19
19
  puts execute!('foreman-rake katello:pulp3_content_switchover')
20
20
  puts 'Re-running the installer to switch specified content over to pulp3'
21
21
  args = ['--foreman-proxy-content-proxy-pulp-isos-to-pulpcore=true',
22
+ '--foreman-proxy-content-proxy-pulp-yum-to-pulpcore=true',
23
+ '--foreman-proxy-content-proxy-pulp-deb-to-pulpcore=true',
22
24
  '--katello-use-pulp-2-for-file=false',
23
25
  '--katello-use-pulp-2-for-docker=false',
26
+ '--katello-use-pulp-2-for-deb=false',
24
27
  '--katello-use-pulp-2-for-yum=false']
25
28
  feature(:installer).run(args.join(' '))
26
29
  end
@@ -16,7 +16,7 @@ module Procedures
16
16
  def run_service_action(action, options)
17
17
  action_noun = feature(:service).action_noun(action).capitalize
18
18
  puts "\n#{action_noun} the following service(s):"
19
- services = feature(:service).filtered_services(options)
19
+ services = feature(:service).filtered_services(options, action)
20
20
  print_services(services)
21
21
  with_spinner('') do |spinner|
22
22
  feature(:service).handle_services(spinner, action, options)
@@ -1,6 +1,23 @@
1
1
  module ForemanMaintain::Scenarios
2
2
  module Content
3
- class Prepare < ForemanMaintain::Scenario
3
+ class ContentBase < ForemanMaintain::Scenario
4
+ def enable_and_start_services
5
+ add_step(Procedures::Service::Start)
6
+ add_step(Procedures::Service::Enable.
7
+ new(:only => Features::Pulpcore.pulpcore_migration_services))
8
+ add_step(Procedures::Service::Start.
9
+ new(:only => Features::Pulpcore.pulpcore_migration_services))
10
+ end
11
+
12
+ def disable_and_stop_services
13
+ add_step(Procedures::Service::Stop.
14
+ new(:only => Features::Pulpcore.pulpcore_migration_services))
15
+ add_step(Procedures::Service::Disable.
16
+ new(:only => Features::Pulpcore.pulpcore_migration_services))
17
+ end
18
+ end
19
+
20
+ class Prepare < ContentBase
4
21
  metadata do
5
22
  label :content_prepare
6
23
  description 'Prepare content for Pulp 3'
@@ -16,26 +33,9 @@ module ForemanMaintain::Scenarios
16
33
  add_step(Procedures::Content::Prepare)
17
34
  end
18
35
  end
19
-
20
- private
21
-
22
- def enable_and_start_services
23
- add_step(Procedures::Service::Start)
24
- add_step(Procedures::Service::Enable.
25
- new(:only => Features::Pulpcore.pulpcore_migration_services))
26
- add_step(Procedures::Service::Start.
27
- new(:only => Features::Pulpcore.pulpcore_migration_services))
28
- end
29
-
30
- def disable_and_stop_services
31
- add_step(Procedures::Service::Stop.
32
- new(:only => Features::Pulpcore.pulpcore_migration_services))
33
- add_step(Procedures::Service::Disable.
34
- new(:only => Features::Pulpcore.pulpcore_migration_services))
35
- end
36
36
  end
37
37
 
38
- class Switchover < ForemanMaintain::Scenario
38
+ class Switchover < ContentBase
39
39
  metadata do
40
40
  label :content_switchover
41
41
  description 'Switch support for certain content from Pulp 2 to Pulp 3'
@@ -51,7 +51,7 @@ module ForemanMaintain::Scenarios
51
51
  end
52
52
  end
53
53
 
54
- class PrepareAbort < ForemanMaintain::Scenario
54
+ class PrepareAbort < ContentBase
55
55
  metadata do
56
56
  label :content_prepare_abort
57
57
  description 'Abort all running Pulp 2 to Pulp 3 migration tasks'
@@ -65,7 +65,7 @@ module ForemanMaintain::Scenarios
65
65
  end
66
66
  end
67
67
 
68
- class MigrationStats < ForemanMaintain::Scenario
68
+ class MigrationStats < ContentBase
69
69
  metadata do
70
70
  label :content_migration_stats
71
71
  description 'Retrieve Pulp 2 to Pulp 3 migration statistics'
@@ -79,7 +79,7 @@ module ForemanMaintain::Scenarios
79
79
  end
80
80
  end
81
81
 
82
- class MigrationReset < ForemanMaintain::Scenario
82
+ class MigrationReset < ContentBase
83
83
  metadata do
84
84
  label :content_migration_reset
85
85
  description 'Reset the Pulp 2 to Pulp 3 migration data (pre-switchover)'
@@ -97,7 +97,7 @@ module ForemanMaintain::Scenarios
97
97
  end
98
98
  end
99
99
 
100
- class RemovePulp2 < ForemanMaintain::Scenario
100
+ class RemovePulp2 < ContentBase
101
101
  metadata do
102
102
  label :content_remove_pulp2
103
103
  description 'Remove Pulp2 and mongodb packages and data'
@@ -28,6 +28,7 @@ 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)
31
32
  add_step(Checks::Repositories::Validate.new(:version => '6.8'))
32
33
  end
33
34
  end
@@ -28,6 +28,7 @@ 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)
31
32
  add_step(Checks::Repositories::Validate.new(:version => '6.9'))
32
33
  end
33
34
  end
@@ -15,6 +15,7 @@ module ForemanMaintain
15
15
  @reporter = reporter
16
16
  @scenarios = Array(scenarios)
17
17
  @quit = false
18
+ @rescue = false
18
19
  @last_scenario = nil
19
20
  @last_scenario_continuation_confirmed = false
20
21
  @exit_code = 0
@@ -29,12 +30,17 @@ module ForemanMaintain
29
30
  @assumeyes
30
31
  end
31
32
 
33
+ def rescue?
34
+ @rescue
35
+ end
36
+
32
37
  def run
33
38
  @scenarios.each do |scenario|
34
39
  run_scenario(scenario)
35
40
  next unless @quit
36
41
 
37
42
  if @rescue_scenario
43
+ @rescue = true
38
44
  logger.debug('=== Rescue scenario found. Executing ===')
39
45
  execute_scenario_steps(@rescue_scenario, true)
40
46
  end
@@ -44,10 +50,10 @@ module ForemanMaintain
44
50
 
45
51
  def run_scenario(scenario)
46
52
  return if scenario.steps.empty?
47
- raise 'The runner is already in quit state' if quit?
53
+ raise 'The runner is already in quit state' if quit? && !rescue?
48
54
 
49
55
  confirm_scenario(scenario)
50
- return if quit?
56
+ return if quit? && !rescue?
51
57
 
52
58
  execute_scenario_steps(scenario)
53
59
  ensure
@@ -26,6 +26,10 @@ 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
+
29
33
  private
30
34
 
31
35
  # In fio command, --direct option bypass the cache page
@@ -1,3 +1,3 @@
1
1
  module ForemanMaintain
2
- VERSION = '0.7.6'.freeze
2
+ VERSION = '0.7.11'.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.6
4
+ version: 0.7.11
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-03-02 00:00:00.000000000 Z
11
+ date: 2021-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clamp
@@ -126,6 +126,7 @@ 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
129
130
  - definitions/checks/disk/performance.rb
130
131
  - definitions/checks/env_proxy.rb
131
132
  - definitions/checks/foreman/check_checkpoint_segments.rb
@@ -418,7 +419,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
418
419
  - !ruby/object:Gem::Version
419
420
  version: '0'
420
421
  requirements: []
421
- rubygems_version: 3.0.3
422
+ rubygems_version: 3.0.9
422
423
  signing_key:
423
424
  specification_version: 4
424
425
  summary: Foreman maintenance tool belt