Skip to content

Commit

Permalink
Move deleteTaskIfItExists to task manager
Browse files Browse the repository at this point in the history
  • Loading branch information
Liza K committed Jan 7, 2021
1 parent 70dd89a commit c71139d
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 7 deletions.
3 changes: 1 addition & 2 deletions x-pack/plugins/alerts/server/alerts_client/alerts_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ import {
InvalidateAPIKeyResult as SecurityPluginInvalidateAPIKeyResult,
} from '../../../security/server';
import { EncryptedSavedObjectsClient } from '../../../encrypted_saved_objects/server';
import { TaskManagerStartContract } from '../../../task_manager/server';
import { TaskManagerStartContract, deleteTaskIfItExists } from '../../../task_manager/server';
import { taskInstanceToAlertTaskInstance } from '../task_runner/alert_task_instance';
import { deleteTaskIfItExists } from '../lib/delete_task_if_it_exists';
import { RegistryAlertType, UntypedNormalizedAlertType } from '../alert_type_registry';
import { AlertsAuthorization, WriteOperations, ReadOperations } from '../authorization';
import { IEventLogClient } from '../../../../plugins/event_log/server';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
TaskManagerSetupContract,
TaskManagerStartContract,
RunContext,
deleteTaskIfItExists,
} from '../../../../task_manager/server';
import { checkRunningSessions } from './check_running_sessions';
import { CoreSetup, SavedObjectsClient, Logger } from '../../../../../../src/core/server';
Expand Down Expand Up @@ -56,10 +57,7 @@ export async function scheduleSearchSessionsTasks(
taskManager: TaskManagerStartContract,
logger: Logger
) {
try {
// delete previous task
await taskManager.remove(SEARCH_SESSIONS_TASK_ID);
} catch (e) {} // eslint-disable-line no-empty
await deleteTaskIfItExists(taskManager, SEARCH_SESSIONS_TASK_ID);

try {
await taskManager.ensureScheduled({
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/task_manager/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export {
} from './task';

export { isUnrecoverableError, throwUnrecoverableError } from './task_running';
export { deleteTaskIfItExists } from './lib/delete_task_if_it_exists';

export {
TaskManagerPlugin as TaskManager,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { TaskManagerStartContract } from '../../../task_manager/server';
import { TaskManagerStartContract } from '../';
import { SavedObjectsErrorHelpers } from '../../../../../src/core/server';

export async function deleteTaskIfItExists(taskManager: TaskManagerStartContract, taskId: string) {
Expand Down

0 comments on commit c71139d

Please sign in to comment.