Skip to content

Commit

Permalink
[ILM] Fix Index Management not loading when ILM enricher errors out (e…
Browse files Browse the repository at this point in the history
…lastic#28108) (elastic#28191)

* Only load ILM data enricher if UI is enabled

* Silently swallow errors from data enrichers

* Only add index management ILM extensions if ILM UI is enabled
  • Loading branch information
jen-huang authored Jan 7, 2019
1 parent 596de51 commit e848e10
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
1 change: 1 addition & 0 deletions x-pack/plugins/index_lifecycle_management/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export function indexLifecycleManagement(kibana) {
registerLifecycleRoutes(server);
registerIndexRoutes(server);
if (
server.config().get('xpack.ilm.ui.enabled') &&
server.plugins.index_management &&
server.plugins.index_management.addIndexManagementDataEnricher
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,6 @@ export const addLifecyclePolicyActionExtension = (indices, reloadIndices) => {
};
};

addActionExtension(retryLifecycleActionExtension);
addActionExtension(removeLifecyclePolicyActionExtension);
addActionExtension(addLifecyclePolicyActionExtension);

export const ilmBannerExtension = indices => {
const { Query } = EuiSearchBar;
if (!indices.length) {
Expand Down Expand Up @@ -132,14 +128,10 @@ export const ilmBannerExtension = indices => {
};
};

addBannerExtension(ilmBannerExtension);

export const ilmSummaryExtension = index => {
return <IndexLifecycleSummary index={index} />;
};

addSummaryExtension(ilmSummaryExtension);

export const ilmFilterExtension = indices => {
const hasIlm = any(indices, index => index.ilm && index.ilm.managed);
if (!hasIlm) {
Expand Down Expand Up @@ -206,4 +198,12 @@ export const ilmFilterExtension = indices => {
}
};

addFilterExtension(ilmFilterExtension);
export const addAllExtensions = () => {
addActionExtension(retryLifecycleActionExtension);
addActionExtension(removeLifecyclePolicyActionExtension);
addActionExtension(addLifecyclePolicyActionExtension);

addBannerExtension(ilmBannerExtension);
addSummaryExtension(ilmSummaryExtension);
addFilterExtension(ilmFilterExtension);
};
9 changes: 8 additions & 1 deletion x-pack/plugins/index_lifecycle_management/public/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,11 @@

import './register_management_section';
import './register_routes';
import './extend_index_management';

import chrome from 'ui/chrome';
import { addAllExtensions } from './extend_index_management';

// Only add extensions if ILM UI is enabled
if (chrome.getInjected('ilmUiEnabled')) {
addAllExtensions();
}
10 changes: 8 additions & 2 deletions x-pack/plugins/index_management/server/lib/enrich_response.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@

import { getIndexManagementDataEnrichers } from '../../index_management_data';
export const enrichResponse = async (response, callWithRequest) => {
let enrichedResponse = response;
const dataEnrichers = getIndexManagementDataEnrichers();
for (let i = 0; i < dataEnrichers.length; i++) {
const dataEnricher = dataEnrichers[i];
response = await dataEnricher(response, callWithRequest);
try {
const dataEnricherResponse = await dataEnricher(enrichedResponse, callWithRequest);
enrichedResponse = dataEnricherResponse;
} catch(e) {
// silently swallow enricher response errors
}
}
return response;
};
};

0 comments on commit e848e10

Please sign in to comment.