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

Cloud Volume creation fixes #4908

Merged
merged 11 commits into from
Nov 26, 2018
Merged

Conversation

martinpovolny
Copy link
Member

@martinpovolny martinpovolny commented Nov 13, 2018

Fixes:

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

  • CloudVolume create: Need to turn off the spinner in both if/else branches.
  • Fix a crash when there is a CloudManager that does not have a CloudVolume. Such as Azure.
  • Fix the storage manager is not being loaded when creating a new Volume (and therefor emstype (and possibly other) parameters where missing) . Therefor the case when adding a new volume w/o selecting a storage manager did not work.

Part of the problems seem to be coming from 771e97f .

Populate volume types for EBS. Fixing:
https://bugzilla.redhat.com/show_bug.cgi?id=1644306

I have issues with understanding what are all the possible situations here and what is the expected behavior. Review and more testing is very welcome. Ping @mansam, @miha-plesko, @gberginc

@martinpovolny martinpovolny changed the title Cloud Volume creation fixes [WIP] Cloud Volume creation fixes Nov 16, 2018
@miq-bot miq-bot added the wip label Nov 16, 2018
@martinpovolny martinpovolny requested review from andyvesel and removed request for alexander-demicev and andyvesel November 16, 2018 12:49
@martinpovolny
Copy link
Member Author

ping @AlexanderZagaynov

@AlexanderZagaynov
Copy link

AlexanderZagaynov commented Nov 16, 2018

Looks like it works now (with your PR).
screenshot from 2018-11-16 16-45-26

@martinpovolny martinpovolny changed the title [WIP] Cloud Volume creation fixes Cloud Volume creation fixes Nov 19, 2018
@miq-bot miq-bot removed the wip label Nov 19, 2018
@@ -270,6 +277,8 @@ ManageIQ.angular.app.controller('cloudVolumeFormController', ['miqService', 'API
vm.supportsCinderVolumeTypes = data.supports_cinder_volume_types;
if (vm.supportsCinderVolumeTypes) {
vm.volumeTypes = data.parent_manager.cloud_volume_types;
} else if (vm.cloudVolumeModel.emstype === 'ManageIQ::Providers::Amazon::StorageManager::Ebs') {
loadEBSVolumeTypes();
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to call it here as well? I think we call it inside setForm() already which is called regardless where we arrived to the page from.

Copy link
Member Author

Choose a reason for hiding this comment

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

The vm.storageManagerChanged is called from https://github.com/ManageIQ/manageiq-ui-classic/blob/master/app/views/cloud_volume/_common_new_edit.html.haml#L8. And from, there I need to populate the Volume types when the provider type is selected.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I see 👍 You actually moved it to better place, we should probably delete it from setForm function eventually (not sure if in this PR that will be backported)

@miha-plesko
Copy link
Contributor

For some reason I'm getting this error when arriving to the page via AWS volumes:

image

But it seems to be working when arriving from all volumes page.

@martinpovolny
Copy link
Member Author

@miha-plesko : Please, provide more detailed steps for the error that you found. I'd love to reproduce what you got.

To be honest I am pretty lost in this form. It seems to be doing multiple things from multiple contexts and I don't know all the situations then need to be covered. I welcome any help here.

@miha-plesko
Copy link
Contributor

Ahh, I know what it is. There is also variant c) to access the page - not through EBS manager, but through EC2 provider itself.

Comput > Cloud > Providers > "my aws" > Cloud Volumes

On this page it's also possible to click "Add new volume" but here storage_manager_id querystring parameter actually holds EC2 id instead EBS manager id BUUUM. We should somehow fix Rails to set correct ID here...

@martinpovolny
Copy link
Member Author

martinpovolny commented Nov 19, 2018

Let's make a list of all the stuff that is expected to work with cloudVolumeFormController controller:

  • app/views/cloud_volume/backup_select.html.haml
  • app/views/cloud_volume/new.html.haml
  • app/views/cloud_volume/edit.html.haml
  • app/views/cloud_volume/snapshot_new.html.haml
  • app/views/cloud_volume/backup_new.html.haml
  • app/views/cloud_volume/detach.html.haml
  • app/views/cloud_volume/attach.html.haml

Creating a volume should work

  • from the screen that lists all the volumes (with the StorageManager drop-down working)
  • from a nested list screen under a particular StorageManager (with the StorageManager drop-down disabled).
  • from a nested list under a particular Cloud Provider (with the StorageManager drop-down disabled).

Providers:

  • It should work for Amazon EBS (with a hardcoded list of volume types).
  • It should work for OpenShift Cider (with a list of volume types coming from the parent manager of the StorageManager)

@martinpovolny
Copy link
Member Author

Ahh, I know what it is. There is also variant c) to access the page - not through EBS manager, but through EC2 provider itself.

Oh how I love code that does a million things from a dozen contexts that is greatly documented and test-covered :-D

@miha-plesko
Copy link
Contributor

I know the feeling @martinpovolny , was working on this controller in Gaprindashvilli blocker-only phase... @himdel said the same thing, "we need to split into 7 controllers". But are we really going to, assuming we're in Hammer blocker phase this time? 😂

@miha-plesko
Copy link
Contributor

@martinpovolny it should fix the problem if we replace this line with

@storage_manager = begin
  if (manager = find_record_with_rbac(ExtManagementSystem, params[:storage_manager_id]))
    # Handle situation when CloudProvider ID is given instead StorageManager
    manager unless manager.respond_to?(:storage_managers)
    manager.storage_managers.detect { |m| m.supports_block_storage? }
  end
end

@martinpovolny
Copy link
Member Author

I have added one more commit that does not fix things, but removes a creating of an empty CloudVolume instance. Should that cause a problem, please try testing w/o the last commit.

Thx!

return nil unless manager
return manager.id unless manager.respond_to?(:storage_managers)
manager.storage_managers.detect { |m| m.supports_block_storage? }&.id
end
Copy link
Contributor

Choose a reason for hiding this comment

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

I like this. Maybe rename function into

def block_storage_manager_id
because at some point we'll probably need
def object_storage_manager_id
as well. Or even better, make it accept additional parameter to support both storage manager types:

def storage_manager_id(provider_id, criteria: :supports_block_storage?)
  ...
  manager.storage_managers.detect { |m| m.send(criteria) }&.id
end

I'll test your latest changes tomorrow when I come to the office.

Copy link
Contributor

@miha-plesko miha-plesko left a comment

Choose a reason for hiding this comment

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

@martinpovolny the last commit causes haml crash in _common_new_edit.haml if I go to:
Storage > BlockStorage > Volumes > "Add a new Cloud Volume"
We need to modify the HAML as well, please see the comment.

@@ -185,7 +185,6 @@ def new
assert_privileges("cloud_volume_new")
assert_privileges("cloud_tenant_show_list")

@volume = CloudVolume.new
Copy link
Contributor

Choose a reason for hiding this comment

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

Please also modify haml:

"disabled" => !@storage_manager.nil? || !@volume.id.nil?,

Here ^ it crashes with undefined method 'id' for nil:NilClass. We should probably test if @volume itself is nil, not try to access its id.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right. I fixed it and added a simple spec.

Copy link
Contributor

@miha-plesko miha-plesko left a comment

Choose a reason for hiding this comment

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

LGTM. Tested and it works - NEW volume form gets properly populated no matter where I access it from 👍. I'd still rename the function into def block_storage_manager_id() (see comment from before), but as you wish.

BTW while testing I realized EDIT requires "storage manager show" permission (besides "volume edit") but that's not a problem to solve here. Not sure if it's really a bug even, because you shouldn't edit volume without accessing the manager options anyway, but I got the red bubble on UI so... :)

@martinpovolny
Copy link
Member Author

@miha-plesko : Renaming the method as you suggested. However not adding the parameters as you also suggested. It's a good suggestion, but one that is not (yet) relevant. And a good practice is not to do things that are not needed. Not add parameters that are not needed.
I am also looking at adding some more tests.

Thank you for your cooperation and testing!

@martinpovolny
Copy link
Member Author

@AlexanderZagaynov : good to merge?

@AlexanderZagaynov
Copy link

@martinpovolny yes, looks good, let's do that :)

@miq-bot
Copy link
Member

miq-bot commented Nov 22, 2018

Checked commits martinpovolny/manageiq-ui-classic@b5d15d8~...b8731b6 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
8 files checked, 1 offense detected

**

  • 💣 💥 🔥 🚒 - Linter/Haml - Linter::Haml STDERR:
warning: parser/current is loading parser/ruby23, which recognizes
warning: 2.3.6-compliant syntax, but you are running 2.3.3.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.

@martinpovolny
Copy link
Member Author

ping @mzazrivec, @himdel, @h-kataria ?

@himdel
Copy link
Contributor

himdel commented Nov 26, 2018

LGTM, code looks good and both BZs seem fixed 👍

@himdel himdel merged commit c7af6b6 into ManageIQ:master Nov 26, 2018
@himdel himdel self-assigned this Nov 26, 2018
@himdel himdel added this to the Sprint 100 Ending Dec 3, 2018 milestone Nov 26, 2018
simaishi pushed a commit that referenced this pull request Nov 26, 2018
@simaishi
Copy link
Contributor

Hammer backport details:

$ git log -1
commit ceb56d29494ad33e96b4b2d17b952dfc855e01eb
Author: Martin Hradil <himdel@seznam.cz>
Date:   Mon Nov 26 13:59:40 2018 +0100

    Merge pull request #4908 from martinpovolny/cloud_volume_buttons
    
    Cloud Volume creation fixes
    
    (cherry picked from commit c7af6b63e77ba40a36cf5661f35c44c5767dfc55)
    
    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1644310

@simaishi
Copy link
Contributor

@martinpovolny @himdel can this be gaprindashvili/yes?

@himdel
Copy link
Contributor

himdel commented Dec 14, 2018

I think so, yes. #4549 is in gaprindashvili

@himdel
Copy link
Contributor

himdel commented Dec 14, 2018

.. But, looks like it would depend on backporting #4536 first (which fails to backport without #4345, but that one also has conflicts because it fixes some files which werent in gaprindashvili).

EDIT: and also #4605, which depends on #3927

@himdel
Copy link
Contributor

himdel commented Dec 14, 2018

This seeems to take all the relevant changes

git cherry-pick -x -m1 70b2475 # #3927
git cherry-pick -x -m1 760c7d6 # #4605

git cherry-pick -x -m1 46260de # #4345
rm app/assets/javascripts/controllers/ems_physical_infra_dashboard/server_health_pie_chart_controller.js app/assets/javascripts/components/cloud_subnet/cloud-subnet-form.js
git add app/assets/javascripts/controllers/ems_physical_infra_dashboard/server_health_pie_chart_controller.js app/assets/javascripts/components/cloud_subnet/cloud-subnet-form.js
git cherry-pick --continue

git cherry-pick -x -m1 7c4afa8 # #4536

git cherry-pick -x -m1 c7af6b6 # #4908
sed -i -e 202d -e 169,192d app/controllers/ems_common.rb
git add app/controllers/ems_common.rb
git cherry-pick --continue

not sure how to proceed :)

@simaishi
Copy link
Contributor

@himdel Oh my...... thanks for finding out all those dependencies and extra steps!!! Let me check with mgmt team with this info, this might be more than what we'd like in G branch. Thanks again 😄

@martinpovolny
Copy link
Member Author

Thank you for taking care of this, @himdel !

@simaishi : might be better to create a separate PR for Gaprindashvili (and test it!) following the steps @himdel provided rather than just trying to backport this.

@simaishi
Copy link
Contributor

@martinpovolny Please hold off working on PRs for Gaprindashvili. We might not take this into G release.

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.

6 participants