From e24d757dbbe52ce6195c8d4f5ed2b5ee9ecc9a73 Mon Sep 17 00:00:00 2001 From: Simon Larsen Date: Fri, 25 Apr 2025 18:59:59 +0100 Subject: [PATCH] feat: Enhance e2e cron job configuration and add random sleep to FetchList job --- HelmChart/Public/oneuptime/templates/e2e-cron.yml | 4 ++++ Probe/Jobs/Monitor/FetchList.ts | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/HelmChart/Public/oneuptime/templates/e2e-cron.yml b/HelmChart/Public/oneuptime/templates/e2e-cron.yml index 390383e98d..9295195da7 100644 --- a/HelmChart/Public/oneuptime/templates/e2e-cron.yml +++ b/HelmChart/Public/oneuptime/templates/e2e-cron.yml @@ -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 }} diff --git a/Probe/Jobs/Monitor/FetchList.ts b/Probe/Jobs/Monitor/FetchList.ts index dda435b1b0..d4116501a2 100644 --- a/Probe/Jobs/Monitor/FetchList.ts +++ b/Probe/Jobs/Monitor/FetchList.ts @@ -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");