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

[ILM] Absolute to relative time conversion #87822

Merged

Conversation

jloleysens
Copy link
Contributor

@jloleysens jloleysens commented Jan 11, 2021

Summary

Added lib logic for converting an ILM policy's minimum age timings to relative time. For example:

// policy
{
  hot: { min_age: '0ms' },
  warm: { min_age: '2d' },
  cold: { min_age: '15d' },
  delete: { min_age: '1M' },
}
// =>
{
  total: 'At least 30 days', // This copy is intended to be visible to users
  hot: 'At least 2 days',
  warm: 'At least 13 days',
  cold: 'At least 17 days',,
}

Additionally, the lib code includes a function for returning these values in their millisecond form, see the test coverage for examples of how the returned values look.

How to review

The code added is just lib code, it is not consumed anywhere except for the accompanying tests. These should be read and expanded in the review to make sure that we are correctly handling absolute time conversion to relative time conversion.

The goal of this code is to give users an understanding of how long their data will be in any given phase, and by extension any given data tier.

The assumption was made to always use "day" as the unit of time for this output to simplify the copy and create uniformity in the information being conveyed.

Note

Also removed some unused, legacy logic and types in 9dfe2fc

Checklist

Delete any items that are not applicable to this PR.

@jloleysens jloleysens added Feature:ILM 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 v7.12.0 labels Jan 11, 2021
@jloleysens jloleysens requested a review from yuliacech January 11, 2021 12:25
@jloleysens jloleysens requested a review from a team as a code owner January 11, 2021 12:25
@elasticmachine
Copy link
Contributor

Pinging @elastic/es-ui (Team:Elasticsearch UI)

@jloleysens
Copy link
Contributor Author

@elasticmachine merge upstream

Copy link
Contributor

@yuliacech yuliacech left a comment

Choose a reason for hiding this comment

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

Hi @jloleysens , thanks a lot for working on this conversion! I appreciate addition of tests and build-in i18n support, however I think having this lib function return durations in days (Infinity for forever, fractions for less than a day) would be easier for UI integration than i18n strings. For example, change color and icon of phase duration bottom block if duration < Infinity

@jloleysens
Copy link
Contributor Author

@elasticmachine merge upstream

@jloleysens
Copy link
Contributor Author

jloleysens commented Jan 13, 2021

Thanks for the review @yuliacech , I've changed the lib to also export another function that returns the millisecond values per phase. This is definitely something that will be useful for the timeline component and possibly in other places too!

I also expanded the test coverage to this new function.

Would you mind taking another look when you get a chance? See 5158ae9.

@jloleysens
Copy link
Contributor Author

@elasticmachine merge upstream

Copy link
Contributor

@yuliacech yuliacech left a comment

Choose a reason for hiding this comment

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

Thanks for working on this, @jloleysens ! Changes LGTM, left a couple of nits in comments, but nothing blocking 👍


const i18nTexts = {
forever: i18n.translate('xpack.indexLifecycleMgmt.relativeTiming.Forever', {
defaultMessage: 'Forever',
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 think we should use a lowercase 'forever' for both the label and the string itself

defaultMessage: 'Forever',
}),
lessThanADay: i18n.translate('xpack.indexLifecycleMgmt.relativeTiming.lessThanADay', {
defaultMessage: 'Less than a day',
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: same, maybe use 'less than a day' (because it will probably be used as part of a sentence and can be text transformed if needed)

@jloleysens jloleysens mentioned this pull request Jan 15, 2021
5 tasks
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
indexLifecycleManagement 251.6KB 251.2KB -431.0B

History

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

@jloleysens jloleysens merged commit 3dcb98e into elastic:master Jan 15, 2021
@jloleysens jloleysens deleted the ilm/absolute-to-relative-time-conversion branch January 15, 2021 12:32
jloleysens added a commit to jloleysens/kibana that referenced this pull request Jan 15, 2021
* cleaning up unused types and legacy logic

* added new relative age logic with unit tests

* export the calculate relative timing function that returns millisecond values

* added exports to index.ts file

* copy update and test update

Co-authored-by: Kibana Machine <[email protected]>
jloleysens added a commit that referenced this pull request Jan 15, 2021
* cleaning up unused types and legacy logic

* added new relative age logic with unit tests

* export the calculate relative timing function that returns millisecond values

* added exports to index.ts file

* copy update and test update

Co-authored-by: Kibana Machine <[email protected]>

Co-authored-by: Kibana Machine <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:ILM release_note:skip Skip the PR/issue when compiling release notes Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more v7.12.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants