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 PhysicalDisks into Canisters #18053

Merged
merged 2 commits into from
Nov 7, 2018

Conversation

EsdrasVP
Copy link
Member

@EsdrasVP EsdrasVP commented Oct 3, 2018

This PR is able to:

  • Add PhysicalDisks into Canister model
  • Modify save_inventory_infra for PhysicalDisks
  • Remove physical_storage deletion from physical disks inventory saving (bug fix)

Depends on:

Copy link
Member

@agrare agrare left a comment

Choose a reason for hiding this comment

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

Copy link
Member

@agrare agrare left a comment

Choose a reason for hiding this comment

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

@EsdrasVP EsdrasVP force-pushed the add_physical_disks_to_canisters branch 2 times, most recently from 6f013cc to 6e0f220 Compare October 4, 2018 18:10
@EsdrasVP EsdrasVP changed the title [WIP] Add PhysicalDisks into Canisters Add PhysicalDisks into Canisters Oct 5, 2018
@miq-bot miq-bot removed the wip label Oct 5, 2018
@EsdrasVP EsdrasVP force-pushed the add_physical_disks_to_canisters branch from 6e0f220 to a573ecf Compare October 9, 2018 12:59
@EsdrasVP EsdrasVP changed the title Add PhysicalDisks into Canisters [WIP] Add PhysicalDisks into Canisters Oct 10, 2018
@EsdrasVP EsdrasVP changed the title [WIP] Add PhysicalDisks into Canisters Add PhysicalDisks into Canisters Oct 10, 2018
@agrare agrare closed this Oct 24, 2018
@agrare agrare reopened this Oct 24, 2018
return if hashes.nil?

# Update the associated ids
hashes.each do |h|
h[:physical_storage_id] = h.delete(:physical_storage).try(:[], :id)
Copy link
Member

Choose a reason for hiding this comment

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

Is the intention to be able to save physical disks from both physical_storages and canisters? I think this is a good idea and it looks like you're going that direction by changing save_physical_disks_inventory(physical_storage, hashes) to save_physical_disks_inventory(parent, hashes) but then you need to keep this foreign_key lookup not replace it with the canisters one.

Copy link
Member

Choose a reason for hiding this comment

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

You also need to add :physical_disks to the child_keys in save_canisters_inventory

Copy link
Member Author

Choose a reason for hiding this comment

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

Is the intention to be able to save physical disks from both physical_storages and canisters? I think this is a good idea and it looks like you're going that direction by changing save_physical_disks_inventory(physical_storage, hashes) to save_physical_disks_inventory(parent, hashes) but then you need to keep this foreign_key lookup not replace it with the canisters one.

@agrare I only left a canister foreign_key because, even though we are letting it abstract enough for physical_disks to have any parent, currently they'll always be inside of a physical_storage, what will change is that sometimes it is inside a canister that is inside a physical_storage. It's a little bit confusing at first glance, but this allow us to show all disks inside a storage even if it is inside it through another component like a canister.

Copy link
Member

Choose a reason for hiding this comment

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

currently they'll always be inside of a physical_storage

That's true of the lenovo provider, but might not be true of all physical infra providers right? Not all physical storages have canisters, in fact I think the vast majority do not no?

Copy link
Member Author

Choose a reason for hiding this comment

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

That's true of the lenovo provider, but might not be true of all physical infra providers right? Not all physical storages have canisters, in fact I think the vast majority do not no?

Yeah, that's what bothers me. Is there another way for us to access a physical_disk that is inside a canister from a storage? Because the way foreign_key is used on the other components doesn't allow us to access physical_disks as an attribute for both storage and canister at the same time.

Copy link
Member

Choose a reason for hiding this comment

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

I think that's okay, from a refresh POV we don't need to be able to access both because a disk can only belong to one or the other.

Copy link
Member

@felipedf felipedf Oct 31, 2018

Choose a reason for hiding this comment

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

but then you need to keep this foreign_key lookup not replace it with the canisters one.

A physical_disk should always belong to a physical_storage and saved through association, so I guess we can keep only the lookup for a canister here, so when the canister is present save this disk for both storage and canister.

You also need to add :physical_disks to the child_keys in save_canisters_inventory

We don't plan to save a physical_disk to a canister through association as explained above

Not all physical storages have canisters, in fact I think the vast majority do not no?

Correct, but then we only save a canister to physical_storage when it really exists, and the physical_disk will always be saved to the physical_storage regardless.

Copy link
Member

Choose a reason for hiding this comment

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

@felipedf I'm confused if a physical disk should belong to a physical_storage instead of a canister then why are we doing this?
We could revert this and just add a simple canister id lookup to the old method.

Copy link
Member

Choose a reason for hiding this comment

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

The physical_disk will be saved to the storage through the association and saved to the canister with a simple id lookup as you said. I reverted to the old method to use physical_storage instead parent

Copy link
Member

Choose a reason for hiding this comment

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

Okay let me know when you have the specs in the lenovo PR ready and passing with this applied locally

@EsdrasVP EsdrasVP force-pushed the add_physical_disks_to_canisters branch 2 times, most recently from ff331ed to 2da8fa1 Compare October 26, 2018 19:36
@felipedf felipedf force-pushed the add_physical_disks_to_canisters branch from 2da8fa1 to 5ab40e4 Compare October 31, 2018 20:19
@felipedf felipedf force-pushed the add_physical_disks_to_canisters branch from 9ec48c8 to 1b364dc Compare November 6, 2018 12:23
@miq-bot
Copy link
Member

miq-bot commented Nov 6, 2018

Checked commits EsdrasVP/manageiq@5ab40e4~...1b364dc with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
3 files checked, 0 offenses detected
Everything looks fine. 👍

@@ -1,5 +1,6 @@
class PhysicalDisk < ApplicationRecord
belongs_to :physical_storage, :foreign_key => :physical_storage_id, :inverse_of => :physical_disks
belongs_to :canister, :foreign_key => :canister_id, :inverse_of => :physical_disks
Copy link
Member

Choose a reason for hiding this comment

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

You don't need the foreign_key if the key matches the belongs_to

@agrare
Copy link
Member

agrare commented Nov 7, 2018

@felipedf can you add the canisters and physical_disks inventory collections to the base physical_infra_manager persister definition and fix the foreign_key for canisters in a follow-up PR?

@agrare agrare merged commit 2c598d7 into ManageIQ:master Nov 7, 2018
@agrare agrare added this to the Sprint 99 Ending Nov 19, 2018 milestone Nov 7, 2018
@felipedf felipedf deleted the add_physical_disks_to_canisters branch November 9, 2018 13:43
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.

4 participants