Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions charts/logan/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,19 @@
{{- "UNDEFINED" -}}
{{- end -}}
{{- end -}}

#Add random offset for discovery job
{{- define "randomOffsetCronSchedule" -}}
{{- $cronSchedule := .Values.k8sDiscovery.objects.cronSchedule -}}
{{- $cronParts := regexSplit " " $cronSchedule -1 -}}
{{- $minutePart := index $cronParts 0 -}}
{{- if hasPrefix "*/" $minutePart -}}
{{- $interval := trimPrefix "*/" $minutePart | atoi -}}
{{- $intervalInt := int $interval -}}
{{- $randomOffset := randInt 0 $intervalInt -}}
{{- $newMinutePart := printf "%d/%d" $randomOffset $interval -}}
{{- printf "%s %s %s %s %s" $newMinutePart (index $cronParts 1) (index $cronParts 2) (index $cronParts 3) (index $cronParts 4) -}}
{{- else -}}
{{- $cronSchedule -}}
{{- end -}}
{{- end -}}
2 changes: 1 addition & 1 deletion charts/logan/templates/discovery-cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ metadata:
name: {{ .Values.global.resourceNamePrefix }}-discovery
namespace: {{ $kubernetesNamespace }}
spec:
schedule: {{ .Values.k8sDiscovery.objects.cronSchedule | quote }}
schedule: "{{ include "randomOffsetCronSchedule" . }}"
startingDeadlineSeconds: 120
concurrencyPolicy: Forbid
successfulJobsHistoryLimit: {{ .Values.k8sDiscovery.objects.successfulJobsHistoryLimit }}
Expand Down