Bug 1575077 - Deleting a recently shutdown appliance silently fails
Summary: Deleting a recently shutdown appliance silently fails
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: UI - OPS
Version: 5.9.0
Hardware: All
OS: All
medium
medium
Target Milestone: GA
: cfme-future
Assignee: Zita Nemeckova
QA Contact: Tasos Papaioannou
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-05-04 17:09 UTC by Tasos Papaioannou
Modified: 2019-06-11 15:26 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-06-11 15:26:59 UTC
Category: ---
Cloudforms Team: ---
Target Upstream Version:


Attachments (Terms of Use)

Description Tasos Papaioannou 2018-05-04 17:09:10 UTC
Description of problem:

If you shut down then a secondary appliance, then try to delete it from the web UI before it has been unresponsive for 10 minutes, then the deletion silently fails.

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

5.9.2.4

How reproducible:

100%

Steps to Reproduce:
1.) Shut down a secondary appliance.
2.) Wait 5 minutes.
3.) Verify that appliance shows as Not Responding in the web UI:
Administrator > Configuration > Diagnostics > Roles by Servers
4.) Delete server from db:
Click on Server: EVM [2] (not responding) > Configuration > Delete Server EVM [2] > OK

Actual results:

Flash message "Server "EVM [2]": Delete successful" appears after clicking OK, but server does not actually get deleted. evm.log shows:

[----] E, [2018-05-04T12:52:19.218086 #2614:117d904] ERROR -- : MIQ(MiqServer#validate_is_deleteable) Cannot delete recently active MiqServer [EVM] with ID: [2]
[----] I, [2018-05-04T12:52:19.222926 #2614:117d904]  INFO -- : <AuditSuccess> MIQ(Diagnostics.process_server_deletion) userid: [admin] - [EVM] Record deleted

Expected results:

Flash message shows the correct error message explaining why server can't be deleted, and evm.log/audit.log doesn't log "Record deleted" messages.


Additional info:

./app/models/miq_server.rb hardcodes 10 minutes as 'recently active':

  def is_recently_active?
    last_heartbeat && (last_heartbeat >= 10.minutes.ago.utc)
  end

and does not allow the server record to be deleted if it is recently active:

  def is_deleteable?
    if self.is_local?
      @error_message = N_("Cannot delete currently used %{log_message}") % {:log_message => format_short_log_msg}
      return false
    end
    return true if self.stopped?

    if is_recently_active?
      @error_message = N_("Cannot delete recently active %{log_message}") % {:log_message => format_short_log_msg}
      return false
    end

    true
  end

Comment 2 Tasos Papaioannou 2018-05-04 17:12:58 UTC
After the server has been unresponsive for more than 10 minutes, the server record can be deleted successfully, but the Diagnostics accordion does not get updated. Clicking on the now-deleted server from the Diagnostics accordion leads to a flash error message:

"Last selected Server no longer exists"

Comment 3 Joe Rafaniello 2018-05-07 20:12:53 UTC
This PR will fix the backend validation: https://github.com/ManageIQ/manageiq/pull/17391

This will not fix the UI interaction described in the BZ though.  The UI code will need to attempt to destroy the server record and check the server.errors for any error messages.

Comment 4 Joe Rafaniello 2018-05-07 20:37:04 UTC
Reassigning to the UI team... 

1) I was able to boot with rails s, make sure my server was created
2) remove my GUID file and bin/rails s again, make sure my server showed up in the Diagnostics tab as a second server.
3) I then modified my original server, id 1 in rails console:

s = MiqServer.find(1)
s.update(:last_heartbeat => 5.minutes.ago, :status => "stopped", :is_master => false)

4) I then rails s and attempted to delete my first server in diagnostics (servers) screen and was now able to (it wasn't grayed out) but it silently did nothing.

I see this in my rails log (dev mode):
F, [2018-05-07T15:52:08.026505 #94864] FATAL -- : Error caught: [ActionView::MissingTemplate] Missing partial ops/_tree, application/_tree with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby, :coffee, :haml, :rjs]}. Searched in:
  * "/Users/joerafaniello/.gem/ruby/2.4.4/bundler/gems/miq_v2v_ui_plugin-f45e51c1e266/app/views"
  * "/Users/joerafaniello/.gem/ruby/2.4.4/bundler/gems/manageiq-ui-classic-56248224ca5a/app/views"


The UI code will need to attempt to destroy the record and then check the errors for any failure messages as shown in my unit tests.

Comment 5 CFME Bot 2018-05-30 22:02:11 UTC
New commit detected on ManageIQ/manageiq/master:

https://github.com/ManageIQ/manageiq/commit/7040201ebe5f1d39f01d9eec7a5647c09fb4a94f
commit 7040201ebe5f1d39f01d9eec7a5647c09fb4a94f
Author:     Joe Rafaniello <jrafanie@redhat.com>
AuthorDate: Mon May  7 12:20:18 2018 -0400
Commit:     Joe Rafaniello <jrafanie@redhat.com>
CommitDate: Mon May  7 12:20:18 2018 -0400

    Fix current/active server deletability validation

    https://bugzilla.redhat.com/show_bug.cgi?id=1575077

    Note, the UI will need to check server.errors after attempting to
    destroy the record to see any errors.

 app/models/miq_server.rb | 11 +-
 spec/models/miq_server_spec.rb | 17 +
 2 files changed, 24 insertions(+), 4 deletions(-)

Comment 7 Joe Rafaniello 2019-02-07 17:01:08 UTC
No, this BZ is half done.  The backend now stores the validation error and the UI will have to check for errors and display them.


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