-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Conversation
Pinging @elastic/es-ui |
There was a problem hiding this 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.', |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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', { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
- this is call made with
callWithInternalUser
(superuser), so it won't fail due to things like permissions - 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 🙂
There was a problem hiding this comment.
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"?
💔 Build Failed |
💚 Build Succeeded |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested locally, LGTM.
💔 Build Failed |
retest |
💚 Build Succeeded |
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
cluster.metadata.managed_repository
setting via Console: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):
In snapshot details, Delete button is disabled: