mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Watcher] Fix logic that determines watch error state (#67952)
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
1277934588
commit
fc572c9e1a
3 changed files with 9 additions and 2 deletions
|
@ -85,6 +85,7 @@ describe('action_status', () => {
|
|||
beforeEach(() => {
|
||||
upstreamJson = {
|
||||
id: 'my-action',
|
||||
lastCheckedRawFormat: '2017-03-01T20:55:49.679Z',
|
||||
actionStatusJson: {
|
||||
ack: {
|
||||
timestamp: '2017-03-01T20:56:58.442Z',
|
||||
|
@ -107,7 +108,7 @@ describe('action_status', () => {
|
|||
});
|
||||
|
||||
describe(`correctly calculates ACTION_STATES.ERROR`, () => {
|
||||
it('lastExecutionSuccessful is equal to false', () => {
|
||||
it('lastExecutionSuccessful is equal to false and it is the most recent execution', () => {
|
||||
upstreamJson.actionStatusJson.last_execution.successful = false;
|
||||
const actionStatus = ActionStatus.fromUpstreamJson(upstreamJson);
|
||||
expect(actionStatus.state).to.be(ACTION_STATES.ERROR);
|
||||
|
|
|
@ -15,7 +15,9 @@ export class ActionStatus {
|
|||
this.id = props.id;
|
||||
this.actionStatusJson = props.actionStatusJson;
|
||||
this.errors = props.errors;
|
||||
this.lastCheckedRawFormat = props.lastCheckedRawFormat;
|
||||
|
||||
this.lastExecutionRawFormat = get(this.actionStatusJson, 'last_execution.timestamp');
|
||||
this.lastAcknowledged = getMoment(get(this.actionStatusJson, 'ack.timestamp'));
|
||||
this.lastExecution = getMoment(get(this.actionStatusJson, 'last_execution.timestamp'));
|
||||
this.lastExecutionSuccessful = get(this.actionStatusJson, 'last_execution.successful');
|
||||
|
@ -30,7 +32,10 @@ export class ActionStatus {
|
|||
const actionStatusJson = this.actionStatusJson;
|
||||
const ackState = actionStatusJson.ack.state;
|
||||
|
||||
if (this.lastExecutionSuccessful === false) {
|
||||
if (
|
||||
this.lastExecutionSuccessful === false &&
|
||||
this.lastCheckedRawFormat === this.lastExecutionRawFormat
|
||||
) {
|
||||
return ACTION_STATES.ERROR;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ export class WatchStatus {
|
|||
id,
|
||||
actionStatusJson,
|
||||
errors: this.watchErrors.actions && this.watchErrors.actions[id],
|
||||
lastCheckedRawFormat: get(this.watchStatusJson, 'last_checked'),
|
||||
};
|
||||
return ActionStatus.fromUpstreamJson(json);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue