mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
feat: Enhance e2e cron job configuration and add random sleep to FetchList job
This commit is contained in:
@@ -13,10 +13,14 @@ metadata:
|
||||
date: "{{ now | unixEpoch }}"
|
||||
spec:
|
||||
schedule: "*/30 * * * *" # At every 30 minute.
|
||||
{{- if $.Values.nodeSelector }}
|
||||
nodeSelector: {{- $.Values.nodeSelector | toYaml | nindent 8 }}
|
||||
{{- end }}
|
||||
jobTemplate:
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
|
||||
containers:
|
||||
- name: e2e-cron
|
||||
image: {{ printf "%s/%s/%s:%s" $.Values.image.registry $.Values.image.repository "e2e" $.Values.image.tag }}
|
||||
|
||||
@@ -18,6 +18,8 @@ import logger from "Common/Server/Utils/Logger";
|
||||
import Monitor from "Common/Models/DatabaseModels/Monitor";
|
||||
import { EVERY_MINUTE } from "Common/Utils/CronTime";
|
||||
import BasicCron from "Common/Server/Utils/BasicCron";
|
||||
import NumberUtil from "Common/Utils/Number";
|
||||
import Sleep from "Common/Types/Sleep";
|
||||
|
||||
const InitJob: VoidFunction = (): void => {
|
||||
BasicCron({
|
||||
@@ -77,6 +79,14 @@ class FetchListAndProbe {
|
||||
try {
|
||||
logger.debug("Fetching monitor list");
|
||||
|
||||
// sleep randomly between 0 and 45 seconds
|
||||
|
||||
const sleepTime: number = NumberUtil.getRandomNumber(0, 45000);
|
||||
logger.debug(
|
||||
`Sleeping for ${sleepTime} ms, just to give probe API's soem time to load balance between different workers`,
|
||||
);
|
||||
await Sleep.sleep(sleepTime);
|
||||
|
||||
const monitorListUrl: URL = URL.fromString(
|
||||
PROBE_INGEST_URL.toString(),
|
||||
).addRoute("/monitor/list");
|
||||
|
||||
Reference in New Issue
Block a user