Skip to content

Proposal: insert random delay instead of incrementing cron #4

Description

@ebiiim

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions