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

[7.x] Legacy ES plugin pre-removal cleanup (#75779) #76042

Merged
merged 1 commit into from
Aug 27, 2020
Merged
Show file tree
Hide file tree
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
16 changes: 0 additions & 16 deletions src/core/server/ui_settings/integration_tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,6 @@ import { docMissingSuite } from './doc_missing';
import { docMissingAndIndexReadOnlySuite } from './doc_missing_and_index_read_only';

describe('uiSettings/routes', function () {
/**
* The "doc missing" and "index missing" tests verify how the uiSettings
* API behaves in between healthChecks, so they interact with the healthCheck
* in somewhat weird ways (can't wait until we get to https://github.com/elastic/kibana/issues/14163)
*
* To make this work we have a `waitUntilNextHealthCheck()` function in ./lib/servers.js
* that deletes the kibana index and then calls `plugins.elasticsearch.waitUntilReady()`.
*
* waitUntilReady() waits for the kibana index to exist and then for the
* elasticsearch plugin to go green. Since we have verified that the kibana index
* does not exist we know that the plugin will also turn yellow while waiting for
* it and then green once the health check is complete, ensuring that we run our
* tests right after the health check. All of this is to say that the tests are
* stupidly fragile and timing sensitive. #14163 should fix that, but until then
* this is the most stable way I've been able to get this to work.
*/
jest.setTimeout(10000);

beforeAll(startServers);
Expand Down
16 changes: 0 additions & 16 deletions src/core/server/ui_settings/integration_tests/lib/servers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ interface AllServices {
savedObjectsClient: SavedObjectsClientContract;
callCluster: LegacyAPICaller;
uiSettings: IUiSettingsClient;
deleteKibanaIndex: typeof deleteKibanaIndex;
}

let services: AllServices;
Expand All @@ -62,20 +61,6 @@ export async function startServers() {
kbnServer = kbn.kbnServer;
}

async function deleteKibanaIndex(callCluster: LegacyAPICaller) {
const kibanaIndices = await callCluster('cat.indices', { index: '.kibana*', format: 'json' });
const indexNames = kibanaIndices.map((x: any) => x.index);
if (!indexNames.length) {
return;
}
await callCluster('indices.putSettings', {
index: indexNames,
body: { index: { blocks: { read_only: false } } },
});
await callCluster('indices.delete', { index: indexNames });
return indexNames;
}

export function getServices() {
if (services) {
return services;
Expand All @@ -97,7 +82,6 @@ export function getServices() {
callCluster,
savedObjectsClient,
uiSettings,
deleteKibanaIndex,
};

return services;
Expand Down
2 changes: 0 additions & 2 deletions src/legacy/core_plugins/elasticsearch/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,4 @@ export interface CallCluster {
export interface ElasticsearchPlugin {
status: { on: (status: string, cb: () => void) => void };
getCluster(name: string): Cluster;
createCluster(name: string, config: ClusterConfig): Cluster;
waitUntilReady(): Promise<void>;
}
33 changes: 1 addition & 32 deletions src/legacy/core_plugins/elasticsearch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@
import { first } from 'rxjs/operators';
import { Cluster } from './lib/cluster';
import { createProxy } from './lib/create_proxy';
import { handleESError } from './lib/handle_es_error';
import { versionHealthCheck } from './lib/version_health_check';

export default function (kibana) {
let defaultVars;

return new kibana.Plugin({
require: ['kibana'],
require: [],

uiExports: { injectDefaultVars: () => defaultVars },

Expand Down Expand Up @@ -61,25 +59,6 @@ export default function (kibana) {
return clusters.get(name);
});

server.expose('createCluster', (name, clientConfig = {}) => {
// NOTE: Not having `admin` and `data` clients provided by the core in `clusters`
// map implicitly allows to create custom `data` and `admin` clients. This is
// allowed intentionally to support custom `admin` cluster client created by the
// x-pack/monitoring bulk uploader. We should forbid that as soon as monitoring
// bulk uploader is refactored, see https://github.com/elastic/kibana/issues/31934.
if (clusters.has(name)) {
throw new Error(`cluster '${name}' already exists`);
}

const cluster = new Cluster(
server.newPlatform.setup.core.elasticsearch.legacy.createClient(name, clientConfig)
);

clusters.set(name, cluster);

return cluster;
});

server.events.on('stop', () => {
for (const cluster of clusters.values()) {
cluster.close();
Expand All @@ -88,17 +67,7 @@ export default function (kibana) {
clusters.clear();
});

server.expose('handleESError', handleESError);

createProxy(server);

const waitUntilHealthy = versionHealthCheck(
this,
server.logWithMetadata,
server.newPlatform.__internals.elasticsearch.esNodesCompatibility$
);

server.expose('waitUntilReady', () => waitUntilHealthy);
},
});
}

This file was deleted.

This file was deleted.

50 changes: 0 additions & 50 deletions src/legacy/core_plugins/elasticsearch/lib/handle_es_error.js

This file was deleted.

39 changes: 0 additions & 39 deletions src/legacy/core_plugins/elasticsearch/lib/version_health_check.js

This file was deleted.

Loading