Skip to content

Commit

Permalink
fixed jest tests
Browse files Browse the repository at this point in the history
  • Loading branch information
YulNaumenko committed Jan 18, 2022
1 parent 5dfe01c commit 31fad53
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions x-pack/plugins/actions/server/lib/action_executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export class ActionExecutor {
private isInitialized = false;
private actionExecutorContext?: ActionExecutorContext;
private readonly isESOCanEncrypt: boolean;
private actionInfo: ActionInfo | undefined;

constructor({ isESOCanEncrypt }: { isESOCanEncrypt: boolean }) {
this.isESOCanEncrypt = isESOCanEncrypt;
Expand Down Expand Up @@ -126,15 +127,19 @@ export class ActionExecutor {
const namespace = spaceId && spaceId !== 'default' ? { namespace: spaceId } : {};

const actionInfo = await getActionInfoInternal(
await getActionsClientWithRequest(request, source),
encryptedSavedObjectsClient,
preconfiguredActions,
actionId,
namespace.namespace
);
await getActionsClientWithRequest(request, source),
encryptedSavedObjectsClient,
preconfiguredActions,
actionId,
namespace.namespace
);

const { actionTypeId, name, config, secrets } = actionInfo;

if (!this.actionInfo || this.actionInfo.actionId !== actionId) {
this.actionInfo = actionInfo;
}

if (span) {
span.name = `execute_action ${actionTypeId}`;
span.addLabels({
Expand Down Expand Up @@ -296,13 +301,15 @@ export class ActionExecutor {

const spaceId = spaces && spaces.getSpaceId(request);
const namespace = spaceId && spaceId !== 'default' ? { namespace: spaceId } : {};
const actionInfo = await getActionInfoInternal(
await getActionsClientWithRequest(request, source),
encryptedSavedObjectsClient,
preconfiguredActions,
actionId,
namespace.namespace
);
if (!this.actionInfo || this.actionInfo.actionId !== actionId) {
this.actionInfo = await getActionInfoInternal(
await getActionsClientWithRequest(request, source),
encryptedSavedObjectsClient,
preconfiguredActions,
actionId,
namespace.namespace
);
}
const task = taskInfo
? {
task: {
Expand All @@ -315,16 +322,16 @@ export class ActionExecutor {
const event = createActionEventLogRecordObject({
actionId,
action: EVENT_LOG_ACTIONS.executeTimeout,
message: `action: ${actionInfo.actionTypeId}:${actionId}: '${
actionInfo.name ?? ''
message: `action: ${this.actionInfo.actionTypeId}:${actionId}: '${
this.actionInfo.name ?? ''
}' execution cancelled due to timeout - exceeded default timeout of "5m"`,
...namespace,
...task,
savedObjects: [
{
type: 'action',
id: actionId,
typeId: actionInfo.actionTypeId,
typeId: this.actionInfo.actionTypeId,
relation: SAVED_OBJECT_REL_PRIMARY,
},
],
Expand Down

0 comments on commit 31fad53

Please sign in to comment.