Skip to content

Commit

Permalink
Adding log
Browse files Browse the repository at this point in the history
  • Loading branch information
ymao1 committed Nov 5, 2024
1 parent 3e1f8f3 commit 4d31e0b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions x-pack/plugins/alerting/server/invalidate_pending_api_keys/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ export async function runInvalidate({
// Query for PAGE_SIZE api keys to invalidate at a time. At the end of each iteration,
// we should have deleted the deletable keys and added keys still in use to the excluded list
const filter = getFindFilter(delay, [...excludedSOIds]);
logger.info(`API KEY INVALIDATION TASK: filter ${filter}`);
const apiKeysToInvalidate = await savedObjectsClient.find<InvalidatePendingApiKey>({
type: API_KEY_PENDING_INVALIDATION_TYPE,
filter,
Expand All @@ -195,20 +196,30 @@ export async function runInvalidate({
sortOrder: 'asc',
perPage: PAGE_SIZE,
});
logger.info(
`API KEY INVALIDATION TASK: apiKeysToInvalidate ${JSON.stringify(apiKeysToInvalidate)}`
);

if (apiKeysToInvalidate.total > 0) {
const { apiKeyIdsToExclude, apiKeyIdsToInvalidate } = await getApiKeyIdsToInvalidate({
apiKeySOsPendingInvalidation: apiKeysToInvalidate,
encryptedSavedObjectsClient,
savedObjectsClient,
});
logger.info(
`API KEY INVALIDATION TASK: apiKeyIdsToExclude ${JSON.stringify(apiKeyIdsToExclude)}`
);
logger.info(
`API KEY INVALIDATION TASK: apiKeyIdsToInvalidate ${JSON.stringify(apiKeyIdsToInvalidate)}`
);
apiKeyIdsToExclude.forEach(({ id }) => excludedSOIds.add(id));
totalInvalidated += await invalidateApiKeysAndDeletePendingApiKeySavedObject({
apiKeyIdsToInvalidate,
logger,
savedObjectsClient,
securityPluginStart: security,
});
logger.info(`API KEY INVALIDATION TASK: filter ${filter}`);
}

hasMoreApiKeysPendingInvalidation = apiKeysToInvalidate.total > PAGE_SIZE;
Expand Down

0 comments on commit 4d31e0b

Please sign in to comment.