Skip to content

Commit

Permalink
Change some wording in shrink index page (#553)
Browse files Browse the repository at this point in the history
Signed-off-by: gaobinlong <[email protected]>

Signed-off-by: gaobinlong <[email protected]>
  • Loading branch information
gaobinlong authored Jan 9, 2023
1 parent 5b11cd7 commit dc5318e
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 71 deletions.
20 changes: 10 additions & 10 deletions public/pages/ShrinkIndex/container/ShrinkIndex/ShrinkIndex.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ describe("<Shrink index /> spec", () => {
const { queryByText, getByTestId } = renderWithRouter([`${ROUTES.SHRINK_INDEX}?source=test4`]);

await waitFor(() => {
expect(queryByText("The source index's health status is Red.")).not.toBeNull();
expect(queryByText("The source index must be in Green health status.")).not.toBeNull();
expect(getByTestId("shrinkIndexConfirmButton")).toHaveAttribute("disabled");
});
});
Expand All @@ -427,7 +427,7 @@ describe("<Shrink index /> spec", () => {
const { queryByText, getByTestId } = renderWithRouter([`${ROUTES.SHRINK_INDEX}?source=test4`]);

await waitFor(() => {
expect(queryByText("The source index has only one primary shard, you cannot shrink it anymore.")).not.toBeNull();
expect(queryByText("Cannot shrink source index with only one primary shard.")).not.toBeNull();
expect(getByTestId("shrinkIndexConfirmButton")).toHaveAttribute("disabled");
});
});
Expand Down Expand Up @@ -488,7 +488,7 @@ describe("<Shrink index /> spec", () => {
getByText("Source index details");
});

expect(queryByText("The source index's health status is Yellow!")).not.toBeNull();
expect(queryByText("We recommend shrinking index with a Green health status.")).not.toBeNull();
});

it("shows warning when source index is set to read-only", async () => {
Expand All @@ -499,7 +499,7 @@ describe("<Shrink index /> spec", () => {
getByText("Source index details");
});

expect(queryByText("The source index's setting [index.blocks.read_only] is [true]!")).not.toBeNull();
expect(queryByText("Index setting [index.blocks.read_only] is [true].")).not.toBeNull();
});

it("shows error when source index cannot be opened", async () => {
Expand Down Expand Up @@ -571,7 +571,7 @@ describe("<Shrink index /> spec", () => {
getByText("Source index details");
});

expect(queryByText("A copy of every shard in the source index may not reside on the same node.")).not.toBeNull();
expect(queryByText("A copy of every shard must reside on the same node.")).not.toBeNull();
});

it("no warning when source index is ready", async () => {
Expand All @@ -582,13 +582,13 @@ describe("<Shrink index /> spec", () => {
getByText("Configure target index");
});

expect(queryByText("The source index's health status is Red.")).toBeNull();
expect(queryByText("The source index has only one primary shard, you cannot shrink it anymore.")).toBeNull();
expect(queryByText("The source index must be in Green health status.")).toBeNull();
expect(queryByText("Cannot shrink source index with only one primary shard.")).toBeNull();
expect(queryByText("The source index must block write operations before shrinking.")).toBeNull();
expect(queryByText("The source index must be open.")).toBeNull();
expect(queryByText("The source index's health status is Yellow!")).toBeNull();
expect(queryByText("The source index's setting [index.blocks.read_only] is [true]!")).toBeNull();
expect(queryByText("A copy of every shard in the source index may not reside on the same node.")).toBeNull();
expect(queryByText("We recommend shrinking index with a Green health status.")).toBeNull();
expect(queryByText("Index setting [index.blocks.read_only] is [true].")).toBeNull();
expect(queryByText("A copy of every shard must reside on the same node.")).toBeNull();

userEvent.type(getByTestId("targetIndexNameInput"), "test3_shrunken");

Expand Down
69 changes: 29 additions & 40 deletions public/pages/ShrinkIndex/container/ShrinkIndex/ShrinkIndex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
EuiLink,
EuiSpacer,
EuiTitle,
EuiText,
EuiFormRow,
EuiLoadingSpinner,
} from "@elastic/eui";
import React, { Component } from "react";
Expand Down Expand Up @@ -193,7 +193,7 @@ export default class ShrinkIndex extends Component<ShrinkIndexProps, ShrinkIndex
if (result && result.ok) {
return result.response;
} else {
const errorMessage = `There is a problem getting index setting for ${indexName}, please check with Admin.`;
const errorMessage = `There was a problem getting index setting for ${indexName}, please check with Admin.`;
this.context.notifications.toasts.addDanger(result?.error || errorMessage);
}
} catch (err) {
Expand All @@ -219,7 +219,7 @@ export default class ShrinkIndex extends Component<ShrinkIndexProps, ShrinkIndex
if (result && result.ok) {
this.context.notifications.toasts.addSuccess(`${indexName} has been set to block write operations.`);
} else {
const errorMessage = `There is a problem set index setting for ${indexName}, please check with Admin`;
const errorMessage = `There was a problem updating index setting for ${indexName}, please check with Admin`;
this.context.notifications.toasts.addDanger(result?.error || errorMessage);
}
} catch (err) {
Expand Down Expand Up @@ -311,10 +311,10 @@ export default class ShrinkIndex extends Component<ShrinkIndexProps, ShrinkIndex
disableShrinkButton = true;
sourceIndexNotReadyToShrinkReasons.push(
<>
<EuiCallOut title="The source index's health status is Red." color="danger" iconType="alert">
<EuiCallOut title="The source index must be in Green health status." color="danger" iconType="alert">
<p>
The state of the shards in the source index are abnormal, you must check the index's health status before shrinking, and it is
recommended to shrink an index when its health status is Green.
The index is in Red health status and may be running operations in the background. We recommend to wait until the index
becomes Green to continue shrinking.
</p>
</EuiCallOut>
<EuiSpacer />
Expand All @@ -326,11 +326,7 @@ export default class ShrinkIndex extends Component<ShrinkIndexProps, ShrinkIndex
disableShrinkButton = true;
sourceIndexNotReadyToShrinkReasons.push(
<>
<EuiCallOut
title="The source index has only one primary shard, you cannot shrink it anymore."
color="danger"
iconType="alert"
></EuiCallOut>
<EuiCallOut title="Cannot shrink source index with only one primary shard." color="danger" iconType="alert"></EuiCallOut>
<EuiSpacer />
</>
);
Expand Down Expand Up @@ -397,10 +393,10 @@ export default class ShrinkIndex extends Component<ShrinkIndexProps, ShrinkIndex
if (sourceIndex.health === "yellow") {
sourceIndexNotReadyToShrinkReasons.push(
<>
<EuiCallOut title="The source index's health status is Yellow!" color="warning" iconType="help">
<EuiCallOut title="We recommend shrinking index with a Green health status." color="warning" iconType="help">
<p>
It's recommended to shrink an index when its health status is Green, because if the index's health status is Yellow, it
may cause problems when initializing the new shrunken index's shards.
The source index is in Yellow health status. To prevent issues with initializing the new shrunken index, we recommend
shrinking an index with a Green health status.
</p>
</EuiCallOut>
<EuiSpacer />
Expand All @@ -414,11 +410,11 @@ export default class ShrinkIndex extends Component<ShrinkIndexProps, ShrinkIndex
if (indexReadOnlyBlock === "true" || indexReadOnlyBlock === true) {
sourceIndexNotReadyToShrinkReasons.push(
<>
<EuiCallOut title="The source index's setting [index.blocks.read_only] is [true]!" color="warning" iconType="help">
<EuiCallOut title="Index setting [index.blocks.read_only] is [true]." color="warning" iconType="help">
<p>
When the source index's setting [index.blocks.read_only] is [true], it will be copied to the new shrunken index and then
the new shrunken index's metadata write will be blocked, this will cause the new shrunken index's shards to be unassigned,
you can set the setting to [null] or [false] in the advanced settings bellow.
Index setting [index.blocks.read_only] of the source index is [true], it will be copied to the new shrunken index and then
cause the new shrunken index's shards to be unassigned, you can set the setting to [null] or [false] in the advanced
settings bellow.
</p>
</EuiCallOut>
<EuiSpacer />
Expand Down Expand Up @@ -446,20 +442,8 @@ export default class ShrinkIndex extends Component<ShrinkIndexProps, ShrinkIndex
if (!shardsAllocatedToOneNode) {
sourceIndexNotReadyToShrinkReasons.push(
<>
<EuiCallOut
title="A copy of every shard in the source index may not reside on the same node."
color="warning"
iconType="help"
>
<p>
When shrinking an index, a copy of every shard in the index must reside on the same node, you can use the index setting
`index.routing.allocation.require._*` to relocate the copy of every shard to one node.
</p>
<p>
Ignore this warning if the copy of every shard in the source index just reside on the same node in some cases, like the
OpenSearch cluster has only one node or the cluster has two nodes and each primary shard in the source index has one
replia.
</p>
<EuiCallOut title="A copy of every shard must reside on the same node." color="warning" iconType="help">
<p>For clusters with more than one node, you must allocate a copy of every shard of the source index to the same node.</p>
</EuiCallOut>
<EuiSpacer />
</>
Expand Down Expand Up @@ -635,14 +619,19 @@ export default class ShrinkIndex extends Component<ShrinkIndexProps, ShrinkIndex
);

const subTitleText = (
<EuiText color="subdued" size="s" style={{ padding: "5px 0px" }}>
<p style={{ fontWeight: 200 }}>
Shrink an existing index into a new index with fewer primary shards.{" "}
<EuiLink href={SHRINK_DOCUMENTATION_URL} target="_blank" rel="noopener noreferrer">
Learn more.
</EuiLink>
</p>
</EuiText>
<EuiFormRow
fullWidth
helpText={
<div>
Shrink an existing index into a new index with fewer primary shards.&nbsp;
<EuiLink href={SHRINK_DOCUMENTATION_URL} target="_blank" rel="noopener noreferrer">
Learn more.
</EuiLink>
</div>
}
>
<></>
</EuiFormRow>
);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,34 @@ exports[`<Shrink index /> spec renders the component 1`] = `
Shrink index
</h1>
<div
class="euiText euiText--small"
style="padding: 5px 0px;"
class="euiFormRow euiFormRow--fullWidth"
id="some_html_id-row"
>
<div
class="euiTextColor euiTextColor--subdued"
class="euiFormRow__fieldWrapper"
>
<p
style="font-weight: 200;"
<div
class="euiFormHelpText euiFormRow__text"
id="some_html_id-help-0"
>
Shrink an existing index into a new index with fewer primary shards.
<a
class="euiLink euiLink--primary"
href="https://opensearch.org/docs/latest/api-reference/index-apis/shrink-index"
rel="noopener noreferrer"
target="_blank"
>
Learn more.
EuiIconMock
<span
class="euiScreenReaderOnly"
<div>
Shrink an existing index into a new index with fewer primary shards. 
<a
class="euiLink euiLink--primary"
href="https://opensearch.org/docs/latest/api-reference/index-apis/shrink-index"
rel="noopener noreferrer"
target="_blank"
>
(opens in a new tab or window)
</span>
</a>
</p>
Learn more.
EuiIconMock
<span
class="euiScreenReaderOnly"
>
(opens in a new tab or window)
</span>
</a>
</div>
</div>
</div>
</div>
<div
Expand Down

0 comments on commit dc5318e

Please sign in to comment.