Add unused-urls-cleanup plugin#220038
Add unused-urls-cleanup plugin#220038kowalczyk-krzysztof wants to merge 1 commit intoelastic:mainfrom
Conversation
|
🤖 Jobs for this PR can be triggered through checkboxes. 🚧
ℹ️ To trigger the CI, please tick the checkbox below 👇
|
|
Closing this because this should actually live in share plugin. |
| import { DEFAULT_MAX_AGE } from '@kbn/unused-urls-cleanup/server/constants'; | ||
|
|
||
| export const configSchema = schema.object({ | ||
| maxAge: schema.string({ |
There was a problem hiding this comment.
I think there should be something like schema.duration that should do the trick
| export const TASK_ID = 'unusedUrlsCleanupTask'; | ||
| export const TASK_SCHEDULE_INTERVAL = '30s'; // TODO: Change this to 1 week | ||
| export const SAVED_OBJECT_TYPE = 'url'; | ||
| export const PIT_KEEP_ALIVE = '10m'; |
There was a problem hiding this comment.
Ideally, the timing configurations should be included in the kibana.yml file. This makes it easy to adjust in development or testing scenarios, and it allows for quick changes if real deployments have issues with our defaults.
| filter: string; | ||
| logger: Logger; | ||
| }) => { | ||
| const results: SavedObjectsFindResult[] = []; |
There was a problem hiding this comment.
I think we shouldn't fetch everything and store it in memory due to low server memory limits. For more details, see: #203017
Ideally we would use deleteByQuery, but looks like it isn't available on the saved object client.
But I think we should just store the IDs to remove, without the whole objects.
| filter: string; | ||
| logger: Logger; | ||
| }) => { | ||
| try { |
There was a problem hiding this comment.
I’m not sure about the try/catch and best practices here because I think the task manager should know if the task succeeded or failed. This is something to investigate.
| return; | ||
| } | ||
|
|
||
| const savedObjectsRepository = core.savedObjects.createInternalRepository(); |
There was a problem hiding this comment.
One important thing to test is different spaces. I don't know how we store URLs from different spaces, but we need to double-check that our cleanup logic works globally across all spaces.
| } | ||
|
|
||
| const savedObjectsRepository = core.savedObjects.createInternalRepository(); | ||
| const filter = `url.attributes.accessDate <= now-${maxAge}`; |
There was a problem hiding this comment.
When a URL is created, is the access date prefilled with the creation date? Or can accessDat be null ?
There was a problem hiding this comment.
accessDate on creation is equal to it's creation date
|
Work on this will continue in #220138 |
Summary
TODO
Closes: #179146