-
Notifications
You must be signed in to change notification settings - Fork 897
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
Update model to support network adapters #15371
Conversation
@miq-bot add_label wip |
@miq-bot assign @blomquisg |
@miq-bot remove_label wip |
@blomquisg Can you get someone to look at this PR? Thanks |
@skovic it looks like there needs to be an associated set of changes to the DB Schema. Can you look into that and add the link to the associated PR when that's available. Talk to @juliancheal about how to get started there if you have questions. |
@blomquisg @juliancheal The schema changes have already been reviewed and merged. Please see manageiq-schema PR 16 |
c5d64bf
to
56d56eb
Compare
98801cb
to
f5b90b3
Compare
Provider change have also been submitted for review in ManageIQ/manageiq-providers-lenovo#59 @juliancheal can you review? |
@blomquisg Could you get someone to take a look at this PR? The schema changes are already in. Thanks |
@@ -10,4 +11,7 @@ class GuestDevice < ApplicationRecord | |||
|
|||
has_one :network, :foreign_key => "device_id", :dependent => :destroy, :inverse_of => :guest_device | |||
has_many :miq_scsi_targets, :dependent => :destroy | |||
|
|||
has_many :firmwares, :dependent => :destroy | |||
has_many :child_devices, -> { where(:parent_device_id => ids) }, :foreign_key => "parent_device_id", :class_name => "GuestDevice", :dependent => :destroy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if you could do something more bi-directional here, like the Rails docs show.
has_many :child_devices, class_name => "GuestDevice",
foreign_key => :parent_device_id,
dependent => :destroy
belongs_to :parent_device, class_name => "GuestDevice"
This way, you could have a guest device, and list it's child devices, and also ask for it's parent device:
guest_device = GuestDevice.first
children = guest_device.child_devices
parent = guest_device.parent_device
I think the rest will fall into place with Rails magic.
/cc @Fryguy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@blomquisg I made the changes you suggested, and they seemed to work at first, but after I restarted the evm, one of the ports associated with the guest device was replaced by a duplicate of the other port in the table. For example, suppose we have guest device 1 that has port 1 and port 2. At first, the guest device and its associated ports are populated in the DB correctly. After a evm restart is performed, port 1 disappears from the table and there are now two duplicate port 2 entries with the same address and parent device. Any ideas why this is occurring? Does it have something to do with the save_inventory code? Including @juliancheal @Fryguy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds like a bug in the refresh, honestly.
Can you update the PR with the changes you have in place, and maybe it will shed some light on what's going on.
Also, with the inventory refresher code... are you running what's on master? Or, do you have local changes to the inventory collection? It would help to see that, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@blomquisg @juliancheal I updated the PR with the suggested changes. The associated changes in the provider were merged, so they're in master which is what I'm testing with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@skovic I'm having a look this afternoon, to see if I can find the root of the refresh issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@juliancheal Have you had a chance to look into this issue yet? Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@blomquisg Could we just revert to my original changes (undo the change you recommended) and get this PR merged? Our provider changes for the network adapter support have already been merged but these changes have not. This partial implementation is causing the provider to not refresh properly. In addition, this PR is delaying the UI changes for network adapter support from being merged -- the PR is ready to go. We could always make another PR with your suggested changes and have it sit out there while someone investigates the database issues that occurring with the change. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@blomquisg I have reverted the guest device model in this PR to use my original changes (which do not have the database refresh problem), and I have moved the implementation of this suggestion to PR #15732. Please consider merging this PR (#15371), so we are unblocked. Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
K... Thanks for the update @skovic ... I'll remove my "request for changes" review and take another look.
We can try to figure out what's going on with this in a separate PR/thread.
@@ -6213,6 +6213,26 @@ | |||
:feature_type: view | |||
:identifier: firmware_show | |||
|
|||
# Guest Devices |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dclarizio @Fryguy Do we want a Guest Devices
section in the product_features
? I'm not sure of all the impact that has.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@blomquisg if these are a new menu item in the navigation, we normally do add them into product_features so a role can be customized to show or not show them. If they are similar to the Firmwares
item above, then I'd say yes. If not, then I'm not sure as I am not familiar with this addition.
@imtayadeway Can you check on the API changes in this PR? Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, agree with @blomquisg's comment.
f5b90b3
to
3d7b976
Compare
3d7b976
to
10c1f46
Compare
The changes I recommended caused a problem in the refresher ... going to look at that separately and move this PR along.
app/models/hardware.rb
Outdated
@@ -19,7 +19,7 @@ class Hardware < ApplicationRecord | |||
has_many :guest_devices, :dependent => :destroy | |||
has_many :storage_adapters, -> { where "device_type = 'storage'" }, :class_name => "GuestDevice", :foreign_key => :hardware_id | |||
has_many :nics, -> { where "device_type = 'ethernet'" }, :class_name => "GuestDevice", :foreign_key => :hardware_id | |||
has_many :ports, -> { where "device_type != 'storage'" }, :class_name => "GuestDevice", :foreign_key => :hardware_id | |||
has_many :ports, -> { where "device_type = 'ethernet port'" }, :class_name => "GuestDevice", :foreign_key => :hardware_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm worried about this, but without any evidence...
The new implementation is much more "correct". I'm just worried that there were some old assumptions built into that previous relationship mapping based on != 'storage'
that will come back to bite us.
Honestly, the only thing I can think of doing is letting it through and crossing our fingers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, I think I spoke to soon.
I can't find a device_type
of "ethernet port"
. This means that whatever used to be classified as a port
will no longer be.
And, if this is changed to just ethernet
, then it simply overlaps with nics
.
I need to look over the different ways we're collecting the device_type
information to figure out whatdevice_type
ports
should really map to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@blomquisg Are supported device_types defined somewhere? The schema for guest_devices declares the device_type as a string, so it looks like anything will work -- maybe this should be an enumeration instead of a string? The Lenovo provider adds physical ports as a guest_device with a device_type of "ethernet port". Please see ManageIQ/manageiq-providers-lenovo#59
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@blomquisg have you found the problem?
10c1f46
to
80a2245
Compare
I moved the guest_devices REST API changes to ManageIQ/manageiq-api#7 |
Is there anything missing to have this PR merged? I can't see if that is the case from the comments, or whether this should be merged and an issue created (as the tests are green) |
@blomquisg @juliancheal can we merge this PR? |
I need to look back at the |
Here's what I'm seeing for
Based on this, it looks like the previous implementation would have included Also, the UI is using the
Here's how I think this should change. Leave the This allows us to treat the two concepts differently. If we combined them today into a single field, and then later decide to treat them differently, it's going to be much harder to split them apart later. If we decide to combine them later, that should be much easier. /cc @Fryguy @roliveri @juliancheal Thoughts? |
Hi @rodneyhbrown7, Can you comment on the changes @blomquisg is suggesting? There are others PR depending on this one, and it seems that we need to work a little more on this. Is there any approach that would help us to make it faster? |
@blomquisg I believe I have made the changes you requested. Please let me know if I missed anything. Also, as a result of these changes, I had to make an update to the provider in ManageIQ/manageiq-providers-lenovo#73 |
Checked commits skovic/manageiq@e34051c~...faed145 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 app/models/ems_refresh/save_inventory.rb
app/models/hardware.rb
|
The child_devices added unneeded scope. This scope pulled back all ids from the guest devices table. Since the foreign_key is added to the query, this did not do any harm. But it adds an unneeded constraint an unneeded query. This was introduce in ManageIQ#15371 The way the PR was batted around, it looked like this was not an intentional side effect. Before ====== ```ruby has_many :child_devices, -> { where(:parent_device_id => ids) }, :foreign_key => "parent_device_id" has_many :child_devices, -> { where(:parent_device_id => GuestDevice.ids) }, :foreign_key => "parent_device_id" SELECT "guest_devices".* FROM "guest_devices" WHERE "guest_devices"."parent_device_id" = 26000000000035 AND "guest_devices"."parent_device_id" IN (26000000000032, 26000000000033, 26000000000034, 26000000000035, 26000000000036, 26000000000037, 26000000000038) ``` After ===== ```ruby has_many :child_devices, :foreign_key => "parent_device_id" SELECT "guest_devices".* FROM "guest_devices" WHERE "guest_devices"."parent_device_id" = 26000000000035 ```
The child_devices added unneeded scope. This scope pulled back all ids from the guest devices table. Since the foreign_key is added to the query, this did not do any harm. But it adds an unneeded constraint an unneeded query. This was introduce in ManageIQ#15371 The way the PR was batted around, it looked like this was not an intentional side effect. Before ====== ```ruby has_many :child_devices, -> { where(:parent_device_id => ids) }, :foreign_key => "parent_device_id" has_many :child_devices, -> { where(:parent_device_id => GuestDevice.ids) }, :foreign_key => "parent_device_id" SELECT "guest_devices".* FROM "guest_devices" WHERE "guest_devices"."parent_device_id" = 26000000000035 AND "guest_devices"."parent_device_id" IN (26000000000032, 26000000000033, 26000000000034, 26000000000035, 26000000000036, 26000000000037, 26000000000038) ``` After ===== ```ruby has_many :child_devices, :foreign_key => "parent_device_id" SELECT "guest_devices".* FROM "guest_devices" WHERE "guest_devices"."parent_device_id" = 26000000000035 ```
The child_devices added unneeded scope. This scope pulled back all ids from the guest devices table. Since the foreign_key is added to the query, this did not do any harm. But it adds an unneeded constraint an unneeded query. This was introduce in ManageIQ#15371 The way the PR was batted around, it looked like this was not an intentional side effect. Before ====== ```ruby has_many :child_devices, -> { where(:parent_device_id => ids) }, :foreign_key => "parent_device_id" has_many :child_devices, -> { where(:parent_device_id => GuestDevice.ids) }, :foreign_key => "parent_device_id" SELECT "guest_devices".* FROM "guest_devices" WHERE "guest_devices"."parent_device_id" = 26000000000035 AND "guest_devices"."parent_device_id" IN (26000000000032, 26000000000033, 26000000000034, 26000000000035, 26000000000036, 26000000000037, 26000000000038) ``` After ===== ```ruby has_many :child_devices, :foreign_key => "parent_device_id" SELECT "guest_devices".* FROM "guest_devices" WHERE "guest_devices"."parent_device_id" = 26000000000035 ```
The child_devices added unneeded scope. This scope pulled back all ids from the guest devices table. Since the foreign_key is added to the query, this did not do any harm. But it adds an unneeded constraint an unneeded query. This was introduce in ManageIQ#15371 The way the PR was batted around, it looked like this was not an intentional side effect. Before ====== ```ruby has_many :child_devices, -> { where(:parent_device_id => ids) }, :foreign_key => "parent_device_id" has_many :child_devices, -> { where(:parent_device_id => GuestDevice.ids) }, :foreign_key => "parent_device_id" SELECT "guest_devices".* FROM "guest_devices" WHERE "guest_devices"."parent_device_id" = 26000000000035 AND "guest_devices"."parent_device_id" IN (26000000000032, 26000000000033, 26000000000034, 26000000000035, 26000000000036, 26000000000037, 26000000000038) ``` After ===== ```ruby has_many :child_devices, :foreign_key => "parent_device_id" SELECT "guest_devices".* FROM "guest_devices" WHERE "guest_devices"."parent_device_id" = 26000000000035 ```
This PR updates the model to support network adapters which will be added as entries to the guest_devices table.