diff --git a/app/models/manageiq/providers/cloud_manager.rb b/app/models/manageiq/providers/cloud_manager.rb index 4d28e3f80f3..e54094db6ee 100644 --- a/app/models/manageiq/providers/cloud_manager.rb +++ b/app/models/manageiq/providers/cloud_manager.rb @@ -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 source_tenant.destroy diff --git a/app/models/tenant.rb b/app/models/tenant.rb index d0f78cfb486..4c6ba44a06f 100644 --- a/app/models/tenant.rb +++ b/app/models/tenant.rb @@ -355,7 +355,7 @@ def create_tenant_group def ensure_can_be_destroyed errors.add(:base, _("A tenant with groups associated cannot be deleted.")) if miq_groups.non_tenant_groups.exists? - errors.add(:base, _("A tenant created by tenant mapping cannot be deleted.")) if source + errors.add(:base, _("A tenant created by tenant mapping cannot be deleted.")) if source&.persisted? throw :abort unless errors[:base].empty? end