From 94a195b3cbefaf5e739a3ec30f447951b30f71e1 Mon Sep 17 00:00:00 2001 From: Aleksandr Malyshev Date: Tue, 8 Oct 2024 11:34:53 +0300 Subject: [PATCH] [PLAT-15621] Make sure scrape interval is used for DB node alive status query Summary: Currently we have range hardcoded to 30 seconds for DB node processes alive query. This does not work in case we want to increase scrape interval. Fixing it. Test Plan: Increase scrape interval to 30 seconds. Create universe. Make sure alive status is shown correctly. Reviewers: vbansal, skurapati, #yba-api-review! Reviewed By: vbansal, skurapati Subscribers: yugaware Differential Revision: https://phorge.dev.yugabyte.com/D38764 --- .../yw/controllers/handlers/UniverseInfoHandler.java | 6 +++++- .../yugabyte/yw/controllers/UniverseControllerTestBase.java | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/managed/src/main/java/com/yugabyte/yw/controllers/handlers/UniverseInfoHandler.java b/managed/src/main/java/com/yugabyte/yw/controllers/handlers/UniverseInfoHandler.java index 9541733760a2..fb0c953fc48b 100644 --- a/managed/src/main/java/com/yugabyte/yw/controllers/handlers/UniverseInfoHandler.java +++ b/managed/src/main/java/com/yugabyte/yw/controllers/handlers/UniverseInfoHandler.java @@ -10,6 +10,7 @@ package com.yugabyte.yw.controllers.handlers; +import static com.yugabyte.yw.common.SwamperHelper.getScrapeIntervalSeconds; import static play.mvc.Http.Status.BAD_REQUEST; import static play.mvc.Http.Status.INTERNAL_SERVER_ERROR; import static play.mvc.Http.Status.NOT_FOUND; @@ -282,12 +283,15 @@ public Path downloadNodeFile( private JsonNode getUniverseAliveStatus(Universe universe, MetricQueryHelper metricQueryHelper) { List values = new ArrayList<>(); boolean queryError = false; + long scrapeInterval = getScrapeIntervalSeconds(runtimeConfigFactory.staticApplicationConf()); try { values = metricQueryHelper.queryDirect( "max_over_time(up{node_prefix=\"" + universe.getUniverseDetails().nodePrefix - + "\"}[30s])"); + + "\"}[" + + (scrapeInterval * 2) + + "s])"); } catch (RuntimeException re) { queryError = true; log.debug( diff --git a/managed/src/test/java/com/yugabyte/yw/controllers/UniverseControllerTestBase.java b/managed/src/test/java/com/yugabyte/yw/controllers/UniverseControllerTestBase.java index 839cffa25a1a..e64e6ac624f8 100644 --- a/managed/src/test/java/com/yugabyte/yw/controllers/UniverseControllerTestBase.java +++ b/managed/src/test/java/com/yugabyte/yw/controllers/UniverseControllerTestBase.java @@ -146,6 +146,7 @@ protected Application provideApplication() { mockReleasesUtils = mock(ReleasesUtils.class); mockGFlagsValidation = mock(GFlagsValidation.class); + when(mockRuntimeConfig.getString("yb.metrics.scrape_interval")).thenReturn("10s"); when(mockRuntimeConfig.getBoolean("yb.cloud.enabled")).thenReturn(false); when(mockRuntimeConfig.getBoolean("yb.security.use_oauth")).thenReturn(false); when(mockRuntimeConfig.getInt("yb.fs_stateless.max_files_count_persist")).thenReturn(100);