Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions x-pack/legacy/plugins/epm/server/lib/elasticsearch/ilm/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,11 @@ export async function policyExists(
name: string,
callCluster: CallESAsCurrentUser
): Promise<boolean> {
try {
// TODO: Figure out if there is a better way to check for an ILM policy to exist that
// does not throw an exception.
await callCluster('transport.request', {
method: 'GET',
path: '/_ilm/policy/' + name,
});
return true;
} catch (e) {
return false;
}
const response = await callCluster('transport.request', {
method: 'GET',
path: '/_ilm/policy/?filter_path=' + name,
});

return false;
// If the response contains a key, it means the policy exists
return Object.keys(response).length > 0;
}