feat: Enhance e2e cron job configuration and add random sleep to FetchList job

This commit is contained in:
Simon Larsen
2025-04-25 18:59:59 +01:00
parent 20c2931dec
commit e24d757dbb
2 changed files with 14 additions and 0 deletions

View File

@@ -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 }}

View File

@@ -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");