diff --git a/app/models/service_retire_task.rb b/app/models/service_retire_task.rb index 5081056122aa..38f7a1c634ec 100644 --- a/app/models/service_retire_task.rb +++ b/app/models/service_retire_task.rb @@ -32,7 +32,11 @@ def after_request_task_create def create_retire_subtasks(parent_service, parent_task) parent_service.service_resources.collect do |svc_rsc| - next unless svc_rsc.resource.try(:retireable?) + next unless svc_rsc.resource.present? && svc_rsc.resource.try(:retireable?) + next if svc_rsc.resource_type == "ServiceTemplate" && + !self.class.include_service_template?(self, + svc_rsc.resource.id, + parent_service) # TODO: the next line deals with the filtering for provisioning # (https://github.com/ManageIQ/manageiq/blob/3921e87915b5a69937b9d4a70bb24ab71b97c165/app/models/service_template/filter.rb#L5) # which should be extended to retirement as part of later work