foreman_maintain 0.8.23 → 0.8.26
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 +4 -4
 - data/definitions/features/foreman_tasks.rb +14 -7
 - data/definitions/procedures/pulp/remove.rb +49 -13
 - data/lib/foreman_maintain/version.rb +1 -1
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 07e94dcd8b177dfd099dba0073afd0f231cbe2fd4a1029b6576d587c5cb94f3a
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: ca3855c666713a17cc2fdb5d995fdfc15237e083a98978964cfd276b44d55e18
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 360bc155ca767b7ffd7c1ca17a8e9e669c4b2eb91ddc4148134c4f475af57888ee0938976d07dfaee48b2fa3ead2d8c6e2ab83c060330b42645fcaf9397697ae
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 4b6df3189ca5ee87b6051995729a74e9641ac6866fa7bf6330285f5b59f5d29e92a25a332e718967125deddb9525d4ff119ff727b31f4e40ec55b7cf26db2805
         
     | 
| 
         @@ -82,15 +82,22 @@ class Features::ForemanTasks < ForemanMaintain::Feature 
     | 
|
| 
       82 
82 
     | 
    
         
             
              def delete(state)
         
     | 
| 
       83 
83 
     | 
    
         
             
                tasks_condition = condition(state)
         
     | 
| 
       84 
84 
     | 
    
         | 
| 
       85 
     | 
    
         
            -
                 
     | 
| 
       86 
     | 
    
         
            -
             
     | 
| 
       87 
     | 
    
         
            -
             
     | 
| 
       88 
     | 
    
         
            -
             
     | 
| 
       89 
     | 
    
         
            -
             
     | 
| 
       90 
     | 
    
         
            -
             
     | 
| 
       91 
     | 
    
         
            -
             
     | 
| 
      
 85 
     | 
    
         
            +
                sql = <<-SQL
         
     | 
| 
      
 86 
     | 
    
         
            +
                  DELETE FROM dynflow_steps USING foreman_tasks_tasks WHERE (foreman_tasks_tasks.external_id = dynflow_steps.execution_plan_uuid::varchar) AND #{tasks_condition};
         
     | 
| 
      
 87 
     | 
    
         
            +
                  DELETE FROM dynflow_actions USING foreman_tasks_tasks WHERE (foreman_tasks_tasks.external_id = dynflow_actions.execution_plan_uuid::varchar) AND #{tasks_condition};
         
     | 
| 
      
 88 
     | 
    
         
            +
                  DELETE FROM dynflow_execution_plans USING foreman_tasks_tasks WHERE (foreman_tasks_tasks.external_id = dynflow_execution_plans.uuid::varchar) AND #{tasks_condition};
         
     | 
| 
      
 89 
     | 
    
         
            +
                  DELETE FROM foreman_tasks_tasks WHERE #{tasks_condition};
         
     | 
| 
      
 90 
     | 
    
         
            +
                  -- Delete locks and links which may now be orphaned
         
     | 
| 
      
 91 
     | 
    
         
            +
                  DELETE FROM foreman_tasks_locks as ftl where ftl.task_id NOT IN (SELECT id FROM foreman_tasks_tasks);
         
     | 
| 
       92 
92 
     | 
    
         
             
                SQL
         
     | 
| 
       93 
93 
     | 
    
         | 
| 
      
 94 
     | 
    
         
            +
                if check_min_version(foreman_plugin_name('foreman-tasks'), '4.0.0')
         
     | 
| 
      
 95 
     | 
    
         
            +
                  sql += 'DELETE FROM foreman_tasks_links as ftl ' \
         
     | 
| 
      
 96 
     | 
    
         
            +
                         'where ftl.task_id NOT IN (SELECT id FROM foreman_tasks_tasks);'
         
     | 
| 
      
 97 
     | 
    
         
            +
                end
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
                feature(:foreman_database).psql("BEGIN; #{sql}; COMMIT;")
         
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
       94 
101 
     | 
    
         
             
                count(state)
         
     | 
| 
       95 
102 
     | 
    
         
             
              end
         
     | 
| 
       96 
103 
     | 
    
         | 
| 
         @@ -23,7 +23,15 @@ module Procedures::Pulp 
     | 
|
| 
       23 
23 
     | 
    
         
             
                    '/var/lib/pulp/uploads',
         
     | 
| 
       24 
24 
     | 
    
         
             
                    '/var/lib/mongodb/',
         
     | 
| 
       25 
25 
     | 
    
         
             
                    '/var/cache/pulp'
         
     | 
| 
       26 
     | 
    
         
            -
                  ]
         
     | 
| 
      
 26 
     | 
    
         
            +
                  ].select { |dir| File.directory?(dir) }
         
     | 
| 
      
 27 
     | 
    
         
            +
                end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                def pulp_data_dirs_mountpoints
         
     | 
| 
      
 30 
     | 
    
         
            +
                  pulp_data_dirs.select { |d| Pathname(d).mountpoint? }
         
     | 
| 
      
 31 
     | 
    
         
            +
                end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                def deletable_pulp_dirs
         
     | 
| 
      
 34 
     | 
    
         
            +
                  @deletable_pulp_dirs ||= pulp_data_dirs - pulp_data_dirs_mountpoints
         
     | 
| 
       27 
35 
     | 
    
         
             
                end
         
     | 
| 
       28 
36 
     | 
    
         | 
| 
       29 
37 
     | 
    
         
             
                # rubocop:disable  Metrics/MethodLength
         
     | 
| 
         @@ -52,11 +60,12 @@ module Procedures::Pulp 
     | 
|
| 
       52 
60 
     | 
    
         
             
                  @installed_pulp_packages
         
     | 
| 
       53 
61 
     | 
    
         
             
                end
         
     | 
| 
       54 
62 
     | 
    
         | 
| 
       55 
     | 
    
         
            -
                def data_dir_removal_cmds
         
     | 
| 
       56 
     | 
    
         
            -
                   
     | 
| 
      
 63 
     | 
    
         
            +
                def data_dir_removal_cmds(pulp_dirs)
         
     | 
| 
      
 64 
     | 
    
         
            +
                  pulp_dirs.map { |dir| "rm -rf #{dir}" }
         
     | 
| 
       57 
65 
     | 
    
         
             
                end
         
     | 
| 
       58 
66 
     | 
    
         | 
| 
       59 
     | 
    
         
            -
                def ask_to_proceed 
     | 
| 
      
 67 
     | 
    
         
            +
                def ask_to_proceed
         
     | 
| 
      
 68 
     | 
    
         
            +
                  rm_cmds = data_dir_removal_cmds(pulp_data_dirs)
         
     | 
| 
       60 
69 
     | 
    
         
             
                  question = "\nWARNING: All pulp2 packages will be removed with the following commands:\n"
         
     | 
| 
       61 
70 
     | 
    
         
             
                  question += "\n# rpm -e #{pulp_packages.join('  ')}" if pulp_packages.any?
         
     | 
| 
       62 
71 
     | 
    
         
             
                  question += "\n# yum remove rh-mongodb34-*"
         
     | 
| 
         @@ -69,11 +78,9 @@ module Procedures::Pulp 
     | 
|
| 
       69 
78 
     | 
    
         
             
                end
         
     | 
| 
       70 
79 
     | 
    
         | 
| 
       71 
80 
     | 
    
         
             
                def run
         
     | 
| 
       72 
     | 
    
         
            -
                  rm_cmds = data_dir_removal_cmds
         
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
       74 
81 
     | 
    
         
             
                  assumeyes_val = @assumeyes.nil? ? assumeyes? : @assumeyes
         
     | 
| 
       75 
82 
     | 
    
         | 
| 
       76 
     | 
    
         
            -
                  ask_to_proceed 
     | 
| 
      
 83 
     | 
    
         
            +
                  ask_to_proceed unless assumeyes_val
         
     | 
| 
       77 
84 
     | 
    
         | 
| 
       78 
85 
     | 
    
         
             
                  remove_pulp if pulp_packages.any?
         
     | 
| 
       79 
86 
     | 
    
         | 
| 
         @@ -85,7 +92,7 @@ module Procedures::Pulp 
     | 
|
| 
       85 
92 
     | 
    
         | 
| 
       86 
93 
     | 
    
         
             
                  drop_migrations
         
     | 
| 
       87 
94 
     | 
    
         | 
| 
       88 
     | 
    
         
            -
                  delete_pulp_data 
     | 
| 
      
 95 
     | 
    
         
            +
                  delete_pulp_data
         
     | 
| 
       89 
96 
     | 
    
         | 
| 
       90 
97 
     | 
    
         
             
                  restart_pulpcore_services
         
     | 
| 
       91 
98 
     | 
    
         
             
                end
         
     | 
| 
         @@ -162,12 +169,41 @@ module Procedures::Pulp 
     | 
|
| 
       162 
169 
     | 
    
         
             
                end
         
     | 
| 
       163 
170 
     | 
    
         
             
                # rubocop:enable Metrics/BlockLength
         
     | 
| 
       164 
171 
     | 
    
         | 
| 
       165 
     | 
    
         
            -
                def delete_pulp_data 
     | 
| 
       166 
     | 
    
         
            -
                   
     | 
| 
       167 
     | 
    
         
            -
             
     | 
| 
       168 
     | 
    
         
            -
             
     | 
| 
      
 172 
     | 
    
         
            +
                def delete_pulp_data
         
     | 
| 
      
 173 
     | 
    
         
            +
                  non_mountpoints = data_dir_removal_cmds(deletable_pulp_dirs)
         
     | 
| 
      
 174 
     | 
    
         
            +
                  mountpoints = pulp_data_dirs_mountpoints
         
     | 
| 
      
 175 
     | 
    
         
            +
                  with_spinner('') do |spinner|
         
     | 
| 
      
 176 
     | 
    
         
            +
                    if non_mountpoints.any?
         
     | 
| 
      
 177 
     | 
    
         
            +
                      spinner.update('Deleting pulp2 data directories.')
         
     | 
| 
      
 178 
     | 
    
         
            +
                      non_mountpoints.each do |cmd|
         
     | 
| 
      
 179 
     | 
    
         
            +
                        execute!(cmd)
         
     | 
| 
      
 180 
     | 
    
         
            +
                      end
         
     | 
| 
      
 181 
     | 
    
         
            +
                      msg_for_del_non_mountpoints(mountpoints, spinner)
         
     | 
| 
      
 182 
     | 
    
         
            +
                    end
         
     | 
| 
      
 183 
     | 
    
         
            +
                    if mountpoints.any?
         
     | 
| 
      
 184 
     | 
    
         
            +
                      msg_for_del_mountpoints(mountpoints, spinner)
         
     | 
| 
       169 
185 
     | 
    
         
             
                    end
         
     | 
| 
       170 
     | 
    
         
            -
             
     | 
| 
      
 186 
     | 
    
         
            +
                  end
         
     | 
| 
      
 187 
     | 
    
         
            +
                end
         
     | 
| 
      
 188 
     | 
    
         
            +
             
     | 
| 
      
 189 
     | 
    
         
            +
                def msg_for_del_non_mountpoints(mountpoints, spinner)
         
     | 
| 
      
 190 
     | 
    
         
            +
                  if mountpoints.empty?
         
     | 
| 
      
 191 
     | 
    
         
            +
                    spinner.update('Done deleting all pulp2 data directories.')
         
     | 
| 
      
 192 
     | 
    
         
            +
                  else
         
     | 
| 
      
 193 
     | 
    
         
            +
                    spinner.update("Deleted: #{deletable_pulp_dirs.join("\n")}")
         
     | 
| 
      
 194 
     | 
    
         
            +
                  end
         
     | 
| 
      
 195 
     | 
    
         
            +
                end
         
     | 
| 
      
 196 
     | 
    
         
            +
             
     | 
| 
      
 197 
     | 
    
         
            +
                def msg_for_del_mountpoints(mountpoints, spinner)
         
     | 
| 
      
 198 
     | 
    
         
            +
                  _, cmd_name = ForemanMaintain.pkg_and_cmd_name
         
     | 
| 
      
 199 
     | 
    
         
            +
                  if mountpoints.count > 1
         
     | 
| 
      
 200 
     | 
    
         
            +
                    spinner.update("The directories #{mountpoints.join(',')} are individual mountpoints.")
         
     | 
| 
      
 201 
     | 
    
         
            +
                    puts  "\nThe #{cmd_name} won't delete these directories.\n"\
         
     | 
| 
      
 202 
     | 
    
         
            +
                          'You need to remove content and these directories on your own.'
         
     | 
| 
      
 203 
     | 
    
         
            +
                  else
         
     | 
| 
      
 204 
     | 
    
         
            +
                    spinner.update("The directory #{mountpoints.join(',')} is individual mountpoint.")
         
     | 
| 
      
 205 
     | 
    
         
            +
                    puts  "\nThe #{cmd_name} won't delete the directory.\n"\
         
     | 
| 
      
 206 
     | 
    
         
            +
                          'You need to remove content and the directory on your own.'
         
     | 
| 
       171 
207 
     | 
    
         
             
                  end
         
     | 
| 
       172 
208 
     | 
    
         
             
                end
         
     | 
| 
       173 
209 
     | 
    
         | 
    
        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.8. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.8.26
         
     | 
| 
       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: 2022- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2022-04-13 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: clamp
         
     |