Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
cjcenizal committed Oct 1, 2021
1 parent bcda761 commit eb5c8da
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 24 deletions.
26 changes: 17 additions & 9 deletions x-pack/plugins/upgrade_assistant/public/application/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export class ApiService {
body: {
settings: JSON.stringify(settings),
},
errorInterceptors: this.errorInterceptors,
});

return result;
Expand All @@ -126,6 +127,7 @@ export class ApiService {
path: `${API_BASE_PATH}/ml_snapshots`,
method: 'post',
body,
errorInterceptors: this.errorInterceptors,
});

return result;
Expand All @@ -135,6 +137,7 @@ export class ApiService {
const result = await this.sendRequest({
path: `${API_BASE_PATH}/ml_snapshots/${jobId}/${snapshotId}`,
method: 'delete',
errorInterceptors: this.errorInterceptors,
});

return result;
Expand All @@ -150,36 +153,41 @@ export class ApiService {
return await this.sendRequest({
path: `${API_BASE_PATH}/ml_snapshots/${jobId}/${snapshotId}`,
method: 'get',
errorInterceptors: this.errorInterceptors,
});
}

public useLoadMlUpgradeMode() {
return this.useRequest<{
mlUpgradeModeEnabled: boolean;
}>({
path: `${API_BASE_PATH}/ml_upgrade_mode`,
method: 'get',
errorInterceptors: this.errorInterceptors,
});
}

public async getReindexStatus(indexName: string) {
return await this.sendRequest({
path: `${API_BASE_PATH}/reindex/${indexName}`,
method: 'get',
errorInterceptors: this.errorInterceptors,
});
}

public async startReindexTask(indexName: string) {
return await this.sendRequest({
path: `${API_BASE_PATH}/reindex/${indexName}`,
method: 'post',
errorInterceptors: this.errorInterceptors,
});
}

public async cancelReindexTask(indexName: string) {
return await this.sendRequest({
path: `${API_BASE_PATH}/reindex/${indexName}/cancel`,
method: 'post',
});
}

public useLoadMlUpgradeMode() {
return this.useRequest<{
mlUpgradeModeEnabled: boolean;
}>({
path: `${API_BASE_PATH}/ml_upgrade_mode`,
method: 'get',
errorInterceptors: this.errorInterceptors,
});
}
}
Expand Down
26 changes: 13 additions & 13 deletions x-pack/plugins/upgrade_assistant/server/lib/es_version_precheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,24 +102,24 @@ export const esVersionCheck = async (
};

export const versionCheckHandlerWrapper =
<P, Q, B>(handler: RequestHandler<P, Q, B>, isFailure) =>
<P, Q, B>(handler: RequestHandler<P, Q, B>, /*isFailure*/) =>
async (
ctx: RequestHandlerContext,
request: KibanaRequest<P, Q, B>,
response: KibanaResponseFactory
) => {
if (isFailure) {
return response.customError({
// 426 means "Upgrade Required" and is used when semver compatibility is not met.
statusCode: 426,
body: {
message: 'There are some nodes running a different version of Elasticsearch',
attributes: {
allNodesUpgraded: false,
},
},
});
}
// if (isFailure) {
// return response.customError({
// // 426 means "Upgrade Required" and is used when semver compatibility is not met.
// statusCode: 426,
// body: {
// message: 'There are some nodes running a different version of Elasticsearch',
// attributes: {
// allNodesUpgraded: false,
// },
// },
// });
// }
const errorResponse = await esVersionCheck(ctx, response);
if (errorResponse) {
return errorResponse;
Expand Down
3 changes: 1 addition & 2 deletions x-pack/plugins/upgrade_assistant/server/routes/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ export function registerAppRoutes({
} catch (error) {
return handleEsError({ error, response });
}
},
true
}
)
);
}

0 comments on commit eb5c8da

Please sign in to comment.