Bug 1389459 - can't add cloud provider with the same name again
Summary: can't add cloud provider with the same name again
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: Providers
Version: 5.6.0
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: GA
: 5.8.0
Assignee: James Wong
QA Contact: Tasos Papaioannou
URL:
Whiteboard: provider:cloud, appliance:database
Depends On:
Blocks: 1411517
TreeView+ depends on / blocked
 
Reported: 2016-10-27 15:38 UTC by Ievgen Zapolskyi
Modified: 2017-06-12 17:08 UTC (History)
11 users (show)

Fixed In Version: 5.8.0.0
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1411517 (view as bug list)
Environment:
Last Closed: 2017-06-12 17:08:33 UTC
Category: ---
Cloudforms Team: CFME Core
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
error message screenshot (20.61 KB, image/png)
2016-10-27 15:38 UTC, Ievgen Zapolskyi
no flags Details
one more error (16.31 KB, image/png)
2016-10-27 15:39 UTC, Ievgen Zapolskyi
no flags Details

Description Ievgen Zapolskyi 2016-10-27 15:38:47 UTC
Created attachment 1214661 [details]
error message screenshot

Description of problem:
When I try to add cloud provider/rename existing one with the name that was used earlier, I get an error "Name has already been taken"/"Network_manager.name".
So, the name cannot be re-used.


Version-Release number of selected component (if applicable):
CFME 5.6.2.2

How reproducible:
100 % but sometimes the steps need to be repeat once more

Steps to Reproduce:
1. Add cloud provider (f.e. Azure/EC2) with some name to CFME
2. Remove the provider
3. Logout from appliance
4. Login to appliance
5. Try to add such provider with same name again (reproduced with renaming)

Actual results:
The error "Name has already been taken"/"Network_manager.name" appears.
So, the name cannot be re-used.

Expected results:
There shouldn't be such a restriction

Additional info:

Comment 2 Ievgen Zapolskyi 2016-10-27 15:39:17 UTC
Created attachment 1214663 [details]
one more error

Comment 5 Ievgen Zapolskyi 2016-11-07 10:41:35 UTC
Actually, I noticed destroy messages and providers were removed from the db but
Network Managers remained. Apparently, that's a reason why next attempts failed.

select id, name from ext_management_systems;

"id","name"
"5","azure Network Manager"
"8","ec2-west Network Manager"


select id, class_name, method_name, queue_name from miq_queue;
"id","class_name","method_name","queue_name"
"25","MiqServer","shutdown_and_exit","miq_server"
"591","EmsRefresh","refresh","ems_8"
"475","EmsRefresh","refresh","ems_5"
"197","MiqServer","shutdown_and_exit","miq_server"

I'd also say that I noticed a moment when EC2 Network Manager disappeared from the table and appeared later again. It seems destroy operation isn't done in one transaction.

Comment 6 Ievgen Zapolskyi 2016-11-07 10:42:43 UTC
I'm leaving this appliance up for a while - 10.16.5.142.
So, you can use it for reproducing the issue if you want.

Comment 13 Adam Grare 2016-11-17 20:07:42 UTC
Looks like the same thing has been hit by https://bugzilla.redhat.com/show_bug.cgi?id=1393675 and https://bugzilla.redhat.com/show_bug.cgi?id=1394432

So maybe not so much of an edge case?

Comment 15 James Wong 2016-11-28 15:05:10 UTC
For record purpose, this is how I managed to reproduce this problem manually,


1. In rails console, EmsRefresh.refresh(ems-cloud-instance) and put a debug to hold it right before inventory saving

2. In another rails console, run ems-cloud-instance.destroy. You can confirm that both manager ems are gone from db

3. Back to first console and let it continue to run. It will failed with something like not able to find the cloud ems instance, but a new record of network manager is created in db.

Comment 16 CFME Bot 2016-12-01 16:43:41 UTC
New commit detected on ManageIQ/manageiq-providers-amazon/master:
https://github.com/ManageIQ/manageiq-providers-amazon/commit/13cbb68b282c26449752c6127cba9e9c111a592b

commit 13cbb68b282c26449752c6127cba9e9c111a592b
Author:     Marcel Hild <hild>
AuthorDate: Mon Nov 28 15:13:11 2016 +0100
Commit:     Marcel Hild <hild>
CommitDate: Mon Nov 28 15:13:11 2016 +0100

    Add managers in before_create callback instead of before_validation
    
    otherwise it could happen that one process deletes the manager
    and another one saves it and the saving one would add back
    a deleted manager.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1389459
    https://bugzilla.redhat.com/show_bug.cgi?id=1393675

 app/models/manageiq/providers/amazon/cloud_manager.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comment 17 CFME Bot 2016-12-01 16:46:48 UTC
New commit detected on ManageIQ/manageiq/master:
https://github.com/ManageIQ/manageiq/commit/fab74b285e2d93f85456d9a0985081b5eb7b9aff

commit fab74b285e2d93f85456d9a0985081b5eb7b9aff
Author:     Marcel Hild <hild>
AuthorDate: Mon Nov 28 15:02:56 2016 +0100
Commit:     Marcel Hild <hild>
CommitDate: Mon Nov 28 15:02:56 2016 +0100

    Add managers in before_create callback instead of before_validation
    
    otherwise it could happen that one process deletes the manager
    and another one saves it and the saving one would add back
    a deleted manager.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1389459
    https://bugzilla.redhat.com/show_bug.cgi?id=1393675

 app/models/manageiq/providers/foreman/provider.rb        | 2 +-
 app/models/manageiq/providers/google/cloud_manager.rb    | 2 +-
 app/models/manageiq/providers/openstack/cloud_manager.rb | 2 +-
 app/models/manageiq/providers/openstack/infra_manager.rb | 2 +-
 app/models/manageiq/providers/vmware/cloud_manager.rb    | 2 +-
 spec/controllers/provider_foreman_controller_spec.rb     | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

Comment 18 CFME Bot 2016-12-06 17:25:26 UTC
New commit detected on ManageIQ/manageiq-providers-azure/master:
https://github.com/ManageIQ/manageiq-providers-azure/commit/a2acb585c09633f903c194aae227fdf50e591a13

commit a2acb585c09633f903c194aae227fdf50e591a13
Author:     Marcel Hild <hild>
AuthorDate: Mon Nov 28 15:10:55 2016 +0100
Commit:     Marcel Hild <hild>
CommitDate: Mon Nov 28 15:10:55 2016 +0100

    Add managers in before_create callback instead of before_validation
    
    otherwise it could happen that one process deletes the manager
    and another one saves it and the saving one would add back
    a deleted manager.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1389459
    https://bugzilla.redhat.com/show_bug.cgi?id=1393675

 app/models/manageiq/providers/azure/cloud_manager.rb    |  2 +-
 .../manageiq/providers/azure/cloud_manager_spec.rb      | 17 +++++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

Comment 20 Marcel Hild 2016-12-08 21:05:26 UTC
https://github.com/ManageIQ/manageiq/pull/12381 has nothing to do with this BZ - not sure how it ended up here.

its https://github.com/ManageIQ/manageiq/pull/12878 that fixes this

Comment 22 Tasos Papaioannou 2017-05-11 19:43:19 UTC
Verified on 5.8.0.14-rc3.


Note You need to log in before you can comment on or make changes to this bug.