App platform: Add cleanup job for dashboards when going through /apis (kubectl) (#102506)
* Add dashboard cleanup job Change log message Adjust logic to account for new head RV logic Don't update lastResourceVersion due to pagination Save improvements * Address review feedback * Update docs. * Remove docs * Rename config --------- Co-authored-by: Marco de Abreu <18629099+marcoabreu@users.noreply.github.com>
This commit is contained in:
co-authored by
Marco de Abreu
parent
c661077651
commit
543c0bbccb
@@ -181,6 +181,9 @@ type Cfg struct {
|
||||
DataProxyWhiteList map[string]bool
|
||||
ActionsAllowPostURL string
|
||||
|
||||
// K8s Dashboard Cleanup
|
||||
K8sDashboardCleanup K8sDashboardCleanupSettings
|
||||
|
||||
TempDataLifetime time.Duration
|
||||
|
||||
// Plugins
|
||||
@@ -1291,6 +1294,7 @@ func (cfg *Cfg) parseINIFile(iniFile *ini.File) error {
|
||||
|
||||
cfg.readDataSourcesSettings()
|
||||
cfg.readDataSourceSecuritySettings()
|
||||
cfg.readK8sDashboardCleanupSettings()
|
||||
cfg.readSqlDataSourceSettings()
|
||||
|
||||
cfg.Storage = readStorageSettings(iniFile)
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package setting
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type K8sDashboardCleanupSettings struct {
|
||||
Interval time.Duration
|
||||
Timeout time.Duration
|
||||
BatchSize int64
|
||||
}
|
||||
|
||||
const (
|
||||
defaultK8sDashboardCleanupInterval = 30 * time.Second
|
||||
defaultK8sDashboardCleanupBatchSize = int64(10)
|
||||
minK8sDashboardCleanupInterval = 10 * time.Second
|
||||
minK8sDashboardCleanupTimeout = 5 * time.Second
|
||||
minK8sDashboardCleanupBatchSize = int64(5)
|
||||
maxK8sDashboardCleanupBatchSize = int64(200)
|
||||
)
|
||||
|
||||
func (cfg *Cfg) readK8sDashboardCleanupSettings() {
|
||||
section := cfg.Raw.Section("dashboard_cleanup")
|
||||
|
||||
// Read interval setting with validation
|
||||
cleanupInterval := section.Key("interval").MustDuration(defaultK8sDashboardCleanupInterval)
|
||||
if cleanupInterval < minK8sDashboardCleanupInterval {
|
||||
cfg.Logger.Warn("[dashboard_cleanup.interval] is too low; the minimum allowed (10s) is enforced")
|
||||
cleanupInterval = minK8sDashboardCleanupInterval
|
||||
}
|
||||
|
||||
// Calculate timeout as 5 seconds less than interval, with minimum validation
|
||||
cleanupTimeout := cleanupInterval - (5 * time.Second)
|
||||
if cleanupTimeout < minK8sDashboardCleanupTimeout {
|
||||
cleanupTimeout = minK8sDashboardCleanupTimeout
|
||||
}
|
||||
|
||||
// Read batch size with validation
|
||||
batchSize := section.Key("batch_size").MustInt64(defaultK8sDashboardCleanupBatchSize)
|
||||
if batchSize < minK8sDashboardCleanupBatchSize {
|
||||
cfg.Logger.Warn("[dashboard_cleanup.batch_size] is too low; the minimum allowed (5) is enforced")
|
||||
batchSize = minK8sDashboardCleanupBatchSize
|
||||
} else if batchSize > maxK8sDashboardCleanupBatchSize {
|
||||
cfg.Logger.Warn("[dashboard_cleanup.batch_size] is too high; the maximum allowed (1000) is enforced")
|
||||
batchSize = maxK8sDashboardCleanupBatchSize
|
||||
}
|
||||
|
||||
cfg.K8sDashboardCleanup = K8sDashboardCleanupSettings{
|
||||
Interval: cleanupInterval,
|
||||
Timeout: cleanupTimeout,
|
||||
BatchSize: batchSize,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user