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 Key Pairs from refresh being returned with provider AuthPrivateKeys #18633

Merged

Conversation

agrare
Copy link
Member

@agrare agrare commented Apr 5, 2019

AuthPrivateKeys are used to connect to providers, ManageIQ::Provider::CloudManager::AuthKeyPairs were being returned with these because they inherited from that class without actually using anything from it.

Update the CloudManager::AuthKeyPairs to inherit from the base Authentications class

To prevent cloud_manager auth_key_pairs from being returned with other
AuthPrivateKeys change the parent class to Authentication
@djberg96
Copy link
Contributor

djberg96 commented Apr 5, 2019

👍

@Fryguy
Copy link
Member

Fryguy commented Apr 9, 2019

If we are sure we are not using anything from the base class, then this is a good change, conceptually...though I have one issue with the implementation.

@Fryguy
Copy link
Member

Fryguy commented Apr 9, 2019

Oh, additionally, you are going to need a data migration for upgrading users.

@Fryguy
Copy link
Member

Fryguy commented Apr 9, 2019

@agrare Can you also verify the UI side of this (I think it's in the Cloud EMS summary page)? I know that keypairs are shown in the UI, and I think they do some dance to only show the "right" ones.

@agrare
Copy link
Member Author

agrare commented Apr 9, 2019

Oh, additionally, you are going to need a data migration for upgrading users.

If we're updating the parent class? What would we change, not the :type column...

@miq-bot
Copy link
Member

miq-bot commented Apr 9, 2019

Checked commits agrare/manageiq@321d9d3~...e79e13a with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
4 files checked, 1 offense detected

app/models/manageiq/providers/cloud_manager.rb

@@ -4,7 +4,7 @@ def dest_availability_zone
end

def guest_access_key_pair
@guest_access_key_pair ||= AuthPrivateKey.find_by(:id => get_option(:guest_access_key_pair))
@guest_access_key_pair ||= ManageIQ::Providers::CloudManager::AuthKeyPair.find_by(:id => get_option(:guest_access_key_pair))
Copy link
Member

@Fryguy Fryguy Apr 9, 2019

Choose a reason for hiding this comment

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

I'm good with this for now, but I don't understand why this doesn't do a find_by_id off of the EMS (in this entire file). @gmcculloug ? Doesn't this allow a provision run to get at a different EMS's records?

Copy link
Member

Choose a reason for hiding this comment

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

The pattern setup in the options_helper.rb file has always been to lookup the record by the ID on the model, but we it could definitely be scoped down where possible. Might be outside of the scope of this PR.

For this value, if the wrong instance is pulled we are only sending the name to the provider.
https://github.com/ManageIQ/manageiq/blob/master/app/models/manageiq/providers/cloud_manager/provision/cloning.rb#L21

@Fryguy
Copy link
Member

Fryguy commented Apr 9, 2019

I was thinking we would have to change the polymorphic relationships where the base class is stored in cols like resource_type. However, I see you only changed a "middle" class in the hierarchy not the leaf nor the base, so yeah, no DB migration needed.

@agrare
Copy link
Member Author

agrare commented Apr 9, 2019

👍 yeah now I see what you meant

@agrare
Copy link
Member Author

agrare commented Apr 9, 2019

Can you also verify the UI side of this (I think it's in the Cloud EMS summary page)? I know that keypairs are shown in the UI, and I think they do some dance to only show the "right" ones.

@Fryguy I didn't see keypairs on the summary page anymore (checked on master as well) but there is a key pairs page under cloud_manager and that still works great

@agrare
Copy link
Member Author

agrare commented Apr 9, 2019

Confirmed that this fixes the issue with the GCE provider

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.

5 participants