ShareInternally: Make stale short link expiry optional (#88137)

Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com>
Co-authored-by: Isabel Matwawana <76437239+imatwawana@users.noreply.github.com>
Co-authored-by: Irene Rodriguez <irene.rodriguez@grafana.com>
Co-authored-by: Jack Baldry <jack.baldry@grafana.com>
This commit is contained in:
Igor 2024-10-16 10:36:54 +02:00 committed by GitHub
parent 7fba9ba522
commit 0a255ac5fb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 3 deletions

View File

@ -1559,7 +1559,8 @@ enabled = true
#################################### Short Links ############################# #################################### Short Links #############################
[short_links] [short_links]
# Short links which are never accessed will be deleted as cleanup. Time is in days. Default is 7 days. Max is 365. 0 means they will be deleted approximately every 10 minutes. # Short links that are never accessed will be deleted as cleanup. Time is set up in days. The default is 7 days. Maximum value is 365.
# 0 means they will be deleted approximately every 10 minutes. A negative value (such as -1) will disable expiration.
expire_time = 7 expire_time = 7
#################################### Internal Grafana Metrics ############ #################################### Internal Grafana Metrics ############

View File

@ -1872,7 +1872,11 @@ Configures settings around the short link feature.
### expire_time ### expire_time
Short links which are never accessed are considered expired or stale, and will be deleted as cleanup. Set the expiration time in days. Default is `7` days. Maximum is `365` days, and setting above the maximum will have `365` set instead. Setting `0` means the short links will be cleaned up approximately every 10 minutes. Short links that are never accessed are considered expired or stale and will be deleted as cleanup. Set the expiration time in days. The default is `7` days. The maximum is `365` days, and setting above the maximum will have `365` set instead. Setting `0` means the short links will be cleaned up approximately every 10 minutes. A negative value such as `-1` will disable expiry.
{{< admonition type="caution" >}}
Short links without an expiration increase the size of the database and cant be deleted.
{{< /admonition >}}
<hr> <hr>

View File

@ -103,12 +103,15 @@ func (srv *CleanUpService) clean(ctx context.Context) {
{"delete expired images", srv.deleteExpiredImages}, {"delete expired images", srv.deleteExpiredImages},
{"cleanup old annotations", srv.cleanUpOldAnnotations}, {"cleanup old annotations", srv.cleanUpOldAnnotations},
{"expire old user invites", srv.expireOldUserInvites}, {"expire old user invites", srv.expireOldUserInvites},
{"delete stale short URLs", srv.deleteStaleShortURLs},
{"delete stale query history", srv.deleteStaleQueryHistory}, {"delete stale query history", srv.deleteStaleQueryHistory},
{"expire old email verifications", srv.expireOldVerifications}, {"expire old email verifications", srv.expireOldVerifications},
{"cleanup trash dashboards", srv.cleanUpTrashDashboards}, {"cleanup trash dashboards", srv.cleanUpTrashDashboards},
} }
if srv.Cfg.ShortLinkExpiration > 0 {
cleanupJobs = append(cleanupJobs, cleanUpJob{"delete stale short URLs", srv.deleteStaleShortURLs})
}
logger := srv.log.FromContext(ctx) logger := srv.log.FromContext(ctx)
logger.Debug("Starting cleanup jobs", "jobs", fmt.Sprintf("%v", cleanupJobs)) logger.Debug("Starting cleanup jobs", "jobs", fmt.Sprintf("%v", cleanupJobs))