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

Add condition to fix deletion of Default Container Image Rate #16792

Conversation

hstastna
Copy link

@hstastna hstastna commented Jan 10, 2018

Fixing https://bugzilla.redhat.com/show_bug.cgi?id=1486658
This PR has to be merged with ManageIQ/manageiq-ui-classic#3215
to completely fix the bug.


Summary:
Add condition to ensure_nondefault method in chargeback rate model to fix deletion of Default Container Image Rate in Cloud Intel -> Chargeback -> Rates so that the Rate can't be deleted and error message is properly displayed.

Explanation:
Originally, checking if the selected rate is default (before its deletion), did not work well only if deleting rate(s) from a list of the rates. This was because of missing part of the condition for checking default rates here:
https://github.com/ManageIQ/manageiq/blob/master/app/models/chargeback_rate.rb#L153
Checking if the rate is default, worked only from rate details page. This was because of
https://github.com/ManageIQ/manageiq-ui-classic/blob/master/app/helpers/application_helper/button/chargeback_rate_remove.rb#L12
So I added the missing part of the condition here (this PR): https://github.com/ManageIQ/manageiq/compare/master...hstastna:Default_Container_Image_Rate_delete_description?expand=1#diff-7c998acd3d11c70ed830e216754f4b6bR153
I also edited cb_rates_delete method in chargeback controller to be able to properly delete nondefault rates and also to show error messages about deleting default rates and list of the remaining rates - in a one step (more about this here ManageIQ/manageiq-ui-classic#3215)

The bug is related to Compute Chargeback rates.

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

Add condition to ensure_nondefault method in chargeback rate model to fix
deletion of Default Container Image Rate in Cloud Intel -> Chargeback ->
Rates so that the Rate can't be deleted and error message is displayed.
@hstastna
Copy link
Author

@miq-bot add_label bug, gaprindashvili/yes

@miq-bot
Copy link
Member

miq-bot commented Jan 10, 2018

Checked commits hstastna/manageiq@ad0476e~...65ddd88 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 0 offenses detected
Everything looks fine. 🍰

@hstastna
Copy link
Author

@martinpovolny @lpichler @h-kataria What do you think about this? Thanks a lot! ❇️

Copy link
Contributor

@lpichler lpichler left a comment

Choose a reason for hiding this comment

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

I think that there is no other way how to do it. Is it also default (as rates with ChargebackRate#default ==true)rate because of the specific rate name (''Default Container Image Rate'') from a yml.

@lpichler
Copy link
Contributor

cc @zeari

@lpichler
Copy link
Contributor

@miq-bot assign @gtanzillo

@@ -150,7 +150,7 @@ def ensure_unassigned
end

def ensure_nondefault
if default?
if default? || description == 'Default Container Image Rate'
Copy link
Contributor

Choose a reason for hiding this comment

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

@hstastna few questions, can't description be edited, or have same chargeback rate with same description, or is description unique among chargeback rates?

Copy link
Contributor

Choose a reason for hiding this comment

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

@gtanzillo @lpichler if "Default Container Image Rate" is a default rate that gets seeded from yml, why dont we change yml to populate default field as true here https://github.com/ManageIQ/manageiq/blob/master/db/fixtures/chargeback_rates.yml#L155

Copy link
Author

@hstastna hstastna Jan 17, 2018

Choose a reason for hiding this comment

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

@h-kataria If I click on Edit this Chargeback rate and try to change the description of 'Default Container Image Rate' and click on Save, the flash message occurs:
Can not change description of 'Default Container Image Rate'
If I try to add a new rate with the same description, the flash message occurs:
Description has already been taken
so I think this all works properly. I hope I understood your question properly 👼

Copy link
Contributor

Choose a reason for hiding this comment

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

@hstastna i see that change was made here ManageIQ/manageiq-ui-classic#269 to not allow edit of Default Container Image chargeback rate. I still think it should have been marked as default rate to begin with. @gtanzillo @lpichler @dclarizio any comments?

Copy link
Contributor

Choose a reason for hiding this comment

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

@h-kataria we added it here #13063 and what I remember we needed to distinguish this specific rate and it was possible only according to name. But yes it isn't the reason why we didn't set ChargebackRate#default to true in yaml. Maybe it was causing issues. Can you remember @zeari ?

Copy link

Choose a reason for hiding this comment

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

What we needed was a default-fallback rate, that if no rate is assigned that one is used.
We also needed the ability to edit it which wasnt possible for default rates.

Since default rates were not editable we made a special case of out "Default container image rate". The only place where that is used is in Chargeback for container images.

@gtanzillo gtanzillo modified the milestones: Roadmap, Sprint 78 Ending Jan 29, 2018 Jan 24, 2018
@gtanzillo gtanzillo merged commit 164cd08 into ManageIQ:master Jan 24, 2018
simaishi pushed a commit that referenced this pull request Mar 6, 2018
…delete_description

Add condition to fix deletion of Default Container Image Rate
(cherry picked from commit 164cd08)

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

simaishi commented Mar 6, 2018

Gaprindashvili backport details:

$ git log -1
commit b4ecec83c0bde5903261aef088ea594310522308
Author: Gregg Tanzillo <gtanzill@redhat.com>
Date:   Wed Jan 24 09:03:33 2018 -0500

    Merge pull request #16792 from hstastna/Default_Container_Image_Rate_delete_description
    
    Add condition to fix deletion of Default Container Image Rate
    (cherry picked from commit 164cd082924e89a20acd810cdb9b3f383a2f01a9)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1552260

@hstastna
Copy link
Author

@miq-bot add_label fine/yes

simaishi pushed a commit that referenced this pull request Apr 16, 2018
…delete_description

Add condition to fix deletion of Default Container Image Rate
(cherry picked from commit 164cd08)

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

Fine backport details:

$ git log -1
commit d3cb71cead6dc896e9df788427d8787f7bb0b31e
Author: Gregg Tanzillo <gtanzill@redhat.com>
Date:   Wed Jan 24 09:03:33 2018 -0500

    Merge pull request #16792 from hstastna/Default_Container_Image_Rate_delete_description
    
    Add condition to fix deletion of Default Container Image Rate
    (cherry picked from commit 164cd082924e89a20acd810cdb9b3f383a2f01a9)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1568084

d-m-u pushed a commit to d-m-u/manageiq that referenced this pull request Jun 6, 2018
…ge_Rate_delete_description

Add condition to fix deletion of Default Container Image Rate
(cherry picked from commit 164cd08)

https://bugzilla.redhat.com/show_bug.cgi?id=1568084
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.

7 participants