Skip to content

Commit

Permalink
Fix issue with orch stacks still having references to deleted ems
Browse files Browse the repository at this point in the history
  • Loading branch information
d-m-u committed Jan 21, 2020
1 parent 8b5b6d3 commit dd5eb70
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def up
OrchestrationStack.find_each do |stack|
user = if stack.service.present?
stack.service.tenant_identity
elsif !stack.ems_id.nil?
elsif stack.ext_management_system
stack.ext_management_system.tenant_identity
else
User.super_admin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@
expect(stack).to have_attributes(:tenant_id => ext_ms.tenant_id, :evm_owner_id => ext_ms.tenant_identity.id, :miq_group_id => ext_ms.tenant_identity.current_group.id)
end

it "sets owner, tenant, and group from the user if the ems was deleted but the stack ems id is still set" do
ext_ms = ems.create!(:tenant => tenant)
stack = orchestration_stack.create!(:ext_management_system => ext_ms)
ext_ms.destroy
expect(orchestration_stack.count).to eq(1)

migrate
stack.reload

expect(stack).to have_attributes(:tenant_id => user.current_tenant.id, :evm_owner_id => user.id, :miq_group_id => user.current_group.id)
end

it "sets owner, tenant, and group from the service if the service exists and ems doesn't" do
svc = service.create!(:tenant_id => tenant.id, :miq_group_id => group.id)
stack = orchestration_stack.create!(:direct_services => [svc])
Expand Down

0 comments on commit dd5eb70

Please sign in to comment.