Bug 1205898 - Database backup fails
Summary: Database backup fails
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: Appliance
Version: 5.4.0
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: GA
: 5.4.0
Assignee: Brandon Dunne
QA Contact: Jan Krocil
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-03-25 21:49 UTC by Jan Krocil
Modified: 2015-06-16 12:55 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-06-16 12:55:16 UTC
Category: ---
Cloudforms Team: ---
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2015:1100 0 normal SHIPPED_LIVE CFME 5.4.0 bug fixes, and enhancement update 2015-06-16 16:28:42 UTC

Description Jan Krocil 2015-03-25 21:49:16 UTC
Description of problem:
Scheduled database backup is queued and ran but fails.
Tested using NFS.

Version-Release number of selected component (if applicable):
5.4.0.0.13

How reproducible:
Always

Steps to Reproduce:
1. Configure > Schedules > Add schedule
2. Choose Database Backup type and enter the necessary data
3. Wait for the backup to run

Actual results:
There are no backup files created on the target system and there is an error in evm.log:
[----] E, [2015-03-25T17:00:07.566364 #2238:673ea0] ERROR -- : MIQ(Schedule.invoke_actions) [my_schedule_name] Attempting to run action [action_db_backup] on target [DatabaseBackup], undefined method `id' for nil:NilClass

Expected results:
Files with DB backup are present on the target system.

Additional info:
I wasn't able to test single, direct DB backup (non-scheduled) because that part of the UI is broken and unavailable. I'm assuming that it would fail as well, though, since the scheduling part ran OK.
Based on that, I didn't include the "scheduled" in the summary of this bug but it is mentioned in the description.
Let me know if you want DEBUG-level log for this as well or if the error above is enough to track this down (I'm not seeing any more relevant info in the evm.log with INFO-level logging).

Comment 2 Joe Rafaniello 2015-03-26 15:00:23 UTC
I think it's blowing up because schedule.file_depot is nil.

https://github.com/ManageIQ/manageiq/blob/d5b65697da4a6e5c87cd9cf5508045d77d71ac4a/vmdb/app/models/miq_schedule.rb#L225

Following Jan's steps, creating a schedule for db backup creates a schedule with no file depot.

I created a schedule with name "blah" and depot "blah:

See: 

irb(main):008:0> MiqSchedule.where(:name => "blah").first
=> #<MiqSchedule id: 10, name: "blah", description: "blah", sched_action: {:method=>"db_backup"}, filter: nil, towhat: "DatabaseBackup", run_at: {:start_time=>2015-03-27 00:00:00 UTC, :tz=>"UTC", :interval=>{:unit=>"hourly", :value=>"1"}}, enabled: true, userid: "admin", prod_default: nil, last_run_on: nil, created_on: "2015-03-26 14:41:20", updated_at: "2015-03-26 14:41:20", 
miq_search_id: nil, zone_id: 1, adhoc: nil>


irb(main):009:0> FileDepot.first
=> #<FileDepot id: 1, name: "blah", resource_id: nil, resource_type: "MiqSchedule", uri: "nfs://blah", created_at: "2015-03-26 14:41:20", updated_at: "2015-03-26 14:41:20", type: nil, support_case: nil>

Note, resource_type is a MiqSchedule but the resource_id is nil.

Brandon, can you look at this?  I think it's related to the rewrite of log_file depots done for this BZ:  https://bugzilla.redhat.com/show_bug.cgi?id=965889

https://github.com/ManageIQ/manageiq/commit/a42bb4f829e34781d433854c7aca0db5ec36982f

https://github.com/ManageIQ/manageiq/commit/0ad0ad1b68edc843884875110edc3e1566b55618

https://github.com/ManageIQ/manageiq/commit/a2be452c75e07e8884a6f41b1e5cf089f12814d7

https://github.com/ManageIQ/manageiq/commit/f9f84ec6f96499803c94e5af020cc1aa1d80a89f

Comment 3 Brandon Dunne 2015-03-31 14:08:45 UTC
Researched and can reproduce that when the MiqSchedule is creating the FileDepot record, the MiqSchedule is not yet saved and does not yet have an ID, so the FileDepot saves the resource_type as "MiqSchedule" and the resource_id as nil.  I believe the best solution is to use the same type of relationship that log collection uses with file depots.

Comment 4 CFME Bot 2015-04-28 18:05:53 UTC
New commit detected on manageiq/master:
https://github.com/ManageIQ/manageiq/commit/81683c45fa88e17694db61703d8a7745dfb08bfa

commit 81683c45fa88e17694db61703d8a7745dfb08bfa
Author:     Brandon Dunne <bdunne>
AuthorDate: Mon Apr 20 11:36:31 2015 -0400
Commit:     Brandon Dunne <bdunne>
CommitDate: Mon Apr 27 14:19:14 2015 -0400

    Add file_depot_id to MiqSchedule
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1205898

 vmdb/app/models/file_depot.rb                      |  3 +-
 vmdb/app/models/miq_schedule.rb                    |  5 +--
 ...0330214408_add_file_depot_id_to_miq_schedule.rb | 39 ++++++++++++++++++++++
 ...14408_add_file_depot_id_to_miq_schedule_spec.rb | 30 +++++++++++++++++
 4 files changed, 74 insertions(+), 3 deletions(-)
 create mode 100644 vmdb/db/migrate/20150330214408_add_file_depot_id_to_miq_schedule.rb
 create mode 100644 vmdb/spec/migrations/20150330214408_add_file_depot_id_to_miq_schedule_spec.rb

Comment 5 CFME Bot 2015-04-28 18:05:57 UTC
New commit detected on manageiq/master:
https://github.com/ManageIQ/manageiq/commit/3e3ac4dfe08958e5b569b3a1415d4d9bad9d4635

commit 3e3ac4dfe08958e5b569b3a1415d4d9bad9d4635
Author:     Brandon Dunne <bdunne>
AuthorDate: Wed Apr 1 15:41:50 2015 -0400
Commit:     Brandon Dunne <bdunne>
CommitDate: Mon Apr 27 14:19:14 2015 -0400

    Remove no longer used belongs_to :resource and zone file_depots
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1205898

 vmdb/app/models/file_depot.rb   | 1 -
 vmdb/app/models/miq_schedule.rb | 1 -
 vmdb/app/models/zone.rb         | 1 -
 3 files changed, 3 deletions(-)

Comment 6 CFME Bot 2015-04-28 18:06:01 UTC
New commit detected on manageiq/master:
https://github.com/ManageIQ/manageiq/commit/0d86e9ce0c968422cf6deb2140173ce9f9fc6533

commit 0d86e9ce0c968422cf6deb2140173ce9f9fc6533
Author:     Brandon Dunne <bdunne>
AuthorDate: Thu Apr 2 14:01:59 2015 -0400
Commit:     Brandon Dunne <bdunne>
CommitDate: Mon Apr 27 14:19:15 2015 -0400

    Deprecate FileDepot#depot_hash getter and setter
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1205898

 vmdb/app/models/file_depot.rb | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comment 7 CFME Bot 2015-04-28 18:06:04 UTC
New commit detected on manageiq/master:
https://github.com/ManageIQ/manageiq/commit/a61800193bfae33c7570325830b236acb1102a89

commit a61800193bfae33c7570325830b236acb1102a89
Author:     Brandon Dunne <bdunne>
AuthorDate: Thu Apr 16 14:56:25 2015 -0400
Commit:     Brandon Dunne <bdunne>
CommitDate: Mon Apr 27 14:19:15 2015 -0400

    Create a proper FileDepot subclass rather than sending depot_hash=
    
    Remove old depot_hash and depot_hash= methods
    https://bugzilla.redhat.com/show_bug.cgi?id=1205898

 vmdb/app/controllers/application_controller.rb     |  2 +-
 vmdb/app/controllers/ops_controller/diagnostics.rb | 18 ++++++++----
 .../ops_controller/settings/schedules.rb           | 14 +++++----
 vmdb/app/models/file_depot_ftp.rb                  |  7 ++---
 vmdb/app/models/file_depot_smb.rb                  |  4 +++
 vmdb/app/models/miq_schedule.rb                    | 34 +++++++---------------
 vmdb/spec/models/miq_schedule_spec.rb              | 14 ---------
 7 files changed, 40 insertions(+), 53 deletions(-)

Comment 8 CFME Bot 2015-04-28 18:06:08 UTC
New commit detected on manageiq/master:
https://github.com/ManageIQ/manageiq/commit/6bbdc98162785f28c5313e86237e6bcf543bedd4

commit 6bbdc98162785f28c5313e86237e6bcf543bedd4
Author:     Brandon Dunne <bdunne>
AuthorDate: Mon Apr 20 15:39:36 2015 -0400
Commit:     Brandon Dunne <bdunne>
CommitDate: Mon Apr 27 14:19:15 2015 -0400

    Leverage EvmSpecHelper, move out of context since everything needs it
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1205898

 vmdb/spec/models/miq_schedule_spec.rb | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

Comment 9 CFME Bot 2015-04-28 18:06:12 UTC
New commit detected on manageiq/master:
https://github.com/ManageIQ/manageiq/commit/169d6797fdfb117c4a81319640b2027b73ac4a11

commit 169d6797fdfb117c4a81319640b2027b73ac4a11
Author:     Brandon Dunne <bdunne>
AuthorDate: Mon Apr 20 15:44:18 2015 -0400
Commit:     Brandon Dunne <bdunne>
CommitDate: Mon Apr 27 15:33:06 2015 -0400

    Test logic moved to #verify_file_depot method in its own context
    
    This method replaces depot_hash and depot_hash=
    https://bugzilla.redhat.com/show_bug.cgi?id=1205898

 vmdb/spec/factories/file_depot_ftp.rb |   6 ++
 vmdb/spec/models/miq_schedule_spec.rb | 106 +++++++---------------------------
 2 files changed, 28 insertions(+), 84 deletions(-)
 create mode 100644 vmdb/spec/factories/file_depot_ftp.rb

Comment 10 CFME Bot 2015-04-28 18:06:16 UTC
New commit detected on manageiq/master:
https://github.com/ManageIQ/manageiq/commit/242390e54de66055ffc3d5fb011ca373b1c5f494

commit 242390e54de66055ffc3d5fb011ca373b1c5f494
Author:     Brandon Dunne <bdunne>
AuthorDate: Mon Apr 20 18:12:16 2015 -0400
Commit:     Brandon Dunne <bdunne>
CommitDate: Mon Apr 27 15:33:15 2015 -0400

    Update callers of MiqSchedule#depot_hash to use file_depot relationship
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1205898

 vmdb/app/controllers/ops_controller.rb                   |  2 +-
 vmdb/app/controllers/ops_controller/diagnostics.rb       | 16 ++--------------
 .../app/controllers/ops_controller/settings/schedules.rb | 14 ++++----------
 3 files changed, 7 insertions(+), 25 deletions(-)

Comment 11 CFME Bot 2015-04-28 18:06:19 UTC
New commit detected on manageiq/master:
https://github.com/ManageIQ/manageiq/commit/50f1502884e9b382905513ef76488532616a14de

commit 50f1502884e9b382905513ef76488532616a14de
Author:     Brandon Dunne <bdunne>
AuthorDate: Tue Apr 21 08:24:48 2015 -0400
Commit:     Brandon Dunne <bdunne>
CommitDate: Mon Apr 27 15:33:17 2015 -0400

    resource_id and type have been removed
    
    No reason to create an unused record.
    https://bugzilla.redhat.com/show_bug.cgi?id=1205898

 vmdb/spec/controllers/ops_controller_spec.rb | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

Comment 13 Jan Krocil 2015-05-11 13:07:09 UTC
Verified fixed in 5.4.0.0.25.

Comment 15 errata-xmlrpc 2015-06-16 12:55:16 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2015-1100.html


Note You need to log in before you can comment on or make changes to this bug.