diff --git a/x-pack/plugins/task_manager/server/task_manager.ts b/x-pack/plugins/task_manager/server/task_manager.ts index 35ca439bb9130..d269e69f75bd1 100644 --- a/x-pack/plugins/task_manager/server/task_manager.ts +++ b/x-pack/plugins/task_manager/server/task_manager.ts @@ -284,6 +284,11 @@ export class TaskManager { taskInstance: TaskInstanceWithDeprecatedFields, options?: object ): Promise { + if (taskInstance?.scope?.includes('alerting')) { + console.log( + `:::::: TaskManager.schedule(${taskInstance.params?.alertId}) [availableWorkers=${this.pool.availableWorkers}]` + ); + } await this.waitUntilStarted(); const { taskInstance: modifiedTask } = await this.middleware.beforeSave({ ...options, diff --git a/x-pack/plugins/task_manager/server/task_store.ts b/x-pack/plugins/task_manager/server/task_store.ts index bfdbe0d376f58..13db893116073 100644 --- a/x-pack/plugins/task_manager/server/task_store.ts +++ b/x-pack/plugins/task_manager/server/task_store.ts @@ -174,6 +174,11 @@ export class TaskStore { { id: taskInstance.id, refresh: false } ); + if (taskInstance?.scope?.includes('alerting')) { + console.log(`:::::: TaskStore.schedule(${taskInstance.params?.alertId})`); + console.log(`:::::: ${JSON.stringify(savedObject)}`); + } + return savedObjectToConcreteTaskInstance(savedObject); } diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/update.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/update.ts index 17dba0cb85572..782845d70ac45 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/update.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/update.ts @@ -735,6 +735,8 @@ export default function createUpdateTests({ getService }: FtrProviderContext) { .expect(200); objectRemover.add(space.id, createdAlert.id, 'alert', 'alerts'); + console.log('scheduled with interval of 30m'); + await retry.try(async () => { const alertTask = await getAlertingTaskById(createdAlert.scheduledTaskId); expect(alertTask.status).to.eql('idle'); @@ -742,6 +744,8 @@ export default function createUpdateTests({ getService }: FtrProviderContext) { ensureDatetimeIsWithinRange(Date.parse(alertTask.runAt), 30 * 60 * 1000); }); + console.log('has been rescheduled after first run'); + await ensureTasksIndexRefreshed(); const updatedData = {