foreman_maintain 0.7.2 → 0.7.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ede9ac694f3aa2331891b0a5a8d6e2d16881baa2705cedda1d6665e2f525617c
4
- data.tar.gz: ee459a09c76aeac0d0e62a337e30830b7f93f70a6a48111e81d7af1eed2f6aa0
3
+ metadata.gz: b7bee1fb68980f7f9358b61a13c7d0a5eba0c78d308ebcfeb717e31cb6c71942
4
+ data.tar.gz: 808fb2970b786aec29df42004b22ecf82b52e8bd31666410136842c6621d2b67
5
5
  SHA512:
6
- metadata.gz: e41953a3ec03c60f1a2ee2ab573db15a5fdbfddebf438abbf7a93be1b9512401a430ca13c3f870d010275f3b78d01decc404a00f92cd6087e20fcb8fd057cca4
7
- data.tar.gz: 25745f4026a790b816ce52dd378a1747cea9d9598b3167320cb6d4cc3fb531998589371c8512146c7b35b33aa6b3b632aa9af50b005834c416cda0d2c6b47523
6
+ metadata.gz: 3b5cba26dc0b3011336003c542e7d051b48a1a8896d5b36865d21b25e4a9367b1d1b3929d409ef6bb00fc2947c4f27141e0433a4e14c536291a269c0b334c1f5
7
+ data.tar.gz: a9e794c196a502b2307506863f0e75e1a4a1a803793986040d118f679f0bd921b0f8a5a95f76516844e97c71f831be5b2cdd9bd7052bb2fc6409dd4089e09f75
@@ -9,23 +9,20 @@ module Checks::ForemanTasks
9
9
  end
10
10
 
11
11
  def run
12
- paused_tasks_count = feature(:foreman_tasks).paused_tasks_count(ignored_tasks)
12
+ paused_tasks_count = feature(:foreman_tasks).paused_tasks_count()
13
13
  assert(paused_tasks_count == 0,
14
14
  "There are currently #{paused_tasks_count} paused tasks in the system",
15
- :next_steps =>
16
- [Procedures::ForemanTasks::Resume.new,
17
- Procedures::ForemanTasks::UiInvestigate.new('search_query' => scoped_search_query)])
15
+ :next_steps => next_procedures)
18
16
  end
19
17
 
20
- # Note: this is for UI link generation only: we are not using scoped search for querying
21
- # the tasks itself as we use direct SQL instead
22
- def scoped_search_query
23
- "state = paused AND label !^(#{ignored_tasks.join(' ')})"
24
- end
25
-
26
- def ignored_tasks
27
- %w[Actions::Candlepin::ListenOnCandlepinEvents
28
- Actions::Katello::EventQueue::Monitor]
18
+ def next_procedures
19
+ if assumeyes?
20
+ return [Procedures::ForemanTasks::Resume.new,
21
+ Procedures::ForemanTasks::Delete.new(:state => :paused)]
22
+ end
23
+ [Procedures::ForemanTasks::Resume.new,
24
+ Procedures::ForemanTasks::Delete.new(:state => :paused),
25
+ Procedures::ForemanTasks::UiInvestigate.new('search_query' => 'state = paused')]
29
26
  end
30
27
  end
31
28
  end
@@ -7,10 +7,6 @@ class Features::DynflowSidekiq < ForemanMaintain::Feature
7
7
  end
8
8
  end
9
9
 
10
- def services
11
- service_names.map { |service| system_service service, instance_priority(service) }
12
- end
13
-
14
10
  def config_files
15
11
  # Workaround until foreman-installer can deploy scaled workers
16
12
  service_symlinks = configured_instances.map do |service|
@@ -22,6 +18,13 @@ class Features::DynflowSidekiq < ForemanMaintain::Feature
22
18
  ].flatten
23
19
  end
24
20
 
21
+ def services
22
+ service_names.map do |service|
23
+ system_service service, instance_priority(service),
24
+ :instance_parent_unit => 'dynflow-sidekiq@'
25
+ end
26
+ end
27
+
25
28
  private
26
29
 
27
30
  def instance_priority(instance)
@@ -89,6 +89,8 @@ class Features::ForemanTasks < ForemanMaintain::Feature
89
89
 
90
90
  if state == :old
91
91
  old_tasks_condition
92
+ elsif state == :paused
93
+ paused_tasks_condition
92
94
  else
93
95
  tasks_condition(state)
94
96
  end
@@ -180,6 +182,10 @@ class Features::ForemanTasks < ForemanMaintain::Feature
180
182
  "foreman_tasks_tasks.started_at < CURRENT_DATE - INTERVAL '#{MIN_AGE} days'"
181
183
  end
182
184
 
185
+ def paused_tasks_condition(state = "'paused'")
186
+ "foreman_tasks_tasks.state IN (#{state})"
187
+ end
188
+
183
189
  def prepare_for_backup(state)
184
190
  dir = backup_dir(state)
185
191
  execute("mkdir -p #{dir}")
@@ -197,6 +203,6 @@ class Features::ForemanTasks < ForemanMaintain::Feature
197
203
  end
198
204
 
199
205
  def valid(state)
200
- %w[old planning pending].include?(state.to_s)
206
+ %w[old planning pending paused].include?(state.to_s)
201
207
  end
202
208
  end
@@ -11,18 +11,19 @@ class Features::Pulpcore < ForemanMaintain::Feature
11
11
  end
12
12
 
13
13
  def services
14
- pulpcore_common_services + [
14
+ self.class.pulpcore_common_services + [
15
+ system_service('rh-redis5-redis', 5),
15
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 pulpcore_migration_services
21
+ def self.pulpcore_migration_services
21
22
  pulpcore_common_services + [
22
- system_service('pulpcore-worker@1', 20),
23
- system_service('pulpcore-worker@2', 20),
24
- system_service('pulpcore-worker@3', 20),
25
- system_service('pulpcore-worker@4', 20)
23
+ ForemanMaintain::Utils.system_service('pulpcore-worker@1', 20),
24
+ ForemanMaintain::Utils.system_service('pulpcore-worker@2', 20),
25
+ ForemanMaintain::Utils.system_service('pulpcore-worker@3', 20),
26
+ ForemanMaintain::Utils.system_service('pulpcore-worker@4', 20)
26
27
  ]
27
28
  end
28
29
 
@@ -32,14 +33,11 @@ class Features::Pulpcore < ForemanMaintain::Feature
32
33
  ]
33
34
  end
34
35
 
35
- private
36
-
37
- def pulpcore_common_services
36
+ def self.pulpcore_common_services
38
37
  [
39
- system_service('rh-redis5-redis', 5),
40
- system_service('pulpcore-api', 10, :socket => 'pulpcore-api'),
41
- system_service('pulpcore-content', 10, :socket => 'pulpcore-content'),
42
- system_service('pulpcore-resource-manager', 10)
38
+ ForemanMaintain::Utils.system_service('pulpcore-api', 10, :socket => 'pulpcore-api'),
39
+ ForemanMaintain::Utils.system_service('pulpcore-content', 10, :socket => 'pulpcore-content'),
40
+ ForemanMaintain::Utils.system_service('pulpcore-resource-manager', 10)
43
41
  ]
44
42
  end
45
43
  end
@@ -4,11 +4,12 @@ module Procedures::Backup
4
4
  metadata do
5
5
  description 'Data consistency warning'
6
6
  tags :backup
7
- param :include_db_dumps
7
+ param :include_db_dumps, 'Are database dumps included in backup', :flag => true,
8
+ :default => false
8
9
  end
9
10
 
10
11
  def run
11
- answer = ask_decision(warning_message(@include_db_dumps), 'y(yes), q(quit)')
12
+ answer = ask_decision(warning_message(@include_db_dumps), actions_msg: 'y(yes), q(quit)')
12
13
  abort! unless answer == :yes
13
14
  end
14
15
 
@@ -1,6 +1,6 @@
1
1
  module Procedures::ForemanTasks
2
2
  class Delete < ForemanMaintain::Procedure
3
- ALLOWED_STATES_VALUES = %w[old planning pending].freeze
3
+ ALLOWED_STATES_VALUES = %w[old planning pending paused].freeze
4
4
 
5
5
  metadata do
6
6
  param :state,
@@ -19,12 +19,11 @@ module Procedures::ForemanTasks
19
19
  feature(:foreman_tasks).backup_tasks(@state) do |backup_progress|
20
20
  spinner.update backup_progress
21
21
  end
22
-
23
- spinner.update "Deleting #{@state} tasks [running]"
22
+ spinner.update "Deleting #{count_tasks_before} #{@state} tasks [running]"
24
23
  count_tasks_later = feature(:foreman_tasks).delete(@state)
25
24
  spinner.update "Deleting #{@state} tasks [DONE]"
26
25
  spinner.update(
27
- "Deleted #{@state} stopped and paused tasks: #{count_tasks_before - count_tasks_later}"
26
+ "Deleted #{@state} tasks: #{count_tasks_before - count_tasks_later}"
28
27
  )
29
28
  end
30
29
  end
@@ -6,8 +6,13 @@ module Procedures::ForemanTasks
6
6
  description 'Resume paused tasks'
7
7
  end
8
8
 
9
+ WAIT_TIME = 30
10
+
9
11
  def run
10
12
  output << feature(:foreman_tasks).resume_task_using_hammer
13
+ with_spinner('Waiting 30 seconds for resumed tasks to start.') do
14
+ sleep WAIT_TIME
15
+ end
11
16
  end
12
17
  end
13
18
  end
@@ -3,8 +3,7 @@ class Procedures::Prep610Upgrade < ForemanMaintain::Procedure
3
3
  description 'Preparations for the Satellite 6.10 upgrade'
4
4
 
5
5
  confine do
6
- ::Scenarios.const_defined?('Satellite_6_10') &&
7
- feature(:satellite) &&
6
+ feature(:satellite) &&
8
7
  feature(:satellite).current_minor_version == '6.9'
9
8
  end
10
9
  end
@@ -18,7 +17,6 @@ class Procedures::Prep610Upgrade < ForemanMaintain::Procedure
18
17
  execute!('find /var/lib/pulp/content -type d -perm -g-s -exec chmod g+s {} \;')
19
18
  spinner.update('$ chown -R :pulp /var/lib/pulp/content')
20
19
  FileUtils.chown_R nil, 'pulp', '/var/lib/pulp/content'
21
- # TODO: Install Pulp 3 without starting services?
22
20
  end
23
21
  end
24
22
 
@@ -16,12 +16,22 @@ module Procedures::Service
16
16
 
17
17
  def unit_files_list(services)
18
18
  if systemd_installed?
19
- regex = services.map { |service| "^#{service.name}.service" }.join('\|')
20
- execute("systemctl list-unit-files | grep '#{regex}'")
19
+ execute("systemctl list-unit-files --type=service | \
20
+ grep '#{build_regex_for_services(services)}'")
21
21
  else
22
22
  regex = services.map { |service| "^#{service.name} " }.join('\|')
23
23
  execute("chkconfig --list 2>&1 | grep '#{regex}'")
24
24
  end
25
25
  end
26
+
27
+ def build_regex_for_services(services)
28
+ services.map do |service|
29
+ if service.respond_to?(:instance_parent_unit) && service.instance_parent_unit
30
+ "^#{service.instance_parent_unit}.service"
31
+ else
32
+ "^#{service.name}.service"
33
+ end
34
+ end.join('\|')
35
+ end
26
36
  end
27
37
  end
@@ -94,6 +94,8 @@ module ForemanMaintain::Scenarios
94
94
  Procedures::Backup::Snapshot::MountPulp => :skip)
95
95
  context.map(:tar_volume_size,
96
96
  Procedures::Backup::Pulp => :tar_volume_size)
97
+ context.map(:include_db_dumps,
98
+ Procedures::Backup::Online::SafetyConfirmation => :include_db_dumps)
97
99
  end
98
100
  # rubocop:enable Metrics/MethodLength
99
101
 
@@ -20,16 +20,16 @@ module ForemanMaintain::Scenarios
20
20
  def enable_and_start_services
21
21
  add_step(Procedures::Service::Start)
22
22
  add_step(Procedures::Service::Enable.
23
- new(:only => feature(:pulpcore).pulpcore_migration_services))
23
+ new(:only => Features::Pulpcore.pulpcore_migration_services))
24
24
  add_step(Procedures::Service::Start.
25
- new(:only => feature(:pulpcore).pulpcore_migration_services))
25
+ new(:only => Features::Pulpcore.pulpcore_migration_services))
26
26
  end
27
27
 
28
28
  def disable_and_stop_services
29
29
  add_step(Procedures::Service::Stop.
30
- new(:only => feature(:pulpcore).pulpcore_migration_services))
30
+ new(:only => Features::Pulpcore.pulpcore_migration_services))
31
31
  add_step(Procedures::Service::Disable.
32
- new(:only => feature(:pulpcore).pulpcore_migration_services))
32
+ new(:only => Features::Pulpcore.pulpcore_migration_services))
33
33
  end
34
34
  end
35
35
 
@@ -27,9 +27,8 @@ module ForemanMaintain
27
27
  subcommand 'content', 'Content related commands', ContentCommand
28
28
  subcommand 'maintenance-mode', 'Control maintenance-mode for application',
29
29
  MaintenanceModeCommand
30
- if ::Scenarios.const_defined?('Satellite_6_10') &&
31
- ForemanMaintain.detector.feature('satellite') &&
32
- ForemanMaintain.detector.feature('satellite').current_minor_version == '6.9'
30
+ if ForemanMaintain.detector.feature(:satellite) &&
31
+ ForemanMaintain.detector.feature(:satellite).current_minor_version == '6.9'
33
32
  subcommand 'prep-6.10-upgrade', 'Preparations for the Satellite 6.10 upgrade' do
34
33
  def execute
35
34
  run_scenarios_and_exit(Scenarios::Prep610Upgrade.new)
@@ -67,6 +67,7 @@ module ForemanMaintain
67
67
  end
68
68
  end
69
69
 
70
+ attr_accessor :select_option_counter
70
71
  attr_reader :last_line, :max_length
71
72
 
72
73
  def initialize(stdout = STDOUT, stdin = STDIN, options = {})
@@ -81,6 +82,7 @@ module ForemanMaintain
81
82
  @spinner = Spinner.new(self)
82
83
  @spinner.start_spinner if @stdout.tty?
83
84
  @last_line = ''
85
+ @select_option_counter = 0
84
86
  end
85
87
 
86
88
  def before_scenario_starts(scenario)
@@ -212,8 +214,10 @@ module ForemanMaintain
212
214
  # rubocop:disable Metrics/MethodLength
213
215
  def ask_to_select(message, steps, run_strategy)
214
216
  if assumeyes?
215
- puts('(assuming first option)')
216
- return steps.first
217
+ step = steps[@select_option_counter]
218
+ @select_option_counter += 1
219
+ puts("(assuming option #{@select_option_counter})")
220
+ return step
217
221
  end
218
222
 
219
223
  until_valid_decision do
@@ -18,6 +18,7 @@ module ForemanMaintain
18
18
  @last_scenario = nil
19
19
  @last_scenario_continuation_confirmed = false
20
20
  @exit_code = 0
21
+ @procedure_step_counter = 0
21
22
  end
22
23
 
23
24
  def quit?
@@ -143,14 +144,16 @@ module ForemanMaintain
143
144
 
144
145
  # rubocop:disable Metrics/MethodLength
145
146
  def ask_about_offered_steps(step, scenario)
146
- if assumeyes? && rerun_check?(step)
147
- @reporter.puts 'Check still failing after attempt to fix. Skipping'
148
- return :no
149
- end
150
147
  if step.next_steps && !step.next_steps.empty?
151
148
  @last_decision_step = step
149
+ @procedure_step_counter += 1
152
150
  steps = step.next_steps.map(&:ensure_instance)
153
-
151
+ if assumeyes? && @procedure_step_counter > steps.length
152
+ @procedure_step_counter = 0
153
+ @reporter.select_option_counter = 0
154
+ @reporter.puts 'Check still failing after attempt to fix. Skipping'
155
+ return :no
156
+ end
154
157
  decision = @reporter.on_next_steps(steps, scenario.run_strategy)
155
158
  case decision
156
159
  when :quit
@@ -1,16 +1,17 @@
1
1
  module ForemanMaintain::Utils
2
2
  module Service
3
3
  class Systemd < Abstract
4
+ attr_reader :instance_parent_unit
4
5
  def initialize(name, priority, options = {})
5
6
  super
6
7
  @sys = SystemHelpers.new
8
+ @instance_parent_unit = options.fetch(:instance_parent_unit, nil)
7
9
  end
8
10
 
9
11
  def command(action, options = {})
10
12
  do_wait = options.fetch(:wait, true) # wait for service to start
11
13
  all = @options.fetch(:all, false)
12
14
  skip_enablement = @options.fetch(:skip_enablement, false)
13
-
14
15
  if skip_enablement && %w[enable disable].include?(action)
15
16
  return skip_enablement_message(action, @name)
16
17
  end
@@ -1,3 +1,3 @@
1
1
  module ForemanMaintain
2
- VERSION = '0.7.2'.freeze
2
+ VERSION = '0.7.4'.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.2
4
+ version: 0.7.4
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: 2020-12-23 00:00:00.000000000 Z
11
+ date: 2021-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clamp