Skip to content

Commit

Permalink
Merge pull request #18895 from d-m-u/adding_already_retired_check_to_…
Browse files Browse the repository at this point in the history
…service_retire_task_create

Don't create retirement tasks for things that are already retired

(cherry picked from commit 6bbf5f4)

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1728889
  • Loading branch information
bdunne authored and simaishi committed Jul 22, 2019
1 parent 022f723 commit e8bd1a3
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 @@ -37,6 +37,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 @@ -163,6 +163,15 @@
it "returns a description based upon the source service name" do
expect(ServiceRetireTask.get_description(miq_request)).to eq("Service Retire for: #{service.name}")
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 e8bd1a3

Please sign in to comment.