foreman_maintain 0.7.11 → 0.7.12

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: 89f8cd453e8f9b19bec3b8912f8c88c0bfe4d20c08268c42c77b3748a9b0ebcf
4
- data.tar.gz: 8c1f5fcbba0d7c94e349290ee5b21e313435dc1ad55ab2c782b216b393481cb4
3
+ metadata.gz: 58a7f9214ba787d4da524da11a36469573b52b25859ee6a1efa74502c98504a2
4
+ data.tar.gz: 8e5818b8ce279babe6a6cda10d8549ebe2c07eb5c5f651c2f8dab2b1ed6b4b93
5
5
  SHA512:
6
- metadata.gz: f2572cdbd94ca61bf489eb1ad9354125fe4993c5d448ba0804aaa211cb17559c0ea307c96d63b56ed1dfa76649ebfa3750b7778ca7e95e57758bd454931613fa
7
- data.tar.gz: c31975cb3a4f4d27361b20834329262eef2409d73e65c29ead3207fa27d14288b37864c919cb9cb229f7760d95b09714a3ffe605d0cd73f09dffb6fb4f458508
6
+ metadata.gz: 5b8356b678fb0335b5df23205cbc328afadc8ba33d27501d9b655301c025a4edbe4385a7ecc96d2e2ba70aecb313ce298086046a56e7053ff62b24cc8d9aaad8
7
+ data.tar.gz: 3cd2e0ca9b5a23b1e3de9f27faf2a86ee82399310786ee016e54d4f55cfbd87aab9ae250afdee9193df30254049e7edc893992362bbf5a0975128ee8345e11cc
@@ -34,4 +34,10 @@ 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
37
43
  end
@@ -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!(&:enabled?)
140
+ service_list.select! { |service| !service.respond_to?(:enabled?) || service.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 => ['var/lib/pulp/katello-export'],
33
+ :exclude => feature(:pulp2).exclude_from_backup,
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,
@@ -0,0 +1,75 @@
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
@@ -97,6 +97,24 @@ module ForemanMaintain::Scenarios
97
97
  end
98
98
  end
99
99
 
100
+ class CleanupRepositoryMetadata < ContentBase
101
+ metadata do
102
+ label :cleanup_repository_metadata
103
+ description 'Remove old leftover repository metadata'
104
+ param :remove_files, 'Actually remove the files? Otherwise a dryrun is performed.'
105
+
106
+ manual_detection
107
+ end
108
+
109
+ def compose
110
+ add_step_with_context(Procedures::Pulp::CleanupOldMetadataFiles)
111
+ end
112
+
113
+ def set_context_mapping
114
+ context.map(:remove_files, Procedures::Pulp::CleanupOldMetadataFiles => :remove_files)
115
+ end
116
+ end
117
+
100
118
  class RemovePulp2 < ContentBase
101
119
  metadata do
102
120
  label :content_remove_pulp2
@@ -34,6 +34,17 @@ module ForemanMaintain
34
34
  end
35
35
  end
36
36
 
37
+ subcommand 'cleanup-repository-metadata', 'Cleanup old repository metadata under Pulp 2' do
38
+ option ['-r', '--remove-files'], :flag, 'Remove the files instead of just listing them.',
39
+ :attribute_name => :remove_files
40
+
41
+ def execute
42
+ run_scenarios_and_exit(
43
+ Scenarios::Content::CleanupRepositoryMetadata.new(:remove_files => @remove_files)
44
+ )
45
+ end
46
+ end
47
+
37
48
  subcommand 'remove-pulp2', 'Remove pulp2 and mongodb packages and data' do
38
49
  def execute
39
50
  run_scenarios_and_exit(Scenarios::Content::RemovePulp2.new)
@@ -1,3 +1,3 @@
1
1
  module ForemanMaintain
2
- VERSION = '0.7.11'.freeze
2
+ VERSION = '0.7.12'.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.11
4
+ version: 0.7.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Nečas
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-05 00:00:00.000000000 Z
11
+ date: 2021-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clamp
@@ -260,6 +260,7 @@ files:
260
260
  - definitions/procedures/packages/update_all_confirmation.rb
261
261
  - definitions/procedures/passenger_recycler.rb
262
262
  - definitions/procedures/prep_6_10_upgrade.rb
263
+ - definitions/procedures/pulp/cleanup_old_metadata_files.rb
263
264
  - definitions/procedures/pulp/migrate.rb
264
265
  - definitions/procedures/pulp/remove.rb
265
266
  - definitions/procedures/pulpcore/migrate.rb
@@ -404,7 +405,7 @@ homepage: https://github.com/theforeman/foreman_maintain
404
405
  licenses:
405
406
  - GPL-3.0
406
407
  metadata: {}
407
- post_install_message:
408
+ post_install_message:
408
409
  rdoc_options: []
409
410
  require_paths:
410
411
  - lib
@@ -419,8 +420,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
419
420
  - !ruby/object:Gem::Version
420
421
  version: '0'
421
422
  requirements: []
422
- rubygems_version: 3.0.9
423
- signing_key:
423
+ rubygems_version: 3.1.6
424
+ signing_key:
424
425
  specification_version: 4
425
426
  summary: Foreman maintenance tool belt
426
427
  test_files: []