-
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
[infra] Shorten IDs for ML jobs #168234
Merged
miltonhultgren
merged 34 commits into
elastic:main
from
miltonhultgren:47477-shorten-ml-job-ids
Nov 19, 2023
Merged
[infra] Shorten IDs for ML jobs #168234
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
9714423
[infra] Shorten IDs for ML jobs (#47477)
miltonhultgren 46b2593
Merge branch 'main' into 47477-shorten-ml-job-ids
miltonhultgren 5deea41
Use uuid.v5 instead of crypto, update description of created jobs
miltonhultgren f50f6d0
Merge branch 'main' of github.com:elastic/kibana into 47477-shorten-m…
miltonhultgren a4caae4
Merge branch 'main' into 47477-shorten-ml-job-ids
miltonhultgren 000750c
Add basic tests and test helpers
miltonhultgren b91a791
Merge branch 'main' of github.com:elastic/kibana into 47477-shorten-m…
miltonhultgren dd029b6
Add more tests
miltonhultgren 1ae59e0
Merge branch 'main' of github.com:elastic/kibana into 47477-shorten-m…
miltonhultgren ae4de5a
Add more tests
miltonhultgren 5e9bacc
Merge branch 'main' of github.com:elastic/kibana into 47477-shorten-m…
miltonhultgren b646a4d
Merge branch 'main' into 47477-shorten-ml-job-ids
miltonhultgren 9c5000e
Add comment about removing dashes from UUID
miltonhultgren 341de2a
Merge branch 'main' into 47477-shorten-ml-job-ids
miltonhultgren fb4b244
Merge branch 'main' into 47477-shorten-ml-job-ids
miltonhultgren 0e38a69
Merge branch 'main' into 47477-shorten-ml-job-ids
miltonhultgren 7955b11
Merge branch 'main' into 47477-shorten-ml-job-ids
miltonhultgren 6814fb7
Merge branch 'main' into 47477-shorten-ml-job-ids
miltonhultgren c40e2d3
Merge branch 'main' into 47477-shorten-ml-job-ids
miltonhultgren bf2e37d
Merge branch 'main' into 47477-shorten-ml-job-ids
miltonhultgren 35a3a2e
Merge branch 'main' of github.com:elastic/kibana into 47477-shorten-m…
miltonhultgren afad134
Change import to refernece http_api/latest
miltonhultgren 0b4e168
Remove unnecessary useMemo calls, use previous value in state update …
miltonhultgren a6baa5a
Shuffle around null checks
miltonhultgren 4c02374
Merge branch 'main' into 47477-shorten-ml-job-ids
miltonhultgren 1e57ce5
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine f0f964f
Merge branch 'main' into 47477-shorten-ml-job-ids
miltonhultgren 6dff85c
Merge branch 'main' into 47477-shorten-ml-job-ids
miltonhultgren 359a5f0
Merge branch 'main' of github.com:elastic/kibana into 47477-shorten-m…
miltonhultgren 0d2fb43
Move tests to new location
miltonhultgren 73e6c31
Merge branch 'main' into 47477-shorten-ml-job-ids
miltonhultgren cb25844
Merge branch 'main' into 47477-shorten-ml-job-ids
miltonhultgren dc5ebb6
Merge branch 'main' into 47477-shorten-ml-job-ids
miltonhultgren 7b8ba6b
Merge branch 'main' into 47477-shorten-ml-job-ids
miltonhultgren File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
x-pack/plugins/infra/common/http_api/log_analysis/id_formats/v1/id_formats.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import * as rt from 'io-ts'; | ||
import { logEntryRateJobTypeRT, logEntryCategoriesJobTypeRT } from '../../../../log_analysis'; | ||
|
||
export const idFormatRT = rt.union([rt.literal('legacy'), rt.literal('hashed')]); | ||
export type IdFormat = rt.TypeOf<typeof idFormatRT>; | ||
|
||
const jobTypeRT = rt.union([logEntryRateJobTypeRT, logEntryCategoriesJobTypeRT]); | ||
export type JobType = rt.TypeOf<typeof jobTypeRT>; | ||
|
||
export const idFormatByJobTypeRT = rt.record(jobTypeRT, idFormatRT); | ||
export type IdFormatByJobType = rt.TypeOf<typeof idFormatByJobTypeRT>; | ||
|
||
export const LOG_ANALYSIS_GET_ID_FORMATS = '/api/infra/log_analysis/id_formats'; | ||
|
||
export const getLogAnalysisIdFormatsRequestPayloadRT = rt.type({ | ||
data: rt.type({ | ||
logViewId: rt.string, | ||
spaceId: rt.string, | ||
}), | ||
}); | ||
|
||
export type GetLogAnalysisIdFormatsRequestPayload = rt.TypeOf< | ||
typeof getLogAnalysisIdFormatsRequestPayloadRT | ||
>; | ||
|
||
export const getLogAnalysisIdFormatsSuccessResponsePayloadRT = rt.type({ | ||
data: rt.record(rt.union([logEntryRateJobTypeRT, logEntryCategoriesJobTypeRT]), idFormatRT), | ||
}); | ||
|
||
export type GetLogAnalysisIdFormatsSuccessResponsePayload = rt.TypeOf< | ||
typeof getLogAnalysisIdFormatsSuccessResponsePayloadRT | ||
>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
nit: Hardcoded IDs in the codebase are a bit of a code smell in the long run, can we just comment on what it represents and why can we keep it hardcoded? Future ourselves will thank us for this 😄
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.
The auto merge went through but to address your concern, I feel the variable name and it's usage is clear enough?
We need to generate a unique ID for each job so we use
uuid.v5
which accepts a UUID to use as the namespace for the hashing and a name unique in that namespace.