mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
* [ML] Close job after forecast errors if starting from closed * [ML] Pass closeJob flag to error handler if forecast ID undefined
This commit is contained in:
parent
b64d3ae123
commit
05757eb0b9
1 changed files with 25 additions and 4 deletions
|
@ -163,19 +163,40 @@ export const ForecastingModal = injectI18n(class ForecastingModal extends Compon
|
|||
});
|
||||
};
|
||||
|
||||
runForecastErrorHandler = (resp) => {
|
||||
runForecastErrorHandler = (resp, closeJob) => {
|
||||
const intl = this.props.intl;
|
||||
|
||||
this.setState({ forecastProgress: PROGRESS_STATES.ERROR });
|
||||
console.log('Time series forecast modal - error running forecast:', resp);
|
||||
if (resp && resp.message) {
|
||||
this.addMessage(resp.message, MESSAGE_LEVEL.ERROR, true);
|
||||
} else {
|
||||
this.addMessage(
|
||||
this.props.intl.formatMessage({
|
||||
intl.formatMessage({
|
||||
id: 'xpack.ml.timeSeriesExplorer.forecastingModal.unexpectedResponseFromRunningForecastErrorMessage',
|
||||
defaultMessage: 'Unexpected response from running forecast. The request may have failed.',
|
||||
}),
|
||||
MESSAGE_LEVEL.ERROR, true);
|
||||
}
|
||||
|
||||
if (closeJob === true) {
|
||||
this.setState({ jobClosingState: PROGRESS_STATES.WAITING });
|
||||
mlJobService.closeJob(this.props.job.job_id)
|
||||
.then(() => {
|
||||
this.setState({ jobClosingState: PROGRESS_STATES.DONE });
|
||||
})
|
||||
.catch((response) => {
|
||||
console.log('Time series forecast modal - could not close job:', response);
|
||||
this.addMessage(
|
||||
intl.formatMessage({
|
||||
id: 'xpack.ml.timeSeriesExplorer.forecastingModal.errorWithClosingJobErrorMessage',
|
||||
defaultMessage: 'Error closing job',
|
||||
}),
|
||||
MESSAGE_LEVEL.ERROR
|
||||
);
|
||||
this.setState({ jobClosingState: PROGRESS_STATES.ERROR });
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
runForecast = (closeJobAfterRunning) => {
|
||||
|
@ -194,10 +215,10 @@ export const ForecastingModal = injectI18n(class ForecastingModal extends Compon
|
|||
if (resp.forecast_id !== undefined) {
|
||||
this.waitForForecastResults(resp.forecast_id, closeJobAfterRunning);
|
||||
} else {
|
||||
this.runForecastErrorHandler(resp);
|
||||
this.runForecastErrorHandler(resp, closeJobAfterRunning);
|
||||
}
|
||||
})
|
||||
.catch(this.runForecastErrorHandler);
|
||||
.catch(resp => this.runForecastErrorHandler(resp, closeJobAfterRunning));
|
||||
};
|
||||
|
||||
waitForForecastResults = (forecastId, closeJobAfterRunning) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue