teslamotors / ansible_puller

Ansible daemon for massively-scaleable Ansible
MIT License
129 stars 35 forks source link

Add jitter to sleep #39

Closed ashi009 closed 1 year ago

ashi009 commented 1 year ago

Add sleep-jitter config/flag to sleep. So when deployed in large scale, this will reduce the likelihood for having all the servers banning the remote endpoint at once.

In this change runChan is replaced with a lambda function runOnce, which is a non-blocking function to trigger a single run, and it returns if ansible is running already. Which removes the possibility that multiple ansible runs queued up and runs back to back.

When sleep jitter is specified, the puller will sleep a duration that conforms to uniform distribution U(sleep-jitter, sleep+jitter). Otherwise the behavior remains unchanged.