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

Fix Refresh Relationships and Power States button for VMs, Instances, Images #17863

Merged

Conversation

hstastna
Copy link

@hstastna hstastna commented Aug 15, 2018

Related BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1600678
Related UI PR: ManageIQ/manageiq-ui-classic#4301


There is a problem with Refresh Relationships and Power States button in all of the pages under Compute > Clouds and also Compute > Infra while trying to refresh relationships and power states of any VM, Instance or Image. It's because validate_refresh_ems method is called every time we try to refresh relationships and power states, but this method does not exist. Similar problem was recently with destroy action, this is the PR which fixed that: #17780

Steps to reproduce: (one of possible scenarios)

  1. Go to Compute > Clouds/Infra > Providers and add some provider if there is no one
  2. In provider's details screen, in Relationships table, click on Images/Instances/VMs
  3. Choose some items (check the checkboxes) or display details page of some item
  4. Click on Configuration > Refresh Relationships and Power States
    => refresh is not initiated, error:
----] I, [2018-08-15T19:01:10.256508 #1514:2b1901556f28]  INFO -- : Started POST "/ems_cloud/button/38?pressed=miq_template_refresh" for ::1 at 2018-08-15 19:01:10 +0200
[----] I, [2018-08-15T19:01:10.305767 #1514:2b1901556f28]  INFO -- : Processing by EmsCloudController#button as JS
[----] I, [2018-08-15T19:01:10.305926 #1514:2b1901556f28]  INFO -- :   Parameters: {"miq_grid_checks"=>"2099", "check_2099"=>"2099", "pressed"=>"miq_template_refresh", "id"=>"38"}
[----] W, [2018-08-15T19:01:10.317314 #1514:2b1901556f28]  WARN -- : DEPRECATION WARNING: Please pass the privilege you want to check for when refreshing
 (called from process_vm_buttons at /home/hstastna/manageiq/manageiq-ui-classic/app/controllers/application_controller/ci_processing.rb:999)
[----] F, [2018-08-15T19:01:10.483397 #1514:2b1901556f28] FATAL -- : Error caught: [NoMethodError] undefined method `validate_refresh_ems' for #<ManageIQ::Providers::Amazon::CloudManager::Template:0x007fa98b94a368>
Did you mean?  validates_presence_of
/home/hstastna/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/activemodel-5.0.7/lib/active_model/attribute_methods.rb:433:in `method_missing'
/home/hstastna/manageiq/manageiq/app/models/mixins/availability_mixin.rb:24:in `is_available?'
/home/hstastna/manageiq/manageiq-ui-classic/app/helpers/application_helper.rb:219:in `block in records_support_feature?'
/home/hstastna/manageiq/manageiq-ui-classic/app/helpers/application_helper.rb:215:in `each'
/home/hstastna/manageiq/manageiq-ui-classic/app/helpers/application_helper.rb:215:in `find'
/home/hstastna/manageiq/manageiq-ui-classic/app/helpers/application_helper.rb:215:in `records_support_feature?'

Before:
refresh_before

After:
refresh_after

@hstastna
Copy link
Author

@miq-bot add_label bug

@hstastna
Copy link
Author

@agrare @Ladas What do you think about this? The problem and the fix is very similar to #17780

@hstastna
Copy link
Author

hstastna commented Aug 15, 2018

I also haven't found any BZ for exactly this problem. Do you think I should create the new one or can the problem be part of related BZ I have mentioned in the description of this PR (https://bugzilla.redhat.com/show_bug.cgi?id=1600678) ? It's about some not working toolbar buttons, generally. Thank you for any advice! :)

Copy link
Contributor

@Ladas Ladas left a comment

Choose a reason for hiding this comment

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

looks good

@agrare the reason we see this issue is that now every button must have supports or the old validate.

@Ladas
Copy link
Contributor

Ladas commented Aug 16, 2018

@miq-bot assign @agrare

@agrare
Copy link
Member

agrare commented Aug 16, 2018

@hstastna @Ladas IDK about this, it doesn't seem like the common supports_feature usecase where some types support X and some do not. Every VM/Template/Host/EMS support refresh, it is implemented in the base class.

@Ladas
Copy link
Contributor

Ladas commented Aug 16, 2018

@agrare right, then probably more places will be failing with missing validate/supports method :-)

@agrare
Copy link
Member

agrare commented Aug 16, 2018

@Ladas yeah exactly what I'm worried about. For example will we get the same error for refresh_ems on an ExtManagementSystem? How about Host?

@agrare
Copy link
Member

agrare commented Aug 16, 2018

@martinpovolny WDYT? These buttons aren't something that make sense for supports_feature_mixin IMO.

@Ladas
Copy link
Contributor

Ladas commented Aug 17, 2018

@agrare I think for consistency, every button acts the same now. So I think the UI team is now hunting the actions not having support.

@martinpovolny
Copy link
Member

martinpovolny commented Aug 18, 2018

@martinpovolny WDYT? These buttons aren't something that make sense for supports_feature_mixin IMO.

Actually a good deal of buttons test for a particular feature. In many cases button "A" tests for feature "A". But generally buttons "B, C, D" can test for a feature "E". See here: https://github.com/ManageIQ/guides/blob/master/ui/toolbars.md

This makes sense to me: a particular function requires existing support on the backend.

From the UI perspective we would love to do this in a unified way. However in reality we have support? and validates and in some places we have ad-hoc code. I know that Marcel was working on unifying that but I am not sure that someone has taken over that effort.

As @Ladas wrote:

@agrare I think for consistency, every button acts the same now. So I think the UI team is now hunting the actions not having support.

Really we have BZs that are caused by inconsistencies in the behavior of button actions and are trying to unify and generalize the behavior. We believe that unification of the behavion not only leaves us with less code but gives us less buggy and easier to maintain codebase ;-)

@martinpovolny
Copy link
Member

@agrare : To sum up: Is there any other feature that the UI can test for to see if refresh is supported? If so then we don't need this PR. Else we do need it. We need to know if refresh is supported.

@agrare
Copy link
Member

agrare commented Aug 24, 2018

To sum up: Is there any other feature that the UI can test for to see if refresh is supported?

I'm still confused, are these buttons generic for all types of inventory or specific for VMs?
If they are specific for VMs then you don't need to see if refresh is supported, refresh is supported always for all VM instances so no need to check. There are some buttons which aren't supported/unsupported based on the type of object right? Remove from VMDB comes to mind right?

If it is generic for all types then I don't know why we don't need to also add this to ExtManagementSystem, Host, anything that has #refresh_ems defined.

Basically I'm confused why this is only being added to Vms.

@Ladas
Copy link
Contributor

Ladas commented Aug 27, 2018

@agrare so the change is that @romanblanco refactored the button code, so that every action must have supports (or the old validate_something..), so we can do this checks in a consistent way. E.g. there was a 'supports' code for refresh, but it was as a hacky pieces of code scattered somewhere in controllers (and I think it always returned true, it was just hidden in some crazy conditions).

That being said, I think we should have specs or something to check all buttons are working (e.g. all of them have supports/validate implemented), since it looks like we are discovering that manually now, @romanblanco @martinpovolny ?

@romanblanco
Copy link
Member

romanblanco commented Aug 27, 2018

That being said, I think we should have specs or something to check all buttons are working (e.g. all of them have supports/validate implemented), since it looks like we are discovering that manually now, @romanblanco @martinpovolny ?

@Ladas the problem with this is we don't have a consistent list of all the supported features for each entities we test in the toolbar buttons.

I can get a list of features and a list of toolbar buttons doing the test, but I don't know how they should respond.

@Ladas
Copy link
Contributor

Ladas commented Aug 27, 2018

@romanblanco not sure I understand. There should be a way to write a spec for every button, that will catch bugs like in this PR?

@Ladas
Copy link
Contributor

Ladas commented Aug 27, 2018

@romanblanco ah, I see what you're saying. I think it's ok if you'll test that everything is unsupported by default (except things like refresh that are supported by all providers). So we'll at least test that it won't explode.

@agrare
Copy link
Member

agrare commented Aug 27, 2018

@hstastna is this still an problem? I wasn't able to reproduce...I added a provider and was able to refresh relationships & power states for a provider, vm, and a host without issue.

@hstastna
Copy link
Author

hstastna commented Aug 27, 2018

@agrare Yes, it is still a problem. Did you follow my steps to reproduce in the description of the PR? The important detail here is that for VMs under Compute > Infra > VMs it works but in any other screen displaying VMs (nested list of VMs), it does not work. So it depends where you are, how did you display the list of VMs.

@agrare
Copy link
Member

agrare commented Aug 30, 2018

@hstastna okay I still don't see this, but if we're seeing this on vms we'll eventually see it for the rest of the types so can you add supports :refresh_ems to the rest of the models that have it?

A quick grep shows: provider, physical_chassis, physical_rack, physical_server, physical_server, physical_switch, physical_storage, host, vm_or_template, ext_management_system, and orchestration_stack.

@hstastna
Copy link
Author

hstastna commented Aug 31, 2018

@agrare Thank you, Adam. I will take a look and will add the line to the rest of models. But probably we will not need to add it to all of them you have mentioned. For example, when I try to refresh relationships of some provider, it works well. This is because not every action goes thru generic_button_operation method (in the UI code). But if yes, then this line is crucial: https://github.com/hstastna/manageiq-ui-classic/blob/master/app/controllers/application_controller/ci_processing.rb#L665 The problem will be mainly with refresh of items displayed in a nested list.
Originally, I was trying to fix the problem (and some another problem with some other action, before this problem with refresh occurred) by making changes in testable_action method to return false (yes, it fixed the problem), but I was told not to do it because it could be very problematic in the future. It turned out that adding supports :refresh_ems to appropriate model is the best solution.

@hstastna hstastna force-pushed the Error_refresh_relationships_vm_instance branch from d1ca244 to e73600d Compare September 3, 2018 11:39
@hstastna
Copy link
Author

hstastna commented Sep 3, 2018

@agrare The only place I've found where refresh does not work with this PR, is refresh of Hosts displayed thru Compute > Clouds > Host Aggregates > some host aggregate details page. But no error.. so there must be different problem. I will take a look more and will try to fix it.

@hstastna
Copy link
Author

hstastna commented Sep 4, 2018

@agrare I think that this PR can be merged. The problem with refresh of Hosts displayed thru Compute > Clouds > Host Aggregates > some host aggregate details page is not a problem with refresh but any action in that page (tagging etc.). I would better fix this in a separate PR.

@kbrock
Copy link
Member

kbrock commented Sep 4, 2018

I think this needs a rebase with current master - that should fix the travis failure

@hstastna hstastna force-pushed the Error_refresh_relationships_vm_instance branch from 2231676 to d5b3c09 Compare September 4, 2018 14:28
@agrare
Copy link
Member

agrare commented Sep 4, 2018

@hstastna you just need to include SupportsFeatureMixin to any models that don't have it yet

@hstastna hstastna changed the title Fix Refresh Relationships and Power States button for VMs, Instances, Images [WIP] Fix Refresh Relationships and Power States button for VMs, Instances, Images Sep 4, 2018
@miq-bot miq-bot added the wip label Sep 4, 2018
@hstastna hstastna force-pushed the Error_refresh_relationships_vm_instance branch from d5b3c09 to 493d20f Compare September 4, 2018 14:58
@miq-bot
Copy link
Member

miq-bot commented Sep 4, 2018

Checked commits hstastna/manageiq@566fb1e~...493d20f with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
11 files checked, 0 offenses detected
Everything looks fine. 🏆

@hstastna hstastna changed the title [WIP] Fix Refresh Relationships and Power States button for VMs, Instances, Images Fix Refresh Relationships and Power States button for VMs, Instances, Images Sep 4, 2018
@agrare agrare removed the wip label Sep 4, 2018
@agrare agrare merged commit b1acd59 into ManageIQ:master Sep 4, 2018
@agrare agrare added this to the Sprint 94 Ending Sept 10, 2018 milestone Sep 4, 2018
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