Description of problem: EC2 key pairs that don't have filled public key during creation cannot be removed from inventory. Version-Release number of selected component (if applicable): 5.10.5.1 How reproducible: Always Steps to Reproduce: 1. Add ec2 provider 2. Create key pair without filling in public key 3. Remove key pair from inventory Actual results: ERROR -- : MIQ(auth_key_pair_cloud_controller-button): Couldn't initiate deletion of Key Pair "fE8hdixDkC": Expected results: Additional info:
Matouš, can you please attach logs / post more log lines? Maybe there is more details present? "Create key pair" - how do you create them? In MiQ or in AWS? "Remove key pair" - same, can you please provide some steps?
Alex, added evm.log/production.log starting from creating key_pair to deleting keypair. I create key pair in CFME and only fill in the name. Public key is not filled. When I create keypair in AWS deleting always works. For removing keypairs I go to Compute -> Cloud -> Keypairs -> Select a key pair -> In configuration bar there is remove item from inventory. I think it has something to do with CFME creating/saving public key for future download, because not filling public key is the only way to reproduce it.
Matous, there is no any error in this log :( Where did you take the "Couldn't initiate deletion" line from?
Alex, second last line in evm.log there is that error.
Thank you, I was looking in production.log :)
So in testing, I created a Key Pair with just a title. Tried to delete via CFME UI and got the same error. Using the console wrote the code line by line from `raw_delete_key_pair` https://github.com/ManageIQ/manageiq-providers-amazon/blob/master/app/models/manageiq/providers/amazon/cloud_manager/auth_key_pair.rb#L28 Finding the key pair with `kp = ec2.key_pair("Julian_kp_test")` then deleting the key pair with `kp.delete`. This was successful. So the error is somewhere before this code. I'm thinking in the UI.
So the problem isn't the UI, it's coming from https://github.com/ManageIQ/manageiq-ui-classic/blob/6b6e0047ad9f7333c4219a5042a28adc50cc6a5c/app/controllers/auth_key_pair_cloud_controller.rb#L169 `if key_pair.is_available?(:delete_key_pair)` in the UI If a key pair has a key, that returns true, without a key returns false.
Solved it. If a key pair is created without a key, we get AWS to generate us a key (I believe) https://github.com/ManageIQ/manageiq-providers-amazon/blob/master/app/models/manageiq/providers/amazon/cloud_manager/auth_key_pair.rb#L4-L10 And any keys imported from AWS cannot be deleted in CFME. So I'm not sure what the next step is.
PR fixes this issue https://github.com/ManageIQ/manageiq-providers-amazon/pull/547
Verified in 5.11.0.16. Key pairs created in AWS, created in CFME without public key set and created in CFME with public key set can be all deleted.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHBA-2019:4199