-
Notifications
You must be signed in to change notification settings - Fork 898
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
Reload stale source_tenant after destroying self (rails 5.2) #19367
Reload stale source_tenant after destroying self (rails 5.2) #19367
Conversation
In rails 5.2, this stale source_tenant has a "source" CloudManager during this "after_destroy" callback. This causes the source_tenant.destroy to fail, thinking the "source" CloudManager still exists. Fixes: 5) ManageIQ::Providers::CloudManager OpenStack CloudTenant Mapping #sync_cloud_tenants_with_tenants creation of tenant tree cleans up created tenant tree when the ems is destroyed Failure/Error: expect(Tenant.count).to eq(1) expected: 1 got: 2 (compared using ==) # ./spec/models/manageiq/providers/cloud_manager_spec.rb:205:in `block (5 levels) in <top (required)>'
Checked commit jrafanie@c07a434 with ruby 2.4.6, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -159,6 +159,8 @@ def self.display_name(number = 1) | |||
|
|||
def destroy_mapped_tenants | |||
if source_tenant | |||
# We just destroyed ourself, reload the source_tenant association | |||
source_tenant.reload | |||
source_tenant.all_subtenants.destroy_all | |||
source_tenant.all_subprojects.destroy_all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
darn - feels like this should all be destroyed in tenant itself
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, agreed
In rails 5.2, this stale source_tenant has a "source" CloudManager
during this "after_destroy" callback. This causes the
source_tenant.destroy to fail, thinking the "source" CloudManager still
exists.
Fixes: