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

[ML] Transforms: Add ability to delete dest index & index pattern when deleting transform job #67922

Merged
merged 19 commits into from
Jun 10, 2020

Conversation

qn895
Copy link
Member

@qn895 qn895 commented Jun 2, 2020

This PR adds the option to delete destination index & index pattern when deleting transform job(s) in two scenarios: single delete vs bulk delete.

When we are deleting transforms in bulk:

Delete message
Screen Shot 2020-06-03 at 10 01 38 PM

Delete toast messages when all tasks succeed (in this case one transform job didn't have any index pattern)
Screen Shot 2020-06-02 at 3 35 27 PM

Delete toast messages when some tasks failed
Screen Shot 2020-06-03 at 9 08 12 PM

When we are deleting just one transform job individually:

  • UI checks if user has permission to delete that individual index, shows the option if user has permission, and enables the option by default.
  • UI checks if there's an index pattern that exists with the same name as the destination index, shows the option if user has permission and index pattern does exists, and enables the option by default.

Screen Shot 2020-06-02 at 12 12 47 AM

Screen Shot 2020-06-02 at 12 12 40 AM

  • Toast messages

If all operations succeed
Screen Shot 2020-06-02 at 12 15 57 AM

If one of the tasks failed
Screen Shot 2020-06-03 at 10 09 36 PM

## Original discussion
When we are deleting in bulk:
<img width="493" alt="Screen Shot 2020-06-01 at 10 53 39 PM" src="https://user-images.githubusercontent.com/43350163/83482735-a5975800-a466-11ea-85c7-f3af5ca0f04a.png">

1) Should we assume user has permission to delete all the indices selected?

2) Should option to delete index pattern be visible and enabled? If one job might have index pattern but 2 other jobs might not.

3) Should we show success/error message for each individual job and operation or should we combine them to prevent toast message overload?

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@peteharverson
Copy link
Contributor

My thoughts on the three questions you asked @qn895 :

Should we assume user has permission to delete all the indices selected?

As long as the user has permission to delete one of the indexes, I would show the 'Delete destination index` option in the modal. I would keep the permission checks on the client-side to a minimum, and then do the full permission checks in the server-side endpoint for each destination index, returning an error to display in a toast for each index the user doesn't have permission to delete.

Should option to delete index pattern be visible and enabled? If one job might have index pattern but 2 other jobs might not.

I think we should show the Delete destination index patterns option as long as any one of the destination indexes has an index pattern.

Should we show success/error message for each individual job and operation or should we combine them to prevent toast message overload?

For the bulk delete, I think it would be best to just show one success message for each operation i.e. one toast for the transform, one for the destination index, and one for the index pattern delete. So if you delete 5 transforms, you only get 3 toasts. But for error messages, I would show a toast for each individual transform / operation that has failed.

For bulk delete, the text I would use for the options in the modal are Delete destination indexes and Delete destination index patterns.

@qn895 qn895 self-assigned this Jun 4, 2020
@qn895 qn895 requested a review from walterra June 4, 2020 04:37
@qn895 qn895 changed the title WIP: Add ability to delete dest index & index pattern when deleting transform job [Transform] Add ability to delete dest index & index pattern when deleting transform job Jun 4, 2020
@qn895 qn895 marked this pull request as ready for review June 4, 2020 04:39
@qn895 qn895 requested a review from a team as a code owner June 4, 2020 04:39
@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)

x-pack/test/functional/services/transform/api.ts Outdated Show resolved Hide resolved
x-pack/test/functional/services/transform/api.ts Outdated Show resolved Hide resolved
x-pack/test/functional/services/transform/api.ts Outdated Show resolved Hide resolved
x-pack/test/functional/services/transform/api.ts Outdated Show resolved Hide resolved
x-pack/test/functional/services/transform/api.ts Outdated Show resolved Hide resolved
@walterra walterra changed the title [Transform] Add ability to delete dest index & index pattern when deleting transform job [ML] Transforms: Add ability to delete dest index & index pattern when deleting transform job Jun 4, 2020
Copy link
Contributor

@walterra walterra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job overall, and great to have some integration tests! Added a few comments/questions.

Copy link
Contributor

@peteharverson peteharverson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some minor comments about labelling. Tested and functionally all looks good.

Comment on lines 133 to 176
const deleteModalContent = (
<>
<p>
<FormattedMessage
id="xpack.transform.transformList.deleteModalBody"
defaultMessage="Are you sure you want to delete this transform?"
/>
</p>
<EuiFlexGroup direction="column" gutterSize="none">
<EuiFlexItem>
{userCanDeleteIndex && (
<EuiSwitch
data-test-subj="transformDeleteIndexSwitch"
style={{ paddingBottom: 10 }}
label={i18n.translate(
'xpack.transform.actionDeleteTransform.deleteDestinationIndexTitle',
{
defaultMessage: 'Delete destination index {destinationIndex}',
values: { destinationIndex: items[0] && items[0].config.dest.index },
}
)}
checked={deleteDestIndex}
onChange={toggleDeleteIndex}
/>
)}
</EuiFlexItem>
<EuiFlexItem>
{userCanDeleteIndex && indexPatternExists && (
<EuiSwitch
data-test-subj="transformDeleteIndexPatternSwitch"
label={i18n.translate(
'xpack.transform.actionDeleteTransform.deleteDestIndexPatternTitle',
{
defaultMessage: 'Delete index pattern {destinationIndex}',
values: { destinationIndex: items[0] && items[0].config.dest.index },
}
)}
checked={deleteIndexPattern}
onChange={toggleDeleteIndexPattern}
/>
)}
</EuiFlexItem>
</EuiFlexGroup>
</>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this block looks the same expect i18n strings are different. I'd prefer to have only one and just have conditional rendering of the labels.

) {
const response = await savedObjectsClient.find<IIndexPattern>({
type: 'index-pattern',
perPage: 10,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it require 10 results per page?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in def2ccf

Copy link
Contributor

@walterra walterra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Latest changes LGTM.

qn895 added 2 commits June 9, 2020 08:40
…index-when-del-job

# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
Copy link
Member

@pheyos pheyos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functional tests LGTM

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Copy link
Contributor

@darnautov darnautov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@qn895 qn895 merged commit 9bc0936 into elastic:master Jun 10, 2020
@qn895 qn895 deleted the transform-delete-index-when-del-job branch June 10, 2020 15:11
qn895 added a commit to qn895/kibana that referenced this pull request Jun 10, 2020
qn895 added a commit that referenced this pull request Jun 10, 2020
…tern when deleting transform job (#67922)"

This reverts commit 9bc0936.
@tylersmalley
Copy link
Contributor

A reference to the removed file was added in https://github.com/elastic/kibana/pull/68462/files#diff-0b479419da389da8e3bf4ee485c9fe25R24 which was merged after this PR went green. This resulted in CI master failing. This PR was reverted to unblock downstream teams and can be re-opened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants