Problem
Collection currently increments cron, but actually it's difficult to define "increment" for cron.
$ kubectl get cronjobs
NAME SCHEDULE SUSPEND ACTIVE LAST SCHEDULE AGE
gitbackup-coll1-bar 2 6 * * * False 0 <none> 5s
gitbackup-coll1-foo 1 6 * * * False 0 <none> 5s
gitbackup-coll1-gitbackup 0 6 * * * False 0 <none> 5s
Proposal
Inserting a random delay like rand(0, repo_num*10) is a good alternative.
To allow Collection to set the delay to the controlled Repository, add spec.maxRandomDelay field to Repository.
apiVersion: gitbackup.ebiiim.com/v1beta1
kind: Repository
spec:
# max random delay in seconds
maxRandomDelay: 60
...
Random delay can be implemented in shell script like sleep $(shuf -i0-123 -n1) or sleep $(( RANDOM % 123 )).
Note: $RANDOM returns a number in the range 0 - 32767
Problem
Collectioncurrently increments cron, but actually it's difficult to define "increment" for cron.Proposal
Inserting a random delay like
rand(0, repo_num*10)is a good alternative.To allow
Collectionto set the delay to the controlledRepository, addspec.maxRandomDelayfield toRepository.Random delay can be implemented in shell script like
sleep $(shuf -i0-123 -n1)orsleep $(( RANDOM % 123 )).Note:
$RANDOMreturns a number in the range 0 - 32767