Skip to content

Commit

Permalink
More logging
Browse files Browse the repository at this point in the history
  • Loading branch information
ymao1 committed Nov 6, 2024
1 parent 4d31e0b commit e89908f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ export async function runInvalidate({
apiKeySOsPendingInvalidation: apiKeysToInvalidate,
encryptedSavedObjectsClient,
savedObjectsClient,
logger,
});
logger.info(
`API KEY INVALIDATION TASK: apiKeyIdsToExclude ${JSON.stringify(apiKeyIdsToExclude)}`
Expand All @@ -231,6 +232,7 @@ interface GetApiKeyIdsToInvalidateOpts {
apiKeySOsPendingInvalidation: SavedObjectsFindResponse<InvalidatePendingApiKey>;
encryptedSavedObjectsClient: EncryptedSavedObjectsClient;
savedObjectsClient: SavedObjectsClientContract;
logger: Logger;
}

interface GetApiKeysToInvalidateResult {
Expand All @@ -242,6 +244,7 @@ export async function getApiKeyIdsToInvalidate({
apiKeySOsPendingInvalidation,
encryptedSavedObjectsClient,
savedObjectsClient,
logger,
}: GetApiKeyIdsToInvalidateOpts): Promise<GetApiKeysToInvalidateResult> {
// Decrypt the apiKeyId for each pending invalidation SO
const apiKeyIds = await Promise.all(
Expand Down Expand Up @@ -280,6 +283,8 @@ export async function getApiKeyIdsToInvalidate({
},
});

logger.info(`API KEY INVALIDATION TASK: aggregation result ${JSON.stringify(aggregations)}`);

const apiKeyIdsInUseBuckets: AggregationsStringTermsBucketKeys[] =
(aggregations?.apiKeyId?.buckets as AggregationsStringTermsBucketKeys[]) ?? [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,15 +263,16 @@ export default function apiKeyBackfillTests({ getService }: FtrProviderContext)
await getAdHocRunSO(backfillId);
throw new Error('should have thrown');
} catch (e) {
log.info(`getAdHocRunSO error ${e.message}`);
expect(e.message).not.to.eql('should have thrown');
}
});

// invoke the invalidate task
await runInvalidateTask();

// pending API key should now be deleted because backfill is done
await retry.try(async () => {
// invoke the invalidate task
await runInvalidateTask();

const results = await getApiKeysPendingInvalidation();
log.info(`results 3 ${JSON.stringify(results)}`);
expect(results.length).to.eql(0);
Expand Down

0 comments on commit e89908f

Please sign in to comment.