-
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
[Enterprise Search] Log retention settings logic #82364
Conversation
030fe3c
to
c10a574
Compare
c10a574
to
61efb99
Compare
Note that I changd it to set logsRetentionUpdating to false instead of null so that our types were correct
bc24dd5
to
701951d
Compare
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.
This looks amazing!! I have a spicy proposal for you but I should hopefully have done most of the legwork on it (first comment). Would love to hear your thoughts!
ILogRetentionSettings, | ||
} from '../types'; | ||
|
||
export const convertLogRetentionFromServerToClient = ( |
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 think we have a really unique opportunity in Kibana to clean up a lot of these ServerToClient
transforms/conversions by handling them in our server
/API code rather than our public
/client-side code. We do something very similar already in our internal client API call, for example.
I played around with this a bit and have a working diff for you:
JasonStoltz/kibana@log-retention-logic...constancecchen:server-json-transform
Here's some screenshots of the final API output coming from Kibana:
Would really love to hear what you think! Personally, I think it really helps separate concerns quite a bit.
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.
In any other system, I would be in favor of moving stuff like this to the server.
In the case of Kibana, I am not in favor of it. I am strongly in favor of keeping our Kibana server API as thin as possible as primarily as pass through to Enterprise Search. It feels like we're monkey patching the Enterprise Search API rather than fixing it at its source.
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.
It feels like we're monkey patching the Enterprise Search API rather than fixing it at its source.
Yes, but we're doing that anyway with these ServerToClient
utilities. I'm simply proposing moving the currently existing logic to the server/
folder.
I am strongly in favor of keeping our Kibana server API as thin as possible as primarily as pass through to Enterprise Search.
I don't particularly see why our server API needs to be this way. This is also still a relatively thin action, IMO. I'm not sure what advantage we gain with that mindset and I think being overly prescriptive about what we do in our server/
code is a wasted opportunity for cleanup / giving more freedom & control to our front-end devs.
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 don't particularly see why our server API needs to be this way. This is also still a relatively thin action, IMO. I'm not sure what advantage we gain with that mindset and I think being overly prescriptive about what we do in our server/ code is a wasted opportunity for cleanup / giving more freedom & control to our front-end devs.
It's just one less place we have to look for logic. One less architectural piece to account for.
Also, if we just keep things as is, it makes it easier to just port code over from the old repository. This is one more step for porting views that we could easily cut out.
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.
It's just one less place we have to look for logic. One less architectural piece to account for.
I'm not sold by that argument because convertLogRetentionFromServerToClient
is also one more place we have to look for logic for. I had to open the util file and figure out what exactly the code was doing, etc.
If the concern is that it's a pretty disparate location, I also think there's a danger in that. I really don't think we should treat the server/
folder as something to not look at or stay away from - it's integral for telemetry, for one - and I definitely don't want to be the only dev with familiarity with the code there. In general, I don't think there's any code or area where we should just say "Oh, we don't have to bother looking deeply here".
Also, if we just keep things as is, it makes it easier to just port code over from the old repository. This is one more step for porting views that we could easily cut out.
Definitely a fair argument - for what it's worth I just did a quick grep in ent-search and it looks like these transforms are pretty recent and only occur here (LogRetention) and in the new Crawler folder (and that's something I'd be happy to chat w/ Byron about soon).
With that small scope in mind I think this is worth making this refactor now - it sets up a pattern and precedent that we can use in the future but don't have to. I'm definitely not saying we should go into any of the existing API endpoints or logic files and try to fix all our various inconsistent casing during the migration, but that this allows us to do so after/as a piece of tech debt if we chose to.
I'm also primarily making this proposal now because of the existing convertServerToClient
that I think fits perfectly in server/
- if this utility hadn't been here and the existing logic had just dealt with snake_cased json as-is, I wouldn't have proposed this / would have been fine to leave it as-is.
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.
Why not make this change at the source then, in ent-search?
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.
Nevermind, I don't think it's a big concern either way, and it's a cool proposal. Could you please make it a separate PR though, after this is merged?
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'm definitely good with this being separate, and after some thought I'd be fine leaving this off as post-migration tech debt if we'd rather stay focused for now.
Why not make this change at the source then, in ent-search?
That's a good question - the only potential problem I can think of is one we might potentially see as more users move to Kibana: what happens when ent-search and kibana versions are out of sync (e.g. a user upgrades ent-search but not kibana)? Kibana will now start looking for JSON data/keys that don't exist or have changed, and we'll start seeing more bugs/errors as a result.
I'm slightly more inclined to prefer making small changes like casing transforms in the Kibana side as a result (less potential for product mismatch) and keep ent-search more stable.
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.
Great point, thanks 👍
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.
heavy 👍 for leaving this off as post-migration tech debt
...lic/applications/app_search/components/settings/log_retention/utils/convert_log_retention.ts
Outdated
Show resolved
Hide resolved
...arch/public/applications/app_search/components/settings/log_retention/log_retention_logic.ts
Outdated
Show resolved
Hide resolved
...arch/public/applications/app_search/components/settings/log_retention/log_retention_logic.ts
Show resolved
Hide resolved
...arch/public/applications/app_search/components/settings/log_retention/log_retention_logic.ts
Outdated
Show resolved
Hide resolved
...public/applications/app_search/components/settings/log_retention/log_retention_logic.test.ts
Outdated
Show resolved
Hide resolved
...public/applications/app_search/components/settings/log_retention/log_retention_logic.test.ts
Outdated
Show resolved
Hide resolved
...public/applications/app_search/components/settings/log_retention/log_retention_logic.test.ts
Outdated
Show resolved
Hide resolved
logRetention: ILogRetention | null; | ||
logsRetentionUpdating: boolean; | ||
openModal: ELogRetentionOptions | null; |
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.
[Feel free to disregard this comment totally, just me thinking out loud] This isn't worth the time to change now I think, but if this were new code from scratch I'd probably make the comment the values were a little hard to read/understand the meaning of at a glance.
logsRetentionUpdating
would be nice to be update to a bool naming convention, e.g. something like isUpdating
(it's fine to be a little generic IMO because the context comes from where we're pulling the value from).
openModal
confused me a bit without context because it reads either as an action or possibly a bool. I think it could be clarified to something like currentModalOption
maybe?
OK sorry rambling is over now haha
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.
Stuff like this is easy to change now and virtually risk free. It's not changing the code flow in any significant way, it's just renaming things.
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.
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.
Hm, openedModal
still reads as a potential bool to me (I know it doesn't have an is/has prefix, but we're not yet consistent w/ that naming in our codebase). I really think something like modalContent
or modalOption
makes it clearer that the variable being set is a string/piece of copy rather than an open/close flag. But that's definitely not a blocker, so feel free to merge as-is
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.
Yeah I see your point. It's interesting because it needs to signal that the modal is opened, and also which option it is opened for.
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.
Maybe I'll try to switch it in my next PR to modalOption
, so I don't have to wait for CI again.
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.
Oh wait. So it is a flag for when the modal is opened? Am I just confused? If so, disregard me totally :dead_inside:
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.
It's like:
when openedModal
is null
modal is closed
is 'api'
modal is opened for editing the 'api' option
is 'analytics'
modal is opened for editing the 'analytics' option
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.
🙈 Ahh gotcha! I would personally find super helpful for dev readability to pull out a selector called isModalOpen
that changes to true/false based on modalOption
, and use that instead of a null/string var. It's really minor but I think it helps, and hey, vars are cheap!
...public/applications/app_search/components/settings/log_retention/log_retention_logic.test.ts
Outdated
Show resolved
Hide resolved
This is always complete. When it's returned from the server, it is fully formed, with all options available. We don't need to make the properties optional.
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.
Super appreciate the changes, they look great - the comments I just made are non blocking - feel free to merge at will
@elasticmachine merge upstream |
@elasticmachine merge upstream |
💚 Build SucceededMetrics [docs]
History
To update your PR or re-run it, just comment with: |
Summary
This PR migrates the Logic required for the Log Retention Settings from the old Enterprise Search front-end to Kibana.
This PR is put together in a sequence of commits that each add a single logic action. It is best reviewed commit by commit.
Checklist
Delete any items that are not applicable to this PR.
For maintainers