-
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 change to snapshot name / repository for managed SLM policies #172291
Conversation
Pinging @elastic/platform-deployment-management (Team:Deployment Management) |
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.
Thanks a lot for raising a PR for this issue, @renshuki!
Even though the proposed change is straight forward, I think there are still some things to discuss:
- It looks like changing managed repos/policies on Cloud can lead to serious issues for the deployment. Should we consider first disabling the changes on the ES/Control plane side? Even with some UI elements disabled for managed policies, users will still be able to change the repo/policy via Console for example.
- The issue links to the docs that warns the user of changing the repo
found-snapshots
and the policycloud-snapshot-policy
. So should we only disable editing for those items specifically or do we want to rely on themanaged: true
property? - Instead of disabling snapshot name and repo in the policy edit form, should we consider disabling the edit form all together?
- Should we also consider similar changes for the repo
found-snapshots
?
Let me know what you think @renshuki, also tagging @alisonelizabeth and @sixstringcode for their input.
@yuliacech thank you for raising these questions.
Correct, that why I wanted to implement this change primarily.
You are right, some server side validation / limit the scope of editable fields for managed SLM policies via API would be worth discussing with ES / Control Plane.
I'm not aware of any other Elastic product defining a managed SLM policy other than Cloud. Also, I don't see a scenario where the snapshot name or repository for a managed SLM policy need to be configurable by the end user. That's why I kept this "generic" approach with
No, the reason is that users should still have the possibility to customize the
I agree, for managed Repositories, preventing changes to My thought was that disabling fields in the UI would be "good enough" to mitigate most user errors with little time investment. |
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.
Thanks a lot for providing the context, @renshuki!
Would you be able to start the conversation about limiting changes on the backend with the ES and the Control plane teams please? I don't think our team has enough details to do that. Also could you please open an issue about similar UI work needed for the repository edit form?
To get this PR merged, we need to add some integration tests, there is an example here, the mock policy would need to be a managed policy. If that is difficult, let me know and I could add the tests directly to your branch.
Thank you @renshuki and @yuliacech for the discussion on this. I agree with Yulia that it would be preferred to enforce this at the API layer rather than only putting in controls on the client side. @renshuki please let us know if you are able to start a conversation around that. I'm OK to proceed with this as a partial fix for now, as this appears to be causing a number of customer issues.
++ please let us know if you need help here |
.../plugins/snapshot_restore/public/application/components/policy_form/steps/step_logistics.tsx
Show resolved
Hide resolved
Thank you @yuliacech, @alisonelizabeth for your comments / feedback.
|
@yuliacech sorry, I need some guidance for the integration tests. I'm wondering if we want to keep it simple by modifying the the current mock policy like adding kibana/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/constant.ts Lines 18 to 22 in 8e33d5d
and then add some tests in test('should disable the snapshot name field for managed policy', () => {
const { find } = testBed;
const snapshotNameInput = find('snapshotNameInput');
expect(snapshotNameInput.props().disabled).toEqual(true);
});
test('should disable the respository select field for managed policy', () => {
const { find } = testBed;
const repositorySelect = find('repositorySelect');
expect(repositorySelect.props().disabled).toEqual(true);
}); or should we treat |
Here is the code suggestion test('should disable the repo and snapshot fields for managed policies', async () => {
httpRequestsMockHelpers.setGetPolicyResponse(POLICY_EDIT.name, {
policy: {
...POLICY_EDIT,
isManagedPolicy: true,
},
});
await act(async () => {
testBed = await setup(httpSetup);
});
testBed.component.update();
const { find } = testBed;
const snapshotInput = find('snapshotNameInput');
expect(snapshotInput.props().disabled).toEqual(true);
const repoSelect = find('repositorySelect');
expect(repoSelect.props().disabled).toEqual(true);
}); |
Thank you @yuliacech for the code suggestion 😃 Please, feel free to push it to the |
Thanks @renshuki! I pushed a commit with the test and with this, I'm good with merging this PR if you want to add the tooltip in a separate PR. |
LGTM @yuliacech, please feel free to merge. I opened #173124 separetely for the tooltips. I assigned it to me and will do the implementation in a different PR. To circle back around the discussion with Elasticsearch / Control Plane to restrict APIs, they want to "keep an escape hatch for unforeseen situations where they must be changed" - but they may reconsider in the future: |
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: |
Summary
Managed SLM policies
Snapshot name
andRepository
field values can be changed from the Snapshot and Restore UI. This is particularly an issue with thecloud-snapshot-policy
as changes to the snapshot name or target repository will lead to plan failures on ESS. Besides having a warning message displayed for managed SLM policies:This PR disable the
Snapshot name
andRepository
field for managed SLM policies to prevent edits.Example - Regular SLM policy:
Example - Managed SLM policy:
I'm open to suggestions if there is a better way to do this.
This PR fixes #124916
Checklist
For maintainers
Release Note
Input fields to change snapshot name and repository are now disabled when editing managed SLM policies in Snapshot & Restore.