Skip to content

Commit

Permalink
Don't create tasks for things that are already retired
Browse files Browse the repository at this point in the history
  • Loading branch information
d-m-u committed Jun 19, 2019
1 parent e5a44b8 commit c6822d3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/models/service_retire_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def after_request_task_create

def create_retire_subtasks(parent_service, parent_task)
parent_service.service_resources.collect do |svc_rsc|
next if svc_rsc.resource.respond_to?(:retired?) && svc_rsc.resource.retired?
next unless svc_rsc.resource.try(:retireable?)
# TODO: the next line deals with the filtering for provisioning
# (https://github.com/ManageIQ/manageiq/blob/3921e87915b5a69937b9d4a70bb24ab71b97c165/app/models/service_template/filter.rb#L5)
Expand Down
9 changes: 9 additions & 0 deletions spec/models/service_retire_task_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,15 @@
expect(VmRetireTask.count).to eq(1)
expect(ServiceRetireTask.count).to eq(1)
end

it "does not create vm retire subtask for retired vm" do
service.add_resource!(FactoryBot.create(:vm_openstack, :retired => true))
service_retire_task.after_request_task_create

expect(service_retire_task.description).to eq("Service Retire for: #{service.name} - ")
expect(VmRetireTask.count).to eq(0)
expect(ServiceRetireTask.count).to eq(1)
end
end

context "bundled service retires all children" do
Expand Down

0 comments on commit c6822d3

Please sign in to comment.