Zanzana: Add setting zanzana reconciliation interval (#96687)

Add config option under RBAC for zanzana reconciliation interval
This commit is contained in:
Karl Persson 2024-11-21 09:20:29 +01:00 committed by GitHub
parent 0cb6c3d7bf
commit e995d4f682
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 3 deletions

View File

@ -98,9 +98,8 @@ func (r *ZanzanaReconciler) Reconcile(ctx context.Context) error {
r.reconcile(ctx)
// FIXME:
// 1. We should be a bit graceful about reconciliations so we are not hammering dbs
// 2. We should be able to configure reconciliation interval
ticker := time.NewTicker(1 * time.Hour)
// We should be a bit graceful about reconciliations so we are not hammering dbs
ticker := time.NewTicker(r.cfg.RBAC.ZanzanaReconciliationInterval)
for {
select {
case <-ticker.C:

View File

@ -1,6 +1,9 @@
package setting
import (
"time"
"github.com/grafana/grafana-plugin-sdk-go/backend/gtime"
"github.com/grafana/grafana/pkg/util"
)
@ -13,6 +16,9 @@ type RBACSettings struct {
ResetBasicRoles bool
// RBAC single organization. This configuration option is subject to change.
SingleOrganization bool
// If zanzana feature toggle is enabled this controls how often we
// run the zanzana reconciliation loop.
ZanzanaReconciliationInterval time.Duration
OnlyStoreAccessActionSets bool
@ -47,6 +53,12 @@ func (cfg *Cfg) readRBACSettings() {
s.resourcesWithWildcardSeed[resource] = struct{}{}
}
var err error
s.ZanzanaReconciliationInterval, err = gtime.ParseDuration(rbac.Key("zanzana_reconciliation_interval").MustString("1h"))
if err != nil {
s.ZanzanaReconciliationInterval = 1 * time.Hour
}
cfg.RBAC = s
}