Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove DatabaseBackup #21415

Merged
merged 2 commits into from
Nov 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 0 additions & 99 deletions app/models/database_backup.rb

This file was deleted.

5 changes: 0 additions & 5 deletions app/models/miq_region.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ class MiqRegion < ApplicationRecord
has_many :metric_rollups, :as => :resource # Destroy will be handled by purger
has_many :vim_performance_states, :as => :resource # Destroy will be handled by purger

virtual_has_many :database_backups, :class_name => "DatabaseBackup"
virtual_has_many :ext_management_systems, :class_name => "ExtManagementSystem"
virtual_has_many :hosts, :class_name => "Host"
virtual_has_many :storages, :class_name => "Storage"
Expand Down Expand Up @@ -34,10 +33,6 @@ class MiqRegion < ApplicationRecord

PERF_ROLLUP_CHILDREN = [:ext_management_systems, :storages]

def database_backups
DatabaseBackup.in_region(region_number)
end

def ext_management_systems
ExtManagementSystem.in_region(region_number)
end
Expand Down
42 changes: 4 additions & 38 deletions app/models/miq_schedule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class MiqSchedule < ApplicationRecord

validates :name, :uniqueness_when_changed => {:scope => [:userid, :resource_type]}
validates :name, :description, :resource_type, :run_at, :presence => true
validate :validate_run_at, :validate_file_depot
validate :validate_run_at

before_save :set_start_time_and_prod_default

Expand Down Expand Up @@ -39,9 +39,9 @@ class MiqSchedule < ApplicationRecord
serialize :filter
serialize :run_at

SYSTEM_SCHEDULE_CLASSES = %w(MiqReport MiqAlert MiqWidget).freeze
VALID_INTERVAL_UNITS = %w(minutely hourly daily weekly monthly once).freeze
ALLOWED_CLASS_METHOD_ACTIONS = %w(db_backup db_gc automation_request).freeze
SYSTEM_SCHEDULE_CLASSES = %w[MiqReport MiqAlert MiqWidget].freeze
VALID_INTERVAL_UNITS = %w[minutely hourly daily weekly monthly once].freeze
ALLOWED_CLASS_METHOD_ACTIONS = %w[automation_request].freeze
IMPORT_CLASS_NAMES = %w[MiqSchedule].freeze

default_value_for :userid, "system"
Expand Down Expand Up @@ -247,37 +247,10 @@ def action_automation_request(_klass, _at)
AutomationRequest.create_from_scheduled_task(user, filter[:uri_parts], parameters)
end

def action_db_backup(klass, _at)
self.sched_action ||= {}
self.sched_action[:options] ||= {}
self.sched_action[:options][:userid] = userid
opts = self.sched_action[:options]
opts[:file_depot_id] = file_depot.id
opts[:miq_schedule_id] = id
queue_opts = {:class_name => klass.name, :method_name => "backup", :args => [opts], :role => "database_operations",
:msg_timeout => ::Settings.task.active_task_timeout.to_i_with_method}
task_opts = {:action => "Database backup", :userid => self.sched_action[:options][:userid]}
MiqTask.generic_action_with_callback(task_opts, queue_opts)
end

def action_db_gc(klass, _at)
self.sched_action ||= {}
self.sched_action[:options] ||= {}
self.sched_action[:options][:userid] = userid
opts = self.sched_action[:options]
queue_opts = {:class_name => klass.name, :method_name => "gc", :args => [opts], :role => "database_operations"}
task_opts = {:action => "Database GC", :userid => self.sched_action[:options][:userid]}
MiqTask.generic_action_with_callback(task_opts, queue_opts)
end

def run_automation_request
action_automation_request(AutomationRequest, nil)
end

def run_adhoc_db_backup
action_db_backup(DatabaseBackup, nil)
end

def action_evaluate_alert(obj, _at)
MiqAlert.evaluate_queue(obj)
_log.info("Action [#{name}] has been run for target type: [#{obj.class}] with name: [#{obj.name}]")
Expand Down Expand Up @@ -325,13 +298,6 @@ def validate_run_at
end
end

def validate_file_depot # TODO: Do we need this if the validations are on the FileDepot classes?
if self.sched_action.kind_of?(Hash) && self.sched_action[:method] == "db_backup" && file_depot
errors.add(:file_depot, "is missing credentials") if !file_depot.uri.to_s.starts_with?("nfs") && file_depot.missing_credentials?
errors.add(:file_depot, "is missing uri") if file_depot.uri.blank?
end
end

def verify_file_depot(params) # TODO: This logic belongs in the UI, not sure where
depot_class = FileDepot.supported_protocols[params[:uri_prefix]]
depot = file_depot.class.name == depot_class ? file_depot : build_file_depot(:type => depot_class)
Expand Down
1 change: 0 additions & 1 deletion config/replication_exclude_tables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
- conditions_miq_policies
- custom_buttons
- customization_specs
- database_backups
- event_logs
- external_urls
- file_depots
Expand Down
5 changes: 0 additions & 5 deletions spec/factories/database_backup.rb

This file was deleted.

47 changes: 0 additions & 47 deletions spec/models/database_backup_spec.rb

This file was deleted.

12 changes: 0 additions & 12 deletions spec/models/miq_schedule_filter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@
:sched_action => {:method => "vm_scan"},
:miq_search_id => @search.id
)

# DB Baskup Schedule
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Baskup... 🤣

@db_backup = FactoryBot.create(:miq_schedule,
:resource_type => "DatabaseBackup",
:sched_action => {:method => "db_backup"}
)
end

context "for a scheduled report" do
Expand Down Expand Up @@ -88,11 +82,5 @@
expect(targets.length).to eq(1)
expect(targets.first.name).to eq("Test VM 2")
end

it "should get the the DatabaseBackup class for a scheduled DB Backup" do
targets = @db_backup.get_targets
expect(targets.length).to eq(1)
expect(targets.first.name).to eq("DatabaseBackup")
end
end
end
Loading