prometheus: fix scrape duration growing unbounded (#13667)#13678
prometheus: fix scrape duration growing unbounded (#13667)#13678PrashantBhanage wants to merge 958 commits into
Conversation
…naged storage while restoring VM (apache#12879)
…e#12880) * fixed database update on snapshot with multiple volumes and an api change * changed overwritevolumecontent based on powerflex version and removed unnecessary comments * Update plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/client/ScaleIOGatewayClientImpl.java Co-authored-by: Suresh Kumar Anaparti <sureshkumar.anaparti@gmail.com> * Update plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/client/ScaleIOGatewayClientImpl.java Co-authored-by: Suresh Kumar Anaparti <sureshkumar.anaparti@gmail.com> * Update plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/client/ScaleIOGatewayClientImpl.java Co-authored-by: Suresh Kumar Anaparti <sureshkumar.anaparti@gmail.com> --------- Co-authored-by: Suresh Kumar Anaparti <sureshkumar.anaparti@gmail.com>
…pache#12805) * Fix NPE in NASBackupProvider when no running KVM host is available ResourceManager.findOneRandomRunningHostByHypervisor() can return null when no KVM host in the zone has status=Up (e.g. during management server startup, brief agent disconnections, or host state transitions). NASBackupProvider.syncBackupStorageStats() and deleteBackup() call host.getId() without a null check, causing a NullPointerException that crashes the entire BackupSyncTask background job every sync interval. This adds null checks in both methods: - syncBackupStorageStats: log a warning and return early - deleteBackup: throw CloudRuntimeException with a descriptive message
…ers (apache#12894) * VM start error handling improvements, and config to expose error to user * refactor
…ubernetes dashboard (apache#12776)
* Refactor Quota Summary API * Fixes imports * Fix QuotaServiceImplTest * Update plugins/database/quota/src/main/java/org/apache/cloudstack/api/command/QuotaSummaryCmd.java Co-authored-by: Fabricio Duarte <fabricio.duarte.jr@gmail.com> * Fix QuotaSummaryCmd * Remove unnecessary imports * Remove unused createQuotaSummaryResponse declarations * Remove unnecessary imports * Update plugins/database/quota/src/main/java/org/apache/cloudstack/api/command/QuotaSummaryCmd.java Co-authored-by: dahn <daan.hoogland@gmail.com> * Fix QuotaSummaryCmd * Fix QuotaResponseBuilderImplTest * Refactor test * Fix QuotaSummaryCmd * Fix projectid behavior * Simplify QuotaSummary and deprecate listall * Fix createQuotaSummaryResponse * Remove unused import * Apply suggestions + some adjustments * Remove duplicated check * Fix checkstyle * Adjust entity owner * Remove unused method + fix tests * Add missing @acl to some parameters * Adjust how the parameters behave * Allow domain admins and users to use keyword * Address reviews --------- Co-authored-by: Julien Hervot de Mattos Vaz <julien.vaz@scclouds.com.br> Co-authored-by: Fabricio Duarte <fabricio.duarte.jr@gmail.com> Co-authored-by: dahn <daan.hoogland@gmail.com>
* Fix NPE during VM setup for pvlan * review comments
…specified when upload a template (apache#12768)
apache#12833) Fixes an issue in NsxResource.executeRequest where Network.Service comparison failed when DeleteNsxNatRuleCommand was executed in a different process. Due to serialization/deserialization, the deserialized Network.Service instance was not equal to the static instances Network.Service.StaticNat and Network.Service.PortForwarding, causing the comparison to always return false. Co-authored-by: Andrey Volchkov <avolchkov@playtika.com>
…n user_statistics table in account_view for netstats (apache#12631)" (apache#12965) This reverts commit 58916eb.
… in progress (apache#12792) * Block backup deletion while create-VM-from-backup or restore jobs are in progress * Add tests * Fix exception message * Update test Co-authored-by: Abhisar Sinha <63767682+abh1sar@users.noreply.github.com>
@DaanHoogland Done! I have switched the base branch of this PR to your ghi13586-prometheusDrainage-20 branch as requested. |
quote, that went wrong @PrashantBhanage , look at the commit list in this pull. It contains a lot of undesirable extras. also 3000+ files changesd can’t be good. Can you have another look? |
|
@DaanHoogland Thanks for catching that. I recreated the branch from ghi13586-prometheusDrainage-20 and opened a clean PR containing only the Prometheus fix (1 commit / 4 files changed). I'll close this PR to avoid the unrelated commits. Thanks! |
Description
This PR fixes unbounded growth of Prometheus
/metricsscrape durationagainst the CloudStack management server (root cause tracked in #13586,
improvements requested in #13667).
Before: the exporter's
HttpServerused the JDK default single-threadedexecutor, so a slow scrape serialized/queued every other scrape behind it.
Additionally,
updateMetrics()had no guard against concurrent or rapidrecomputation, so scrape frequency could multiply backend load
indefinitely. Only a full management server restart reset the growth.
After: three targeted, contained changes, all inside
plugins/integrations/prometheus/:PrometheusExporterServerImpl#start()nowsets an explicit
Executors.newFixedThreadPool(2)as the HttpServer'sexecutor instead of relying on the JDK default, and shuts it down
cleanly in
stop().PrometheusExporterImpl#updateMetrics()isnow
synchronizedand checks alastMetricsUpdateTimetimestampagainst a new dynamic global setting,
prometheus.exporter.metrics.min.refresh.interval(default 5 seconds).Scrapes arriving within that window reuse the previously computed
metrics instead of triggering a fresh, expensive recomputation.
updateMetrics()now logs its wall-clockexecution time in milliseconds at
infolevel on every run (includingon the exception path), so operators/CI can identify which
sub-collector is slow and confirm the fix closes the growth.
This PR deliberately does not touch
AlertManagerImplor thecapacity-calculation executor in
server/— that code already creates afresh thread pool per invocation and reads
capacity.calculate.workersdynamically on
main, and rewriting it was flagged in the issue commentsas unnecessary scope creep that introduced its own bugs (stale config,
swallowed shutdown exceptions, thread-pool leaks).
Fixes: #13667
Ref: #13586
Types of changes
Feature/Enhancement Scale or Bug Severity
Bug Severity
Screenshots (if appropriate):
N/A — backend-only change, no UI impact.
How Has This Been Tested?
PrometheusExporterImplTest:testUpdateMetricsTTLGuardSkipsSecondCall— two rapid calls toupdateMetrics()within the TTL window result in only onerecomputation.
testUpdateMetricsTTLGuardAllowsAfterInterval— after the configuredinterval elapses, a subsequent call triggers a fresh recomputation.
mvn -pl plugins/integrations/prometheus test→ 6/6 tests pass (4existing + 2 new).
mvn -pl plugins/integrations/prometheus -am install→ build success./metricsreuse cachedoutput within the TTL window, and that logged
updateMetrics()durationstays flat instead of climbing across successive scrapes.
How did you try to break this feature and the system with this change?
/metricsto confirm thebounded executor and
synchronizedguard prevent overlappingrecomputation instead of deadlocking or throwing.
stop()shuts down the new executor cleanly with no resourceleak warnings.
prometheus.exporter.metrics.min.refresh.intervalsetting is dynamically adjustable at runtime without a restart, and
that a value of
0effectively disables the guard (falls back tooriginal per-scrape recomputation behavior) for anyone who wants that.
AlertManagerImpl,CapacityManagerImpl,etc.) was touched, keeping this change fully isolated to the exporter
plugin.