Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reindex feature to Upgrade Assistant #27457

Merged
merged 56 commits into from
Jan 29, 2019
Merged
Show file tree
Hide file tree
Changes from 55 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
dac2e90
Fixup saved objects
joshdover Dec 18, 2018
0fef9fa
WIP reindex state machine
joshdover Dec 18, 2018
e3e0a2d
WIP UI
joshdover Dec 20, 2018
ff3ff83
Separate status from current step
joshdover Dec 20, 2018
2b94b32
Add error messages
joshdover Dec 21, 2018
20c0c90
Copy types to CallWithInternalUser
joshdover Jan 2, 2019
b5e3fd0
Use backend worker
joshdover Jan 2, 2019
b4831c6
Add progress bar for large indices
joshdover Jan 2, 2019
13eaad5
Cleanup worker implementation
joshdover Jan 2, 2019
30a1f61
Add tests for ReindexService
joshdover Jan 3, 2019
1c93f89
Fix types
joshdover Jan 3, 2019
5bb7de9
Fix CI
joshdover Jan 3, 2019
20d977d
Add support for mapping coerced boolean fields
joshdover Jan 4, 2019
5267bd9
Add basic functional integration test
joshdover Jan 7, 2019
c2aa2f0
Cleanup reindexing backend, add more checks
joshdover Jan 8, 2019
fb89604
Cleanup frontend code and add tests
joshdover Jan 8, 2019
5124db1
Support removal of _default_ mapping + add tests
joshdover Jan 9, 2019
a9256d1
Add reindex warnings to reindex service
joshdover Jan 9, 2019
2eb5bc6
Add confirmation modal for reindex warnings
joshdover Jan 10, 2019
00433d5
Cleanup flyout appearance
joshdover Jan 10, 2019
0c43c0e
Generate new index name intelligently
joshdover Jan 11, 2019
eb7af00
Design tweaks
joshdover Jan 11, 2019
4c1a3a2
Add data archive integration tests
joshdover Jan 11, 2019
7b9a61b
Change flyout design to two step process
joshdover Jan 14, 2019
9bd4db4
Reorganize flyout files
joshdover Jan 14, 2019
1ea9a4b
Use custom steps component
joshdover Jan 14, 2019
b7525f3
Allow writes to indices if anything fails
joshdover Jan 14, 2019
e5c9fc0
Show reindex button in both grouping modes
joshdover Jan 10, 2019
97ccb2e
Misc cleanup
joshdover Jan 14, 2019
9bdf1f0
Design edits
cchaos Jan 14, 2019
2727ae0
Only show warnings panel when reindex has not begun
joshdover Jan 14, 2019
daf9f79
Fix types
joshdover Jan 15, 2019
fdc11df
Merge remote-tracking branch 'upstream/6.x' into upgrade-checkup-reindex
joshdover Jan 15, 2019
415dc7c
Handle moving existing aliases
joshdover Jan 16, 2019
1df22cd
Move integration tests to separate config
joshdover Jan 16, 2019
4e1c29e
Fix ReindexButton bugs when changing pages
joshdover Jan 16, 2019
ba8206a
Merge remote-tracking branch 'upstream/6.x' into upgrade-checkup-reindex
joshdover Jan 17, 2019
c4a2a48
Fix polling service tests
joshdover Jan 17, 2019
74be0a2
Refactor ReindexService and ML handling (backend only)
joshdover Jan 18, 2019
1d1afe8
Add credential caching and paused state to backend
joshdover Jan 23, 2019
363485a
Add paused state to frontend
joshdover Jan 23, 2019
7dc526b
Fix ts errors
joshdover Jan 23, 2019
b4fd5db
Update copy
joshdover Jan 23, 2019
d24f935
Add check for node version before ML step
joshdover Jan 23, 2019
b56edfc
Merge remote-tracking branch 'upstream/6.x' into upgrade-checkup-reindex
joshdover Jan 24, 2019
a7b6bd7
Update data archive format
joshdover Jan 24, 2019
465596e
Update snapshots for React upgrade
joshdover Jan 24, 2019
fa9d1b9
Handle _default_ mappings correctly in warning checks
joshdover Jan 24, 2019
885c961
Use hashed state of reindex operation for credential storage
joshdover Jan 24, 2019
6dda2b3
Address tyler's comments
joshdover Jan 25, 2019
098a02c
Merge remote-tracking branch 'upstream/6.x' into upgrade-checkup-reindex
joshdover Jan 25, 2019
adc7188
Add watcher stop/starting
joshdover Jan 25, 2019
609f412
Use json-stable-stringify and sha256 for CredentialStore
joshdover Jan 25, 2019
80e31f3
Merge remote-tracking branch 'upstream/6.x' into upgrade-checkup-reindex
joshdover Jan 28, 2019
574ed90
Add types for json-stable-stringify
joshdover Jan 28, 2019
f4342df
Merge remote-tracking branch 'upstream/6.x' into upgrade-checkup-reindex
joshdover Jan 28, 2019
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
157 changes: 151 additions & 6 deletions src/legacy/core_plugins/elasticsearch/index.d.ts

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions src/server/kbn_server.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
*/

import { Server } from 'hapi';

import { CallClusterWithRequest, ElasticsearchPlugin } from '../legacy/core_plugins/elasticsearch';
import { IndexPatternsServiceFactory } from './index_patterns';
import { SavedObjectsService } from './saved_objects';
import { SavedObjectsClient, SavedObjectsService } from './saved_objects';

export interface KibanaConfig {
get<T>(key: string): T;
Expand All @@ -31,6 +32,7 @@ declare module 'hapi' {
interface PluginProperties {
elasticsearch: ElasticsearchPlugin;
kibana: any;
spaces: any;
// add new plugin types here
}

Expand All @@ -41,11 +43,9 @@ declare module 'hapi' {
}

interface Request {
getBasePath: () => string;
}

interface Request {
getUiSettingsService: () => any;
getSavedObjectsClient(): SavedObjectsClient;
getBasePath(): string;
getUiSettingsService(): any;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,16 @@
* under the License.
*/

import { SavedObjectsRepository, ScopedSavedObjectsClientProvider } from './lib';
import { ScopedSavedObjectsClientProvider } from './lib';
import { SavedObjectsClient } from './saved_objects_client';

export interface SavedObjectsService<Request = any> {
// ATTENTION: these types are incomplete

addScopedSavedObjectsClientWrapperFactory: ScopedSavedObjectsClientProvider<
Request
>['addClientWrapperFactory'];
getSavedObjectsRepository: (
callCluster: (endpoint: string, clientParams: any, options: any) => Promise<any>
) => SavedObjectsRepository;
getScopedSavedObjectsClient: ScopedSavedObjectsClientProvider<Request>['getClient'];
SavedObjectsClient: typeof SavedObjectsClient;
types: string[];
getSavedObjectsRepository(...rest: any[]): any;
}
2 changes: 1 addition & 1 deletion src/server/saved_objects/service/lib/repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ export class SavedObjectsRepository {
}

if (fields && !Array.isArray(fields)) {
throw new TypeError('options.searchFields must be an array');
throw new TypeError('options.fields must be an array');
}

const esOptions = {
Expand Down
65 changes: 39 additions & 26 deletions src/server/saved_objects/service/saved_objects_client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,32 @@ export interface CreateOptions extends BaseOptions {
override?: boolean;
}

export interface BulkCreateObject {
export interface BulkCreateObject<T extends SavedObjectAttributes = any> {
id?: string;
type: string;
attributes: SavedObjectAttributes;
attributes: T;
extraDocumentProperties?: string[];
}

export interface BulkCreateResponse {
savedObjects: SavedObject[];
export interface BulkCreateResponse<T extends SavedObjectAttributes = any> {
savedObjects: Array<SavedObject<T>>;
}

export interface FindOptions extends BaseOptions {
type?: string | string[];
page?: number;
perPage?: number;
sortField?: string;
sortOrder?: string;
fields?: string[];
type?: string | string[];
search?: string;
searchFields?: string[];
}

export interface FindResponse {
saved_objects: SavedObject[];
export interface FindResponse<T extends SavedObjectAttributes = any> {
saved_objects: Array<SavedObject<T>>;
total: number;
perPage: number;
per_page: number;
page: number;
}

Expand All @@ -65,46 +67,57 @@ export interface BulkGetObject {
}
export type BulkGetObjects = BulkGetObject[];

export interface BulkGetResponse {
savedObjects: SavedObject[];
export interface BulkGetResponse<T extends SavedObjectAttributes = any> {
savedObjects: Array<SavedObject<T>>;
}

export interface SavedObjectAttributes {
[key: string]: SavedObjectAttributes | string | number | boolean | null;
}

export interface SavedObject {
export interface SavedObject<T extends SavedObjectAttributes = any> {
id: string;
type: string;
version?: number;
updated_at?: string;
error?: {
message: string;
};
attributes: SavedObjectAttributes;
attributes: T;
}

export declare class SavedObjectsClient {
public static errors: typeof errors;
public errors: typeof errors;
public create: (

constructor(repository: SavedObjectsRepository);

public create<T extends SavedObjectAttributes = any>(
type: string,
attributes: SavedObjectAttributes,
attributes: T,
options?: CreateOptions
) => Promise<SavedObject>;
public bulkCreate: (
objects: BulkCreateObject[],
): Promise<SavedObject<T>>;
public bulkCreate<T extends SavedObjectAttributes = any>(
objects: Array<BulkCreateObject<T>>,
options?: CreateOptions
) => Promise<BulkCreateResponse>;
public delete: (type: string, id: string, options?: BaseOptions) => Promise<{}>;
public find: (options: FindOptions) => Promise<FindResponse>;
public bulkGet: (objects: BulkGetObjects, options?: BaseOptions) => Promise<BulkGetResponse>;
public get: (type: string, id: string, options?: BaseOptions) => Promise<SavedObject>;
public update: (
): Promise<BulkCreateResponse<T>>;
public delete(type: string, id: string, options?: BaseOptions): Promise<{}>;
public find<T extends SavedObjectAttributes = any>(
options: FindOptions
): Promise<FindResponse<T>>;
public bulkGet<T extends SavedObjectAttributes = any>(
objects: BulkGetObjects,
options?: BaseOptions
): Promise<BulkGetResponse<T>>;
public get<T extends SavedObjectAttributes = any>(
type: string,
id: string,
options?: BaseOptions
): Promise<SavedObject<T>>;
public update<T extends SavedObjectAttributes = any>(
type: string,
id: string,
attributes: SavedObjectAttributes,
attributes: Partial<T>,
options?: UpdateOptions
) => Promise<SavedObject>;
constructor(repository: SavedObjectsRepository);
): Promise<SavedObject<T>>;
}
2 changes: 2 additions & 0 deletions x-pack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
"@scant/router": "^0.1.0",
"@slack/client": "^4.8.0",
"@turf/boolean-contains": "6.0.1",
"@types/json-stable-stringify": "^1.0.32",
"angular-resource": "1.4.9",
"angular-sanitize": "1.6.5",
"angular-ui-ace": "0.2.3",
Expand Down Expand Up @@ -189,6 +190,7 @@
"io-ts": "^1.4.2",
"joi": "^13.5.2",
"jquery": "^3.3.1",
"json-stable-stringify": "^1.0.1",
"jsonwebtoken": "^8.3.0",
"jstimezonedetect": "1.0.5",
"lodash": "npm:@elastic/[email protected]",
Expand Down
7 changes: 6 additions & 1 deletion x-pack/plugins/__mocks__/ui/chrome.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,13 @@ function getInjected(key) {
}
}

function getXsrfToken() {
return 'kbn';
}

export default {
getInjected,
addBasePath,
getUiSettingsClient
getUiSettingsClient,
getXsrfToken
};
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ export class SpacesSavedObjectsClient implements SavedObjectsClient {
* @property {string} [options.namespace]
* @returns {promise} - { id, type, version, attributes }
*/
public async create(type: string, attributes = {}, options: CreateOptions = {}) {
public async create<T extends SavedObjectAttributes>(
type: string,
attributes: T = {} as T,
options: CreateOptions = {}
) {
throwErrorIfTypeIsSpace(type);
throwErrorIfNamespaceSpecified(options);

Expand Down Expand Up @@ -215,10 +219,10 @@ export class SpacesSavedObjectsClient implements SavedObjectsClient {
* @property {string} [options.namespace]
* @returns {promise}
*/
public async update(
public async update<T extends SavedObjectAttributes>(
type: string,
id: string,
attributes: SavedObjectAttributes,
attributes: Partial<T>,
options: UpdateOptions = {}
) {
throwErrorIfTypeIsSpace(type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
*/

// @ts-ignore
import { PluginProperties, Server } from 'hapi';
import { Server } from 'hapi';
import { Legacy } from 'kibana';
import { SpacesClient } from '../../../lib/spaces_client';
import { createSpaces } from './create_spaces';

interface KibanaServer extends Server {
interface KibanaServer extends Legacy.Server {
savedObjects: any;
}

Expand Down Expand Up @@ -46,13 +47,6 @@ const baseConfig: TestConfig = {
'xpack.spaces.maxSpaces': 1000,
};

// Merge / extend default interfaces for hapi. This is all faked out below.
declare module 'hapi' {
interface PluginProperties {
spaces: any;
}
}

export function createTestHandler(initApiFn: (server: any, preCheckLicenseImpl: any) => void) {
const teardowns: TeardownFn[] = [];

Expand Down
49 changes: 49 additions & 0 deletions x-pack/plugins/upgrade_assistant/common/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import {
SavedObject,
SavedObjectAttributes,
} from 'src/server/saved_objects/service/saved_objects_client';

export enum ReindexStep {
// Enum values are spaced out by 10 to give us room to insert steps in between.
created = 0,
indexConsumersStopped = 10,
readonly = 20,
newIndexCreated = 30,
reindexStarted = 40,
reindexCompleted = 50,
aliasCreated = 60,
indexConsumersStarted = 70,
}

export enum ReindexStatus {
inProgress,
completed,
failed,
paused,
}

export const REINDEX_OP_TYPE = 'upgrade-assistant-reindex-operation';
export interface ReindexOperation extends SavedObjectAttributes {
indexName: string;
newIndexName: string;
status: ReindexStatus;
lastCompletedStep: ReindexStep;
locked: string | null;
reindexTaskId: string | null;
reindexTaskPercComplete: number | null;
errorMessage: string | null;
mlReindexCount: number | null;
}

export type ReindexSavedObject = SavedObject<ReindexOperation>;

export enum ReindexWarning {
allField,
booleanFields,
}
1 change: 1 addition & 0 deletions x-pack/plugins/upgrade_assistant/common/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ const matches = currentVersionNum.match(/^([1-9]+)\.([0-9]+)\.([0-9]+)$/)!;

export const CURRENT_MAJOR_VERSION = matches[1];
export const NEXT_MAJOR_VERSION = (parseInt(CURRENT_MAJOR_VERSION, 10) + 1).toString();
export const PREV_MAJOR_VERSION = (parseInt(CURRENT_MAJOR_VERSION, 10) - 1).toString();
6 changes: 6 additions & 0 deletions x-pack/plugins/upgrade_assistant/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ export function upgradeAssistant(kibana: any) {
uiExports: {
managementSections: ['plugins/upgrade_assistant'],
styleSheetPaths: resolve(__dirname, 'public/index.scss'),
mappings: require('./mappings.json'),
savedObjectSchemas: {
'upgrade-assistant-reindex-operation': {
isNamespaceAgnostic: true,
joshdover marked this conversation as resolved.
Show resolved Hide resolved
},
},
},
publicDir: resolve(__dirname, 'public'),

Expand Down
13 changes: 13 additions & 0 deletions x-pack/plugins/upgrade_assistant/mappings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"upgrade-assistant-reindex-operation": {
"dynamic": true,
"properties": {
"indexName": {
"type": "keyword"
},
"status": {
"type": "integer"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { mountWithIntl } from 'test_utils/enzyme_helpers';

jest.mock('axios', () => ({
get: jest.fn(),
create: jest.fn(),
}));

import { UpgradeAssistantTabs } from './tabs';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@import './cell';
@import './reindex/index';

.upgDeprecations {
// Pull the container through the padding of EuiPageContent
Expand Down
Loading