Skip to content

Commit

Permalink
fix backport
Browse files Browse the repository at this point in the history
  • Loading branch information
alisonelizabeth committed Feb 25, 2021
1 parent 81512ed commit 406c127
Show file tree
Hide file tree
Showing 20 changed files with 81 additions and 508 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ import {
EuiFlexItem,
EuiFlyoutBody,
EuiFlyoutFooter,
EuiLink,
EuiSpacer,
EuiTitle,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';

import { ReindexStatus, ReindexWarning } from '../../../../../../../../common/types';
import { ReindexStatus } from '../../../../../../../../common/types';
import { LoadingState } from '../../../../../types';
import { ReindexState } from '../polling_service';
import { ReindexProgress } from './progress';
Expand Down Expand Up @@ -78,7 +77,7 @@ export const ChecklistFlyoutStep: React.FunctionComponent<{
cancelReindex: () => void;
http: HttpSetup;
}> = ({ closeFlyout, reindexState, startReindex, cancelReindex, http, renderGlobalCallouts }) => {
const { loadingState, status, hasRequiredPrivileges, reindexWarnings } = reindexState;
const { loadingState, status, hasRequiredPrivileges } = reindexState;
const loading = loadingState === LoadingState.Loading || status === ReindexStatus.inProgress;

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ describe('getUpgradeAssistantStatus', () => {
esClient.asCurrentUser.indices.resolveIndex.mockResolvedValue(asApiResponse(resolvedIndices));

it('calls /_migration/deprecations', async () => {
await getUpgradeAssistantStatus(esClient, false, []);
await getUpgradeAssistantStatus(esClient, false);
expect(esClient.asCurrentUser.migration.deprecations).toHaveBeenCalled();
});

it('returns the correct shape of data', async () => {
const resp = await getUpgradeAssistantStatus(esClient, false, []);
const resp = await getUpgradeAssistantStatus(esClient, false);
expect(resp).toMatchSnapshot();
});

Expand All @@ -56,7 +56,7 @@ describe('getUpgradeAssistantStatus', () => {
})
);

await expect(getUpgradeAssistantStatus(esClient, false, [])).resolves.toHaveProperty(
await expect(getUpgradeAssistantStatus(esClient, false)).resolves.toHaveProperty(
'readyForUpgrade',
false
);
Expand All @@ -72,7 +72,7 @@ describe('getUpgradeAssistantStatus', () => {
})
);

await expect(getUpgradeAssistantStatus(esClient, false, [])).resolves.toHaveProperty(
await expect(getUpgradeAssistantStatus(esClient, false)).resolves.toHaveProperty(
'readyForUpgrade',
true
);
Expand All @@ -94,7 +94,7 @@ describe('getUpgradeAssistantStatus', () => {
})
);

const result = await getUpgradeAssistantStatus(esClient, true, []);
const result = await getUpgradeAssistantStatus(esClient, true);

expect(result).toHaveProperty('readyForUpgrade', true);
expect(result).toHaveProperty('cluster', []);
Expand Down
49 changes: 17 additions & 32 deletions x-pack/plugins/upgrade_assistant/server/lib/es_migration_apis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,15 @@ import {
UpgradeAssistantStatus,
} from '../../common/types';

import { isSystemIndex } from './reindexing';

import { esIndicesStateCheck } from './es_indices_state_check';

export async function getUpgradeAssistantStatus(
dataClient: IScopedClusterClient,
isCloudEnabled: boolean,
isCloudEnabled: boolean
): Promise<UpgradeAssistantStatus> {
const [{ body: deprecations }] = await Promise.all([
dataClient.asCurrentUser.migration.deprecations<DeprecationAPIResponse>(),
]);
const {
body: deprecations,
} = await dataClient.asCurrentUser.migration.deprecations<DeprecationAPIResponse>();

const cluster = getClusterDeprecations(deprecations, isCloudEnabled);
const indices = getCombinedIndexInfos(deprecations);
Expand Down Expand Up @@ -50,32 +48,19 @@ export async function getUpgradeAssistantStatus(
}

// Reformats the index deprecations to an array of deprecation warnings extended with an index field.
const getCombinedIndexInfos = (
deprecations: DeprecationAPIResponse,
) => {

return (
Object.keys(deprecations.index_settings)
.reduce((indexDeprecations, indexName) => {
return indexDeprecations.concat(
deprecations.index_settings[indexName].map(
(d) =>
({
...d,
index: indexName,
reindex: /Index created before/.test(d.message),
needsDefaultFields: /Number of fields exceeds automatic field expansion limit/.test(
d.message
),
} as EnrichedDeprecationInfo)
)
);
}, [] as EnrichedDeprecationInfo[])
// Filter out warnings for system indices until we know more about what changes are required for the
// next upgrade in a future minor version.
.filter((deprecation) => !isSystemIndex(deprecation.index!))
);
};
const getCombinedIndexInfos = (deprecations: DeprecationAPIResponse) =>
Object.keys(deprecations.index_settings).reduce((indexDeprecations, indexName) => {
return indexDeprecations.concat(
deprecations.index_settings[indexName].map(
(d) =>
({
...d,
index: indexName,
reindex: /Index created before/.test(d.message),
} as EnrichedDeprecationInfo)
)
);
}, [] as EnrichedDeprecationInfo[]);

const getClusterDeprecations = (deprecations: DeprecationAPIResponse, isCloudEnabled: boolean) => {
const combined = deprecations.cluster_settings
Expand Down

This file was deleted.

74 changes: 0 additions & 74 deletions x-pack/plugins/upgrade_assistant/server/lib/query_default_field.ts

This file was deleted.

Loading

0 comments on commit 406c127

Please sign in to comment.