Skip to content

Add unused-urls-cleanup plugin#220038

Closed
kowalczyk-krzysztof wants to merge 1 commit intoelastic:mainfrom
kowalczyk-krzysztof:feat/unusued-url-cleaner
Closed

Add unused-urls-cleanup plugin#220038
kowalczyk-krzysztof wants to merge 1 commit intoelastic:mainfrom
kowalczyk-krzysztof:feat/unusued-url-cleaner

Conversation

@kowalczyk-krzysztof
Copy link
Member

@kowalczyk-krzysztof kowalczyk-krzysztof commented May 5, 2025

Summary

TODO

Closes: #179146

@kowalczyk-krzysztof kowalczyk-krzysztof added the Team:SharedUX Platform AppEx-SharedUX (formerly Global Experience) t// label May 5, 2025
@kowalczyk-krzysztof kowalczyk-krzysztof self-assigned this May 5, 2025
@elasticmachine
Copy link
Contributor

🤖 Jobs for this PR can be triggered through checkboxes. 🚧

ℹ️ To trigger the CI, please tick the checkbox below 👇

  • Click to trigger kibana-pull-request for this PR!
  • Click to trigger kibana-deploy-project-from-pr for this PR!
  • Click to trigger kibana-deploy-cloud-from-pr for this PR!

@kowalczyk-krzysztof
Copy link
Member Author

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({
Copy link
Contributor

Choose a reason for hiding this comment

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

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';
Copy link
Contributor

Choose a reason for hiding this comment

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

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[] = [];
Copy link
Contributor

Choose a reason for hiding this comment

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

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 {
Copy link
Contributor

Choose a reason for hiding this comment

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

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();
Copy link
Contributor

Choose a reason for hiding this comment

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

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}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

When a URL is created, is the access date prefilled with the creation date? Or can accessDat be null ?

Copy link
Member Author

Choose a reason for hiding this comment

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

accessDate on creation is equal to it's creation date

@kowalczyk-krzysztof
Copy link
Member Author

Work on this will continue in #220138

@kowalczyk-krzysztof kowalczyk-krzysztof deleted the feat/unusued-url-cleaner branch August 31, 2025 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Team:SharedUX Platform AppEx-SharedUX (formerly Global Experience) t//

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Delete unused URL saved objects to avoid upgrade downtime

3 participants