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

Do not delete report if task associated with this report deleted #15134

Merged

Conversation

yrudman
Copy link
Contributor

@yrudman yrudman commented May 17, 2017

Issue: Deleting task (in task management screen) also deleting report linked to that task

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

Fixes:

  • remove :dependent => :destroy on association between MiqTask and MiqReportResult
  • allow to access saved report after associated task deleted: MiqReportResult#status now returns Completed if associated task deleted

AFTER: on screenshot first report has task associated with it and for last 2 reports (one successful and one failed) associated task was deleted
screen shot 2017-05-22 at 12 00 39 pm

@miq-bot add-label core, bug

@yrudman yrudman changed the title [WIP] Do not delete report if task associated with this report deleted Do not delete report if task associated with this report deleted May 18, 2017
@miq-bot miq-bot removed the wip label May 18, 2017
@yrudman yrudman changed the title Do not delete report if task associated with this report deleted [WIP] Do not delete report if task associated with this report deleted May 18, 2017
@miq-bot miq-bot added the wip label May 18, 2017
@yrudman yrudman force-pushed the fix-deleting-report-when-task-deleted branch from 79ce384 to fd9a6b7 Compare May 22, 2017 12:47
@yrudman yrudman changed the title [WIP] Do not delete report if task associated with this report deleted Do not delete report if task associated with this report deleted May 22, 2017
@miq-bot miq-bot removed the wip label May 22, 2017
@yrudman yrudman force-pushed the fix-deleting-report-when-task-deleted branch from fd9a6b7 to 0945005 Compare May 22, 2017 13:09
@yrudman
Copy link
Contributor Author

yrudman commented May 22, 2017

@gtanzillo rebased and ready for the second review

@yrudman yrudman force-pushed the fix-deleting-report-when-task-deleted branch from 0945005 to d692cb1 Compare May 22, 2017 16:10
@@ -32,11 +30,16 @@ def result_set
end

def status
MiqTask.human_status(state_or_status)
task = MiqTask.find_by(:id=>miq_task_id)
Copy link
Member

Choose a reason for hiding this comment

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

You should be able to reference the association miq_task here instead of doing MiqTask.find_by(:id=>miq_task_id)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gtanzillo right, no need for find_by, changed

@yrudman yrudman force-pushed the fix-deleting-report-when-task-deleted branch from d692cb1 to ef6922c Compare May 23, 2017 12:36
@miq-bot
Copy link
Member

miq-bot commented May 24, 2017

This pull request is not mergeable. Please rebase and repush.

@yrudman yrudman force-pushed the fix-deleting-report-when-task-deleted branch from ef6922c to 063e202 Compare May 24, 2017 15:39
@@ -36,7 +36,7 @@ def status
end

def status_message
miq_task.nil? ? _("Report results are no longer available") : miq_task.message
miq_task.nil? ? _("Task associated with this report no longer available") : miq_task.message
Copy link
Member

Choose a reason for hiding this comment

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

I believe this is logged or in the UI so, maybe The task associated with this report is no longer available"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks!

@@ -125,6 +125,33 @@
end
end

describe "#state" do
Copy link
Member

Choose a reason for hiding this comment

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

the tests here are testing #status, not #state

Copy link
Contributor Author

Choose a reason for hiding this comment

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

my mistake

@@ -11,10 +11,8 @@ class MiqReportResult < ApplicationRecord
serialize :report

virtual_delegate :description, :to => :miq_group, :prefix => true, :allow_nil => true
virtual_delegate :state_or_status, :to => "miq_task", :allow_nil => true
virtual_attribute :status, :string, :uses => :state_or_status
Copy link
Member

Choose a reason for hiding this comment

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

I can't tell, is this required for this PR? How do you know it's unused? Can you locate the last caller or why it's unused?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Search for string state_or_statusacross all projects: found only in MiqTask and it is not invocation of MiqTaskResult.state_or_status

@jrafanie
Copy link
Member

@yrudman your commit message first line (subject) are too long:

image

Try to keep them under 70 characters

@jrafanie
Copy link
Member

Are you comfortable squashing commits? The second and fourth commit are related in that the fourth undoes the way the second commit works and does it differently. They should probably be squashed since the first commit doesn't really stand on it's own anymore.

@yrudman yrudman force-pushed the fix-deleting-report-when-task-deleted branch from 063e202 to 246f6a6 Compare May 30, 2017 22:36
@yrudman
Copy link
Contributor Author

yrudman commented May 30, 2017

@jrafanie yes, separate commits looks confusing, rebased to 1 commit...

expect(miq_report_result.status).to eq "Running"
end

it "returns 'Complete' if report generated and associated task exists" do
Copy link
Member

Choose a reason for hiding this comment

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

there's two spaces after report here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, fixed

Copy link
Member

@jrafanie jrafanie left a comment

Choose a reason for hiding this comment

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

LGTM with minor nitpick. I don't understand the use case of deleting tasks so I'm not sure what's expected, but this definitely solves the BZ.

BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1450272
Changes:
- removed :dependent => :destroy on miq_report_result association in MiqTask
- refactor MiqReportResult#status to return 'Complete' if task asociated with report deleted
- added test coverage for MiqReportResult#status
- remove not used virtual_delegate to MiqTask#state_or_status
@yrudman yrudman force-pushed the fix-deleting-report-when-task-deleted branch from 246f6a6 to fa4ebc6 Compare June 1, 2017 18:05
@miq-bot
Copy link
Member

miq-bot commented Jun 1, 2017

Checked commit yrudman@fa4ebc6 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
3 files checked, 0 offenses detected
Everything looks fine. 🍪

@jrafanie
Copy link
Member

jrafanie commented Jun 1, 2017

@gtanzillo please review #15134 (review)... I'm good with the change but don't understand the use case of deleting tasks to know what the expected behavior is.

Copy link
Member

@gtanzillo gtanzillo left a comment

Choose a reason for hiding this comment

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

I'm good with this change. 👍 Thanks for reviewing @jrafanie

@gtanzillo gtanzillo added this to the Sprint 62 Ending Jun 5, 2017 milestone Jun 1, 2017
@gtanzillo gtanzillo merged commit c17d043 into ManageIQ:master Jun 1, 2017
@yrudman yrudman deleted the fix-deleting-report-when-task-deleted branch June 2, 2017 11:26
simaishi pushed a commit that referenced this pull request Jun 12, 2017
…deleted

Do not delete report if task associated with this report deleted
(cherry picked from commit c17d043)

https://bugzilla.redhat.com/show_bug.cgi?id=1460394
@simaishi
Copy link
Contributor

Fine backport details:

$ git log -1
commit 403b51d97b0c730db157c065c704e0994c9704fa
Author: Gregg Tanzillo <gtanzill@redhat.com>
Date:   Thu Jun 1 17:57:11 2017 -0400

    Merge pull request #15134 from yrudman/fix-deleting-report-when-task-deleted
    
    Do not delete report if task associated with this report deleted
    (cherry picked from commit c17d0430bd143dbf3e40c131c2dc831bd4958bae)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1460394

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants