Skip to content

Conversation

@alisonelizabeth
Copy link
Contributor

@alisonelizabeth alisonelizabeth commented Sep 9, 2019

This PR adds the ability to configure snapshot retention as part of the create policy wizard.

I considered integrating the form lib into this, but ultimately decided it would be better addressed in a separate PR (if we decide to do it), as it would involve refactoring the existing code.

I am also still working with Gail on the copy, so there will likely be some text changes to come.

Release notes

This feature adds the ability to configure snapshot retention when creating a Snapshot Lifecycle Management policy within the Snapshot and Restore app. If a policy has retention configured, users have the ability to update the slm.retention_schedule cluster setting through the UI. Policy statistics were also added to the policy details panel.

Testing locally

  • You will need to create a repository first, before creating a policy. For a shared filesystem repo, you need to specify a path.repo in ES. For example:

    yarn es snapshot -E path.repo=/tmp/es-backups

  • For more information, see the SR docs.

Screenshots

Policy tab

If a policy with retention exists, but the slm.retention_schedule cluster setting has not be set, a callout will display.

Screen Shot 2019-09-27 at 9 41 08 AM

A user has the ability to edit the slm.retention_schedule cluster setting if they have policies with retention.

Screen Shot 2019-09-27 at 9 41 40 AM

The slm.retention_schedule cluster setting panel will not render, if there are no policies configured with retention.

Screen Shot 2019-09-27 at 9 49 37 AM

Retention schedule modal (supports simple and advanced cron editor)

Screen Shot 2019-09-27 at 9 41 18 AM Screen Shot 2019-09-27 at 9 41 26 AM
Snapshot retention step Screen Shot 2019-09-27 at 9 40 37 AM

Validation
Screen Shot 2019-09-27 at 9 54 12 AM

Review step Added retention to summary and request tabs Screen Shot 2019-09-27 at 9 40 05 AM Screen Shot 2019-09-27 at 9 40 13 AM
Details panel Added policy stats and retention details (if configured) Screen Shot 2019-09-27 at 9 41 56 AM

@alisonelizabeth alisonelizabeth added release_note:enhancement v8.0.0 Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more t// Feature:Snapshot and Restore Elasticsearch snapshots and repositories UI v7.5.0 labels Sep 9, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/es-ui

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@elasticmachine
Copy link
Contributor

💔 Build Failed

@alisonelizabeth
Copy link
Contributor Author

@elasticmachine merge upstream

@cuff-links cuff-links self-requested a review September 30, 2019 19:33
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@cuff-links
Copy link
Contributor

Looking at the tests now.

Copy link
Contributor

@cuff-links cuff-links left a comment

Choose a reason for hiding this comment

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

I ran the tests locally. They work. I had some comments/nits but they aren't enough to block the PR on. Good Job.

Copy link
Member

@Bamieh Bamieh left a comment

Choose a reason for hiding this comment

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

I've left a few comments for i18n related things. Thank you

@alisonelizabeth
Copy link
Contributor Author

@Bamieh thanks for the review! I believe I addressed all of the issues you found with ids, and responded to your other comments.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Member

@Bamieh Bamieh left a comment

Choose a reason for hiding this comment

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

i18n LGTM!

Copy link
Contributor

@jloleysens jloleysens left a comment

Choose a reason for hiding this comment

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

This looks really great @alisonelizabeth ! I read through the code and will do a manual test before submitting my final review, but wanted to submit these comments so long. There is nothing I could identify as a major blocker so these are mostly suggestions and questions.


export const deserializeTime = (time: string) => {
const timeUnits = Object.values(TIME_UNITS);
const timeChars = time.split('');
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't think this .split is necessary. String.prototype has a an indexOf method:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf


{/** Expiration field */}
{renderExpireAfterField()}
{/** Retention count fields */}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I'd say the code is self-documented in this case 😃

</EuiFlexItem>
</EuiFlexGroup>

{/* Retention summary */}
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for this comment! 👍


type OnSuccessCallback = () => void;

export const PolicyUpdateRetentionProvider: React.FunctionComponent<Props> = ({ children }) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: Maybe this could be PolicyRetentionModalProvider? Just think having ModalProvider in the name would good. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point, changed to UpdateRetentionModalProvider

});
}

public getTimeUnitLabel(timeUnit = TIME_UNITS.SECOND, timeValue = '0') {
Copy link
Contributor

Choose a reason for hiding this comment

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

Will we ever call just getTimeUnitLabel() and have a label 0 seconds? Just wondering whether the defaults are meaningful here and if we shouldn't require these values to be provided by consumers of this service.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point, fixed


if (
retention &&
retention.minCount &&
Copy link
Contributor

Choose a reason for hiding this comment

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

Can minCount or maxCount ever be 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, it must be at least 1


// We need to skip the tests until react 16.9.0 is released
// which supports asynchronous code inside act()
describe.skip('<PolicyAdd />', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to clarify, none of the tests are currently running in CI - are we manually testing for now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that's correct. we can remove the skip once we upgrade to react 16.9.0.

@alisonelizabeth
Copy link
Contributor Author

@jloleysens thanks for the initial review! I believe I addressed all of your comments.

Copy link
Contributor

@jloleysens jloleysens left a comment

Choose a reason for hiding this comment

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

@alisonelizabeth

Great work, looks good! Summary of manual testing. Once again now major issues encountered:

Small note: The linked cron schedule docs go here: https://www.elastic.co/guide/en/elastic-stack-overview/master/trigger-schedule.html#schedule-cron which looks like it's been moved :c but you can still get there.

@elasticmachine
Copy link
Contributor

💔 Build Failed

@alisonelizabeth
Copy link
Contributor Author

Thanks @jloleysens! Great catch on the docs link. I updated it to the correct link.

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@alisonelizabeth alisonelizabeth merged commit e81494f into elastic:master Oct 2, 2019
@alisonelizabeth alisonelizabeth deleted the feature/slm-retention branch October 2, 2019 18:06
alisonelizabeth added a commit that referenced this pull request Oct 2, 2019
@mvenukadasula
Copy link

@alisonelizabeth Is this the right place to add this comment or you want me to create new defect?

Snapshot retention policy defined from Kibana UI is not working as expected. Snapshots are not getting purged though retention policy expired. Tested for 1 hour and 1 day.

@alisonelizabeth
Copy link
Contributor Author

alisonelizabeth commented May 15, 2020

Hi @uvenukadasula! Can you please open a "Bug report" issue in the Kibana repo here and provide steps to reproduce? Thanks!

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 release_note:enhancement Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more t// v7.5.0 v8.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants