|
|
|
@ -35,8 +35,6 @@ type ZanzanaReconciler struct { |
|
|
|
|
// reconcilers are migrations that tries to reconcile the state of grafana db to zanzana store.
|
|
|
|
|
// These are run periodically to try to maintain a consistent state.
|
|
|
|
|
reconcilers []resourceReconciler |
|
|
|
|
// globalReconcilers are reconcilers that should only run for cluster namespace
|
|
|
|
|
globalReconcilers []resourceReconciler |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func ProvideZanzanaReconciler(cfg *setting.Cfg, features featuremgmt.FeatureToggles, client zanzana.Client, store db.DB, lock *serverlock.ServerLockService, folderService folder.Service) *ZanzanaReconciler { |
|
|
|
@ -96,8 +94,6 @@ func ProvideZanzanaReconciler(cfg *setting.Cfg, features featuremgmt.FeatureTogg |
|
|
|
|
zanzanaCollector([]string{zanzana.RelationAssignee}), |
|
|
|
|
client, |
|
|
|
|
), |
|
|
|
|
}, |
|
|
|
|
globalReconcilers: []resourceReconciler{ |
|
|
|
|
newResourceReconciler( |
|
|
|
|
"fixed role pemissions", |
|
|
|
|
fixedRolePermissionsCollector(store), |
|
|
|
@ -148,15 +144,6 @@ func (r *ZanzanaReconciler) Reconcile(ctx context.Context) error { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (r *ZanzanaReconciler) reconcile(ctx context.Context) { |
|
|
|
|
runGlobal := func(ctx context.Context) { |
|
|
|
|
for _, reconciler := range r.globalReconcilers { |
|
|
|
|
r.log.Debug("Performing zanzana reconciliation", "reconciler", reconciler.name) |
|
|
|
|
if err := reconciler.reconcile(ctx, zanzana.ClusterNamespace); err != nil { |
|
|
|
|
r.log.Warn("Failed to perform reconciliation for resource", "err", err) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
run := func(ctx context.Context, namespace string) { |
|
|
|
|
now := time.Now() |
|
|
|
|
r.log.Debug("Started reconciliation") |
|
|
|
@ -192,7 +179,6 @@ func (r *ZanzanaReconciler) reconcile(ctx context.Context) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if r.lock == nil { |
|
|
|
|
runGlobal(ctx) |
|
|
|
|
for _, ns := range namespaces { |
|
|
|
|
run(ctx, ns) |
|
|
|
|
} |
|
|
|
@ -201,7 +187,6 @@ func (r *ZanzanaReconciler) reconcile(ctx context.Context) { |
|
|
|
|
|
|
|
|
|
// We ignore the error for now
|
|
|
|
|
err := r.lock.LockExecuteAndRelease(ctx, "zanzana-reconciliation", 10*time.Hour, func(ctx context.Context) { |
|
|
|
|
runGlobal(ctx) |
|
|
|
|
for _, ns := range namespaces { |
|
|
|
|
run(ctx, ns) |
|
|
|
|
} |
|
|
|
|