Retries not executed on resource when ignore_failure set to true

I want my resource to attempt execution a number of times, but if still failing, I want to continue the Chef run, eg waiting for a limited time for a process to finish.

 execute 'Wait for msiexec.exe to finish' do
     command 'tasklist /FI "IMAGENAME eq msiexec.exe" /NH | find /I /C "msiexec"'
     returns 1
     retries 5
     retry_delay 30
     ignore_failure true
 end

Explaining what's happening exactly:

  • as long as a process is found, the resource should retry execution
  • the find command returns the number of processes found to STDOUT, so
    • returning 1,2,... will yield exit code 0 (find succeed) and resource fails & should retry
    • returning 0 will yield exit code 1 (find failed) and resource succeeds (using returns 1)
  • if after retry count has been depleted, resource still fails, the error should be ignored

The observed behaviour is

  • execution finds a process, 1 on STDOUT, 0 exit code, which indicates a failure
  • no retries are attempted, resource fails, chef run continues because ignore_failure is set

Is there any way to obtain the desired behaviour of depleting the retries count before failing the resource?

Extra info:
Running Chef Infra Client 16.5.77