[Logstash Centralized Management] Hide recently-deleted pipelines (follow up PR) (#18683)

* Renaming constant to be more descriptive

* Less kludgy language for better readabilility

* Removing extraneous newlines
This commit is contained in:
Shaunak Kashyap 2018-05-01 07:16:39 -07:00
parent ea23411dce
commit 2832af914e
3 changed files with 4 additions and 6 deletions

View file

@ -11,5 +11,5 @@ export const MONITORING = {
* also, deliberately, the same duration we give Monitoring to pick up and report on a recently-deleted pipeline before we
* are safe to stop tracking that pipeline as recently-deleted.
*/
PIPELINE_RECENCY_DURATION_S: 30
ACTIVE_PIPELINE_RANGE_S: 30
};

View file

@ -37,7 +37,7 @@ export class MonitoringService {
const body = {
timeRange: {
max: now.toISOString(),
min: now.subtract(MONITORING.PIPELINE_RECENCY_DURATION_S, 'seconds').toISOString()
min: now.subtract(MONITORING.ACTIVE_PIPELINE_RANGE_S, 'seconds').toISOString()
}
};
return this.$http.post(url, body);

View file

@ -32,13 +32,13 @@ export class PipelinesService {
// Monitoring will report centrally-managed pipelines as well, including recently-deleted centrally-managed ones.
// If there's a recently-deleted pipeline we're keeping track of BUT monitoring doesn't report it, that means
// it's no longer actually running in Logstash any more. So we can stop tracking it as a recently-deleted pipeline.
// it's not running in Logstash any more. So we can stop tracking it as a recently-deleted pipeline.
const monitoringPipelineIds = monitoringPipelines.map(pipeline => pipeline.id);
this.getRecentlyDeleted().forEach(recentlyDeletedPipeline => {
// We don't want to stop tracking the recently-deleted pipeline until Monitoring has had some
// time to report on it. Otherwise, if we stop tracking first, *then* Monitoring reports it, we'll
// still end up showing it in the list until Monitoring stops reporting it.
if (now - recentlyDeletedPipeline.deletedOn < (MONITORING.PIPELINE_RECENCY_DURATION_S * 1000)) {
if (now - recentlyDeletedPipeline.deletedOn < (MONITORING.ACTIVE_PIPELINE_RANGE_S * 1000)) {
return;
}
@ -127,11 +127,9 @@ export class PipelinesService {
}
return JSON.parse(recentlyDeletedPipelines);
}
setRecentlyDeleted(recentlyDeletedPipelineIds) {
this.$window.localStorage.setItem(RECENTLY_DELETED_PIPELINE_IDS_STORAGE_KEY, JSON.stringify(recentlyDeletedPipelineIds));
}
}