Skip to content

Commit

Permalink
Legacy ES plugin pre-removal cleanup (#75779)
Browse files Browse the repository at this point in the history
* delete integration tests

* remove legacy version healthcheck / waitUntilReady

* remove handleESError

* remove createCluster

* no longer depends on kibana plugin

* fix kbn_server

* remove deprecated comment and dead code

* revert code removal, apparently was used (?)

* Revert "revert code removal, apparently was used (?)"

This reverts commit 6948185
  • Loading branch information
pgayvallet authored Aug 26, 2020
1 parent 35b8d50 commit d2d7b0d
Show file tree
Hide file tree
Showing 10 changed files with 3 additions and 376 deletions.
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 './server/lib/cluster';
import { createProxy } from './server/lib/create_proxy';
import { handleESError } from './server/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.

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

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit d2d7b0d

Please sign in to comment.