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

[V2V] Add default credentials to ansible_playbook method #18724

Merged
merged 11 commits into from
May 7, 2019
Merged

[V2V] Add default credentials to ansible_playbook method #18724

merged 11 commits into from
May 7, 2019

Conversation

djberg96
Copy link
Contributor

@djberg96 djberg96 commented May 3, 2019

In the ansible_playbook method it's possible that an authentication isn't yet directly associated with the conversion host, e.g. a rhev host without a provided ssh key. This modifies the method so that it calls find_credentials as a fallback which will (ultimately) use the authentication of the associated resource.

Without this a undefined method 'userid' for nil:NilClass error could result.

This wasn't caught in the specs because it's a private method. I think our own testing didn't catch it because we were either using openstack or were explicitly providing an ssh key. I personally was just stubbing that method out without checking it. Oops!

This fix also has the added advantage of raising a proper error if it still can't be found for some reason.

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

Edit: also fixed an error message bug in the find_credentials method while we were here.

…h conversion host in ansible_playbook method.
@djberg96
Copy link
Contributor Author

djberg96 commented May 3, 2019

@miq-bot add_label bug, transformation, hammer/yes

@jerryk55
Copy link
Member

jerryk55 commented May 3, 2019

@djberg96 since you're adding a call to find_credentials() it might be appropriate to fix up a line of redundant code in there assigning to the "msg" variable. Line #255 before this change.

@djberg96
Copy link
Contributor Author

djberg96 commented May 3, 2019

@miq-bot add_reviewer @agrare

@miq-bot miq-bot requested a review from agrare May 3, 2019 19:09
@djberg96
Copy link
Contributor Author

djberg96 commented May 3, 2019

@jerryk55 oh, good catch, i spaced out on that one. Fixed that while we were here.

@jerryk55
Copy link
Member

jerryk55 commented May 3, 2019

@djberg96 thanks!

@djberg96
Copy link
Contributor Author

djberg96 commented May 6, 2019

@agrare @jerryk55 Since nothing was using the msg argument, I altered it to accept an auth_type instead, which defaults to "v2v", and updated the ansible_playbook method to use it.

Look ok?

@jerryk55
Copy link
Member

jerryk55 commented May 6, 2019

@djberg96 the only issue I see now is that the ansible_playbook method now has an unused auth_type argument. It can probably be removed. Also I just want to confirm that you no longer wish to have that auth_type = nil argument be the default.

@djberg96
Copy link
Contributor Author

djberg96 commented May 6, 2019

@jerryk55 Ok, I've updated it so that that auth_type is passed explicitly to find_credentials, which will try to use that first, and fall back to "v2v" as the first default.

@jerryk55
Copy link
Member

jerryk55 commented May 6, 2019

Ok @djberg96 cool. Looks good!

Fix find credentials for resources where the authentication is associated with the EMS.
@djberg96
Copy link
Contributor Author

djberg96 commented May 6, 2019

@jerryk55 @agrare I've added another fix that handles cases where it must go through the associated resource. For OSP, it should default to resource -> ems -> authentication instead of resource -> authentication.

Daniel Berger and others added 2 commits May 6, 2019 13:09
@agrare agrare self-assigned this May 7, 2019
@ghost
Copy link

ghost commented May 7, 2019 via email

@agrare
Copy link
Member

agrare commented May 7, 2019

Okay so we can drop the || authentications.first

@djberg96
Copy link
Contributor Author

djberg96 commented May 7, 2019

@agrare Updated the current logic. See if that's ok, or if you think those "or" checks should be dropped completely.

@miq-bot
Copy link
Member

miq-bot commented May 7, 2019

Checked commits https://github.com/djberg96/manageiq/compare/1840f6cbb873168eadcad3c367b637783a8e10da~...802a13b818a9e78ffcea9f696c91d1f316db6f84 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
1 file checked, 0 offenses detected
Everything looks fine. 👍

@ghost
Copy link

ghost commented May 7, 2019 via email

@agrare
Copy link
Member

agrare commented May 7, 2019

@fdupont-redhat okay now you've confused me, is v2v auth type the only one supported or not?

@ghost
Copy link

ghost commented May 7, 2019 via email

@agrare
Copy link
Member

agrare commented May 7, 2019

Okay but on the conversion host v2v was the only option, ssh_keypair and default we're only for the underlying resource

@ghost
Copy link

ghost commented May 7, 2019

You're right. It's a new converged authentication, that makes the graphical configuration easier, and the others, associated to the resource, will disappear in Ivanchuk.

@agrare agrare merged commit a68811e into ManageIQ:master May 7, 2019
@agrare agrare added this to the Sprint 111 Ending May 13, 2019 milestone May 7, 2019
simaishi pushed a commit that referenced this pull request May 8, 2019
…ook_default_credentials

[V2V] Add default credentials to ansible_playbook method

(cherry picked from commit a68811e)

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1694229
@simaishi
Copy link
Contributor

simaishi commented May 8, 2019

Hammer backport details:

$ git log -1
commit e9beef70e978a6ec75feb376c5cc691e81fb20b1
Author: Adam Grare <[email protected]>
Date:   Tue May 7 19:58:11 2019 -0400

    Merge pull request #18724 from djberg96/conversion_host_ansible_playbook_default_credentials
    
    [V2V] Add default credentials to ansible_playbook method
    
    (cherry picked from commit a68811eee56fc4a7bc632c4b74f8c64c0e5b6ef0)
    
    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1694229

simaishi added a commit that referenced this pull request May 8, 2019
@simaishi
Copy link
Contributor

simaishi commented May 8, 2019

Reverted the hammer backport:

commit 282f74ed07d2f851110d9b3d9a5428f1fa7a79ef
Author: Satoe Imaishi <[email protected]>
Date:   Wed May 8 12:46:48 2019 -0400

    Revert "Merge pull request #18724 from djberg96/conversion_host_ansible_playbook_default_credentials"
    
    This reverts commit e9beef70e978a6ec75feb376c5cc691e81fb20b1.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1694229

@djberg96
Copy link
Contributor Author

@miq-bot remove_label hammer/no

@djberg96
Copy link
Contributor Author

@miq-bot add_label hammer/yes

simaishi pushed a commit that referenced this pull request May 20, 2019
…ook_default_credentials

[V2V] Add default credentials to ansible_playbook method

(cherry picked from commit a68811e)

https://bugzilla.redhat.com/show_bug.cgi?id=1712135
@simaishi
Copy link
Contributor

Re-backported to hammer branch:

commit 2a0f93eb01710880b45b651317c28693584b378a
Author: Adam Grare <[email protected]>
Date:   Tue May 7 19:58:11 2019 -0400

    Merge pull request #18724 from djberg96/conversion_host_ansible_playbook_default_credentials
    
    [V2V] Add default credentials to ansible_playbook method
    
    (cherry picked from commit a68811eee56fc4a7bc632c4b74f8c64c0e5b6ef0)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1712135

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