diff --git a/x-pack/legacy/plugins/watcher/common/constants/action_states.ts b/x-pack/legacy/plugins/watcher/common/constants/action_states.ts
index e9501fc2a60c4e..ac4da650463f84 100644
--- a/x-pack/legacy/plugins/watcher/common/constants/action_states.ts
+++ b/x-pack/legacy/plugins/watcher/common/constants/action_states.ts
@@ -36,4 +36,9 @@ export const ACTION_STATES: { [key: string]: string } = {
CONFIG_ERROR: i18n.translate('xpack.watcher.constants.actionStates.configErrorStateText', {
defaultMessage: 'Config error',
}),
+
+ // Action status is unknown; we should never end up in this state
+ UNKNOWN: i18n.translate('xpack.watcher.constants.actionStates.unknownStateText', {
+ defaultMessage: 'Unknown',
+ }),
};
diff --git a/x-pack/legacy/plugins/watcher/public/np_ready/application/components/watch_status.tsx b/x-pack/legacy/plugins/watcher/public/np_ready/application/components/watch_status.tsx
index 8afd174f8561e6..a254f43723877a 100644
--- a/x-pack/legacy/plugins/watcher/public/np_ready/application/components/watch_status.tsx
+++ b/x-pack/legacy/plugins/watcher/public/np_ready/application/components/watch_status.tsx
@@ -23,6 +23,8 @@ function StatusIcon({ status }: { status: string }) {
return ;
case WATCH_STATES.CONFIG_ERROR:
case WATCH_STATES.ERROR:
+ case ACTION_STATES.UNKNOWN:
+ return ;
case ACTION_STATES.CONFIG_ERROR:
case ACTION_STATES.ERROR:
return ;
diff --git a/x-pack/legacy/plugins/watcher/server/np_ready/models/action_status/action_status.js b/x-pack/legacy/plugins/watcher/server/np_ready/models/action_status/action_status.js
index 6a484e7d4303a1..b7292ba3a0da16 100644
--- a/x-pack/legacy/plugins/watcher/server/np_ready/models/action_status/action_status.js
+++ b/x-pack/legacy/plugins/watcher/server/np_ready/models/action_status/action_status.js
@@ -5,7 +5,7 @@
*/
import { get } from 'lodash';
-import { badImplementation, badRequest } from 'boom';
+import { badRequest } from 'boom';
import { getMoment } from '../../../../common/lib/get_moment';
import { ACTION_STATES } from '../../../../common/constants';
import { i18n } from '@kbn/i18n';
@@ -46,6 +46,11 @@ export class ActionStatus {
return ACTION_STATES.ACKNOWLEDGED;
}
+ // A user could potentionally land in this state if running on multiple nodes and timing is off
+ if (ackState === 'acked' && this.lastAcknowledged < this.lastExecution) {
+ return ACTION_STATES.ERROR;
+ }
+
if (ackState === 'ackable' && this.lastThrottled >= this.lastExecution) {
return ACTION_STATES.THROTTLED;
}
@@ -58,20 +63,10 @@ export class ActionStatus {
return ACTION_STATES.ERROR;
}
- // At this point, we cannot determine the action status so we thrown an error.
+ // At this point, we cannot determine the action status so mark it as "unknown".
// We should never get to this point in the code. If we do, it means we are
// missing an action status and the logic to determine it.
- throw badImplementation(
- i18n.translate(
- 'xpack.watcher.models.actionStatus.notDetermineActionStatusBadImplementationMessage',
- {
- defaultMessage: 'Could not determine action status; action = {actionStatusJson}',
- values: {
- actionStatusJson: JSON.stringify(actionStatusJson),
- },
- }
- )
- );
+ return ACTION_STATES.UNKNOWN;
}
get isAckable() {