Skip to content
This repository has been archived by the owner on Mar 31, 2024. It is now read-only.

Commit

Permalink
Revert "Unrevert "Migrations v2: don't auto-create indices + FTR/esAr…
Browse files Browse the repository at this point in the history
…chiver support (elastic#85778)" (elastic#89992)"

This reverts commit fd1d965.
  • Loading branch information
spalger committed Feb 13, 2021
1 parent 874fadf commit 4567940
Show file tree
Hide file tree
Showing 74 changed files with 324 additions and 709 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export declare class SavedObjectsErrorHelpers
| [createBadRequestError(reason)](./kibana-plugin-core-server.savedobjectserrorhelpers.createbadrequesterror.md) | <code>static</code> | |
| [createConflictError(type, id, reason)](./kibana-plugin-core-server.savedobjectserrorhelpers.createconflicterror.md) | <code>static</code> | |
| [createGenericNotFoundError(type, id)](./kibana-plugin-core-server.savedobjectserrorhelpers.creategenericnotfounderror.md) | <code>static</code> | |
| [createIndexAliasNotFoundError(alias)](./kibana-plugin-core-server.savedobjectserrorhelpers.createindexaliasnotfounderror.md) | <code>static</code> | |
| [createInvalidVersionError(versionInput)](./kibana-plugin-core-server.savedobjectserrorhelpers.createinvalidversionerror.md) | <code>static</code> | |
| [createTooManyRequestsError(type, id)](./kibana-plugin-core-server.savedobjectserrorhelpers.createtoomanyrequestserror.md) | <code>static</code> | |
| [createUnsupportedTypeError(type)](./kibana-plugin-core-server.savedobjectserrorhelpers.createunsupportedtypeerror.md) | <code>static</code> | |
Expand All @@ -28,7 +27,6 @@ export declare class SavedObjectsErrorHelpers
| [decorateEsUnavailableError(error, reason)](./kibana-plugin-core-server.savedobjectserrorhelpers.decorateesunavailableerror.md) | <code>static</code> | |
| [decorateForbiddenError(error, reason)](./kibana-plugin-core-server.savedobjectserrorhelpers.decorateforbiddenerror.md) | <code>static</code> | |
| [decorateGeneralError(error, reason)](./kibana-plugin-core-server.savedobjectserrorhelpers.decorategeneralerror.md) | <code>static</code> | |
| [decorateIndexAliasNotFoundError(error, alias)](./kibana-plugin-core-server.savedobjectserrorhelpers.decorateindexaliasnotfounderror.md) | <code>static</code> | |
| [decorateNotAuthorizedError(error, reason)](./kibana-plugin-core-server.savedobjectserrorhelpers.decoratenotauthorizederror.md) | <code>static</code> | |
| [decorateRequestEntityTooLargeError(error, reason)](./kibana-plugin-core-server.savedobjectserrorhelpers.decoraterequestentitytoolargeerror.md) | <code>static</code> | |
| [decorateTooManyRequestsError(error, reason)](./kibana-plugin-core-server.savedobjectserrorhelpers.decoratetoomanyrequestserror.md) | <code>static</code> | |
Expand All @@ -37,7 +35,6 @@ export declare class SavedObjectsErrorHelpers
| [isEsCannotExecuteScriptError(error)](./kibana-plugin-core-server.savedobjectserrorhelpers.isescannotexecutescripterror.md) | <code>static</code> | |
| [isEsUnavailableError(error)](./kibana-plugin-core-server.savedobjectserrorhelpers.isesunavailableerror.md) | <code>static</code> | |
| [isForbiddenError(error)](./kibana-plugin-core-server.savedobjectserrorhelpers.isforbiddenerror.md) | <code>static</code> | |
| [isGeneralError(error)](./kibana-plugin-core-server.savedobjectserrorhelpers.isgeneralerror.md) | <code>static</code> | |
| [isInvalidVersionError(error)](./kibana-plugin-core-server.savedobjectserrorhelpers.isinvalidversionerror.md) | <code>static</code> | |
| [isNotAuthorizedError(error)](./kibana-plugin-core-server.savedobjectserrorhelpers.isnotauthorizederror.md) | <code>static</code> | |
| [isNotFoundError(error)](./kibana-plugin-core-server.savedobjectserrorhelpers.isnotfounderror.md) | <code>static</code> | |
Expand Down
3 changes: 1 addition & 2 deletions packages/kbn-es-archiver/src/actions/empty_kibana_index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,5 @@ export async function emptyKibanaIndexAction({

await cleanKibanaIndices({ client, stats, log, kibanaPluginIds });
await migrateKibanaIndex({ client, kbnClient });
stats.createdIndex('.kibana');
return stats.toJSON();
return stats;
}
2 changes: 1 addition & 1 deletion packages/kbn-es-archiver/src/es_archiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export class EsArchiver {
* @return Promise
*/
async emptyKibanaIndex() {
return await emptyKibanaIndexAction({
await emptyKibanaIndexAction({
client: this.client,
log: this.log,
kbnClient: this.kbnClient,
Expand Down
8 changes: 3 additions & 5 deletions packages/kbn-es-archiver/src/lib/indices/kibana_index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,7 @@ export async function migrateKibanaIndex({
*/
async function fetchKibanaIndices(client: Client) {
const resp = await client.cat.indices<unknown>({ index: '.kibana*', format: 'json' });
const isKibanaIndex = (index: string) =>
/^\.kibana(:?_\d*)?$/.test(index) ||
/^\.kibana(_task_manager)?_(pre)?\d+\.\d+\.\d+/.test(index);
const isKibanaIndex = (index: string) => /^\.kibana(:?_\d*)?$/.test(index);

if (!Array.isArray(resp.body)) {
throw new Error(`expected response to be an array ${inspect(resp.body)}`);
Expand Down Expand Up @@ -117,7 +115,7 @@ export async function cleanKibanaIndices({
while (true) {
const resp = await client.deleteByQuery(
{
index: `.kibana,.kibana_task_manager`,
index: `.kibana`,
body: {
query: {
bool: {
Expand All @@ -131,7 +129,7 @@ export async function cleanKibanaIndices({
},
},
{
ignore: [404, 409],
ignore: [409],
}
);

Expand Down
19 changes: 4 additions & 15 deletions src/core/server/saved_objects/migrationsv2/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,23 +150,12 @@ export const removeWriteBlock = (
.catch(catchRetryableEsClientErrors);
};

/**
* A yellow index status means the index's primary shard is allocated and the
* index is ready for searching/indexing documents, but ES wasn't able to
* allocate the replicas. When migrations proceed with a yellow index it means
* we don't have as much data-redundancy as we could have, but waiting for
* replicas would mean that v2 migrations fail where v1 migrations would have
* succeeded. It doesn't feel like it's Kibana's job to force users to keep
* their clusters green and even if it's green when we migrate it can turn
* yellow at any point in the future. So ultimately data-redundancy is up to
* users to maintain.
*/
const waitForIndexStatusYellow = (
const waitForIndexStatusGreen = (
client: ElasticsearchClient,
index: string
): TaskEither.TaskEither<RetryableEsClientError, {}> => () => {
return client.cluster
.health({ index, wait_for_status: 'yellow', timeout: '30s' })
.health({ index, wait_for_status: 'green', timeout: '30s' })
.then(() => {
return Either.right({});
})
Expand Down Expand Up @@ -270,7 +259,7 @@ export const cloneIndex = (
} else {
// Otherwise, wait until the target index has a 'green' status.
return pipe(
waitForIndexStatusYellow(client, target),
waitForIndexStatusGreen(client, target),
TaskEither.map((value) => {
/** When the index status is 'green' we know that all shards were started */
return { acknowledged: true, shardsAcknowledged: true };
Expand Down Expand Up @@ -698,7 +687,7 @@ export const createIndex = (
} else {
// Otherwise, wait until the target index has a 'green' status.
return pipe(
waitForIndexStatusYellow(client, indexName),
waitForIndexStatusGreen(client, indexName),
TaskEither.map(() => {
/** When the index status is 'green' we know that all shards were started */
return 'create_index_succeeded';
Expand Down
Loading

0 comments on commit 4567940

Please sign in to comment.