[ML] Fixing job deletion slow refresh delay (#30371)
This commit is contained in:
parent
7ae1b4f44d
commit
59cddd706d
10
x-pack/plugins/ml/common/constants/jobs_list.js
Normal file
10
x-pack/plugins/ml/common/constants/jobs_list.js
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
/*
|
||||||
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||||
|
* or more contributor license agreements. Licensed under the Elastic License;
|
||||||
|
* you may not use this file except in compliance with the Elastic License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
export const DEFAULT_REFRESH_INTERVAL_MS = 30000;
|
||||||
|
export const MINIMUM_REFRESH_INTERVAL_MS = 5000;
|
||||||
|
export const DELETING_JOBS_REFRESH_INTERVAL_MS = 2000;
|
|
@ -12,14 +12,14 @@ export const DATAFEED_STATE = {
|
||||||
STARTING: 'starting',
|
STARTING: 'starting',
|
||||||
STOPPED: 'stopped',
|
STOPPED: 'stopped',
|
||||||
STOPPING: 'stopping',
|
STOPPING: 'stopping',
|
||||||
DELETED: 'deleted'
|
DELETED: 'deleted',
|
||||||
};
|
};
|
||||||
|
|
||||||
export const FORECAST_REQUEST_STATE = {
|
export const FORECAST_REQUEST_STATE = {
|
||||||
FAILED: 'failed',
|
FAILED: 'failed',
|
||||||
FINISHED: 'finished',
|
FINISHED: 'finished',
|
||||||
SCHEDULED: 'scheduled',
|
SCHEDULED: 'scheduled',
|
||||||
STARTED: 'started'
|
STARTED: 'started',
|
||||||
};
|
};
|
||||||
|
|
||||||
export const JOB_STATE = {
|
export const JOB_STATE = {
|
||||||
|
@ -27,5 +27,6 @@ export const JOB_STATE = {
|
||||||
CLOSING: 'closing',
|
CLOSING: 'closing',
|
||||||
FAILED: 'failed',
|
FAILED: 'failed',
|
||||||
OPENED: 'opened',
|
OPENED: 'opened',
|
||||||
OPENING: 'opening'
|
OPENING: 'opening',
|
||||||
|
DELETED: 'deleted',
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,6 +19,7 @@ import {
|
||||||
} from '@elastic/eui';
|
} from '@elastic/eui';
|
||||||
|
|
||||||
import { deleteJobs } from '../utils';
|
import { deleteJobs } from '../utils';
|
||||||
|
import { DELETING_JOBS_REFRESH_INTERVAL_MS } from '../../../../../common/constants/jobs_list';
|
||||||
import { injectI18n, FormattedMessage } from '@kbn/i18n/react';
|
import { injectI18n, FormattedMessage } from '@kbn/i18n/react';
|
||||||
|
|
||||||
export const DeleteJobModal = injectI18n(class extends Component {
|
export const DeleteJobModal = injectI18n(class extends Component {
|
||||||
|
@ -70,9 +71,9 @@ export const DeleteJobModal = injectI18n(class extends Component {
|
||||||
deleteJobs(this.state.jobs);
|
deleteJobs(this.state.jobs);
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
this.closeModal();
|
||||||
this.refreshJobs();
|
this.refreshJobs();
|
||||||
}, 500);
|
}, DELETING_JOBS_REFRESH_INTERVAL_MS);
|
||||||
this.closeModal();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setEL = (el) => {
|
setEL = (el) => {
|
||||||
|
|
|
@ -24,6 +24,12 @@ import { UpgradeWarning } from '../../../../components/upgrade';
|
||||||
import { RefreshJobsListButton } from '../refresh_jobs_list_button';
|
import { RefreshJobsListButton } from '../refresh_jobs_list_button';
|
||||||
import { isEqual } from 'lodash';
|
import { isEqual } from 'lodash';
|
||||||
|
|
||||||
|
import {
|
||||||
|
DEFAULT_REFRESH_INTERVAL_MS,
|
||||||
|
MINIMUM_REFRESH_INTERVAL_MS,
|
||||||
|
DELETING_JOBS_REFRESH_INTERVAL_MS,
|
||||||
|
} from '../../../../../common/constants/jobs_list';
|
||||||
|
|
||||||
import React, {
|
import React, {
|
||||||
Component
|
Component
|
||||||
} from 'react';
|
} from 'react';
|
||||||
|
@ -34,9 +40,7 @@ import {
|
||||||
EuiSpacer,
|
EuiSpacer,
|
||||||
} from '@elastic/eui';
|
} from '@elastic/eui';
|
||||||
|
|
||||||
const DEFAULT_REFRESH_INTERVAL_MS = 30000;
|
|
||||||
const MINIMUM_REFRESH_INTERVAL_MS = 5000;
|
|
||||||
const DELETING_JOBS_REFRESH_INTERVAL_MS = 2000;
|
|
||||||
let jobsRefreshInterval = null;
|
let jobsRefreshInterval = null;
|
||||||
let deletingJobsRefreshTimeout = null;
|
let deletingJobsRefreshTimeout = null;
|
||||||
|
|
||||||
|
|
|
@ -179,7 +179,7 @@ export function deleteJobs(jobs, finish = () => {}) {
|
||||||
const jobIds = jobs.map(j => j.id);
|
const jobIds = jobs.map(j => j.id);
|
||||||
mlJobService.deleteJobs(jobIds)
|
mlJobService.deleteJobs(jobIds)
|
||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
showResults(resp, DATAFEED_STATE.DELETED);
|
showResults(resp, JOB_STATE.DELETED);
|
||||||
finish();
|
finish();
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
|
Loading…
Reference in a new issue