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

[SR] Prevent snapshots in Cloud-managed repository from being deleted in the UI #40104

Merged
merged 5 commits into from
Jul 2, 2019

Conversation

jen-huang
Copy link
Contributor

Relates to https://github.com/elastic/cloud/issues/34704

Summary

This PR prevents snapshots stored in the ECE/ESS-managed repository from being deleted via the UI. The reason for this is because ECE and ESS have their own snapshot retention policies. Until we have a stack SLM UI that can fully replace Cloud's current SLM UI, let's prevent users from deleting these snapshots as to not conflict with Cloud's retention policy.

This is similar to the behavior we did to prevent users from deleting the managed repository from the UI: #36947

Note that we do allow users to restore managed repository snapshots from the UI. This disabling behavior only applies to deletion.

cc @elastic/cloud-stack-n-soln

Testing instructions

  1. Add cluster.metadata.managed_repository setting via Console:
PUT /_cluster/settings
{
  "persistent": {
    "cluster.metadata.managed_repository": "found-snapshots"
  }
}
  1. Create a repository with the same name as your setting value (found-snapshots)

Note: Neither step is necessary when this goes live on Cloud, as both the repository and the setting will already exist, we are just mocking the environment locally here 🙂

Screenshots

In snapshots table, deletion is disabled (user is not able to select the row and trash can icon is disabled):

image

In snapshot details, Delete button is disabled:

image

@jen-huang jen-huang added Team:Cloud v8.0.0 Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more release_note:skip Skip the PR/issue when compiling release notes Feature:Snapshot and Restore Elasticsearch snapshots and repositories UI v7.3.0 labels Jul 1, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/es-ui

Copy link
Contributor

@cjcenizal cjcenizal left a comment

Choose a reason for hiding this comment

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

Tested locally, code LGTM! Just had a couple suggestions on copy and a comment.

'xpack.snapshotRestore.snapshotDetails.deleteManagedRepositorySnapshotButtonTitle',
{
defaultMessage:
'You cannot delete a managed repository snapshot.',
Copy link
Contributor

Choose a reason for hiding this comment

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

I defer to @gchaps on this one but I think this wording is a bit ambiguous, because it's not clear if "repository snapshot" is the object qualified by the word "managed". How about rephrasing this to "You cannot delete a snapshot stored in a managed repository."

This comment applies to similar language elsewhere in the PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 to "You cannot delete a snapshot stored in a managed repository."

callWithInternalUser: any
): Promise<string | undefined> => {
try {
const { persistent, transient, defaults } = await callWithInternalUser('cluster.getSettings', {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a comment here to help people connect the dots with the Cloud-based business logic we're supporting? Here's my suggestion.

// Cloud has its own system for managing snapshots and we want to make
// this clear when Snapshot Restore is used in a Cloud deployment.

};
return managedRepositoryName;
} catch (e) {
// Silently swallow error and return undefined
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a blocker but I'm still not quite getting this. Can you help me understand over Zoom?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if the request to get cluster settings fails for some reason, simply return undefined for managedRepositoryName. downstream logic will act as if there is no managed_repository setting, which is the behavior for a non-cloud instance such as local dev environment

Copy link
Contributor

@cjcenizal cjcenizal Jul 2, 2019

Choose a reason for hiding this comment

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

for some reason

I think that's what sets my spidey sense tingling. If an error is expected for a particular reason, then I can see swallowing it because it has some kind of meaning that we've identified as inconsequential. But if the error is unexpected then that's something I'd expect to bubble up and cause a 500. Otherwise if users are on Cloud and we get an error here, won't they be able to delete snapshots?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I view this as an extreme edge case because

  1. this is call made with callWithInternalUser (superuser), so it won't fail due to things like permissions
  2. the call is made to the cluster API /_cluster/settings, if this call fails with a superuser, I expect the user's instance is having larger problems than this UI

I don't expect the catch logic to really ever be hit for the above reasons. previously this method was not wrapped in try...catch, and any errors would prevent the downstream APIs from returning any information.

if users are on Cloud and we get an error here, won't they be able to delete snapshots?

the minimal possibility of getting an error here notwithstanding, Cloud users are able to override any UI blocks we put into place if they want to 🙂

Copy link
Contributor

Choose a reason for hiding this comment

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

Cloud users are able to override any UI blocks we put into place if they want to

You're right, I should have phrased my point better: won't the UI no longer distinguish between Cloud and non-Cloud repos/snaps? So won't the user be in a much more dangerous situation?

any errors would prevent the downstream APIs from returning any information.

I see. Do I understand the reason correctly: we've identified the information here as optional, and if this part of the handler fails then the client can still safely continue without the information this request provides. If this is the reasoning, then can we change the comment to communicate that intention, so the comment describes the "why" instead of the "what"?

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@alisonelizabeth alisonelizabeth left a comment

Choose a reason for hiding this comment

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

Tested locally, LGTM.

@elasticmachine
Copy link
Contributor

💔 Build Failed

@jen-huang
Copy link
Contributor Author

retest

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@jen-huang jen-huang merged commit 2eeea97 into elastic:master Jul 2, 2019
@jen-huang jen-huang deleted the fix/sr-cloud branch July 2, 2019 19:16
cjcenizal pushed a commit that referenced this pull request Jul 2, 2019
… in the UI (#40104) (#40200)

* Extract `getManagedRepositoryName` to `lib/`

* Prevent managed repository snapshots from being deleted in table UI

* Prevent delete of managed repository snapshot from its details UI

* Fix test

* PR feedback and empty restore tab copy edits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Snapshot and Restore Elasticsearch snapshots and repositories UI NeededFor:Cloud release_note:skip Skip the PR/issue when compiling release notes Team:Cloud Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more v7.3.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants