Class: Actions::Candlepin::Consumer::CleanBackendObjects

Inherits:
EntryAction
  • Object
show all
Includes:
RecurringAction
Defined in:
app/lib/actions/candlepin/consumer/clean_backend_objects.rb

Instance Method Summary collapse

Instance Method Details

#humanized_nameObject



37
38
39
# File 'app/lib/actions/candlepin/consumer/clean_backend_objects.rb', line 37

def humanized_name
  _('Clean Backend Objects')
end

#planObject



6
7
8
# File 'app/lib/actions/candlepin/consumer/clean_backend_objects.rb', line 6

def plan
  plan_self
end

#rescue_strategyObject



41
42
43
# File 'app/lib/actions/candlepin/consumer/clean_backend_objects.rb', line 41

def rescue_strategy
  Dynflow::Action::Rescue::Skip
end

#runObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/lib/actions/candlepin/consumer/clean_backend_objects.rb', line 10

def run
  output[:results] = {
    hosts_with_nil_facets: [],
    hosts_with_no_subscriptions: [],
    orphaned_consumers: [],
    errors: [],
  }

  User.as_anonymous_admin do
    # Set bulk load size for Candlepin operations
    original_candlepin_page_size = SETTINGS[:katello][:candlepin][:bulk_load_size]
    SETTINGS[:katello][:candlepin][:bulk_load_size] = 125

    # Gather data from Candlepin and Katello
    candlepin_uuids = fetch_candlepin_uuids
    katello_candlepin_uuids = fetch_katello_candlepin_uuids

    # Find hosts with issues
    cleanup_hosts_with_nil_facets
    cleanup_hosts_with_no_subscriptions(candlepin_uuids)

    # Clean up orphaned Candlepin consumers
    cleanup_candlepin_orphans(candlepin_uuids, katello_candlepin_uuids)
    SETTINGS[:katello][:candlepin][:bulk_load_size] = original_candlepin_page_size
  end
end