reconcilers

package
v0.45.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 30, 2024 License: Apache-2.0 Imports: 32 Imported by: 0

README

runtime/reconcilers/

Adding a new resource type

  1. Define spec and state schemas in proto/rill/runtime/v1/resource.proto
  2. Define a reconciler for it in runtime/reconcilers/
  3. If the resource should be defined in code files,
    • Define parser logic for it in runtime/compilers/rillv1
    • Define mapping from parser output to catalog in runtime/reconcilers/project_parser.go

When reconcile is invoked

  • When the runtime is restarted
  • When the resource's refs or spec is updated
  • When the resource is deleted (.Meta.DeletedOn will be non-nil)
  • When the resource is renamed (.Meta.RenamedFrom will be non-nil)
  • When all the resource's refs finish running Reconcile (even if they return an error)
  • When Controller.Reconcile is called for the resource
  • When the retrigger timestamp returned from an earlier invocation of Reconcile falls due

How the controller schedules reconcilers

  • The controller may run Reconcile for different resources at the same time.
  • The controller will only run one Reconcile per resource name at a time.
  • The controller will not reconcile resources that reference each other at the same time – i.e. it only runs one non-cancelled Reconcile call between any given root and leaf node of the resource DAG. This means Reconcile does not need to worry about refs changing their state while it's running.
  • The controller cancels a reconcile if the resource being reconciled was updated/deleted by another agent than the reconciler itself (self-updates do not cause cancellations).
  • The controller cancels reconciles if DAG ancestors need to be reconciled. It will wait for the cancelled reconcile to complete before starting reconcile for the ancestor.
  • The controller does not call Reconcile for resources with cyclic refs. Instead, it immediately sets an error on them.
  • The controller schedules reconciles of deleted and renamed resources, and waits for them to finish, before scheduling new regular reconciles. It does so in two phases, first letting all deletes finish (resources with deleted_on != nil), second letting all renames finish (resources with renamed_from != nil).

Principles for reconciler development

  • The implementation of Reconcile should be idempotent
  • Assume Reconcile may be invoked at any time
  • The ctx may be cancelled at any time. When ctx is cancelled, the reconciler should return as soon as possible.
  • After the ctx has been cancelled, the reconciler can still update its state before returning (by using the ctx to call UpdateState).
  • If the ctx is cancelled, you can assume that Reconcile will be invoked again shortly.
  • Calls to Reconcile can run for a long time (as long as they respond quickly to a cancelled ctx).
  • Reconcile should strive to keep a resource's .State correct at all times because it may be accessed while Reconcile is running to resolve API requests (such as dashboard queries).
  • The Reconciler struct is shared for all resources of the registered kind for a given instance ID. This enables it to cache (ephemeral) state in-between invocations for optimization.
  • The resource's meta and spec (but not state) may be updated concurrently. Calls to Get return a clone of the resource, but if the reconciler update's the resource's meta or spec, it must use a lock to read and update it.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrParserHasParseErrors = errors.New("encountered parse errors")

Functions

This section is empty.

Types

type APIReconciler added in v0.42.0

type APIReconciler struct {
	C *runtime.Controller
}

func (*APIReconciler) AssignSpec added in v0.42.0

func (r *APIReconciler) AssignSpec(from, to *runtimev1.Resource) error

func (*APIReconciler) AssignState added in v0.42.0

func (r *APIReconciler) AssignState(from, to *runtimev1.Resource) error

func (*APIReconciler) Close added in v0.42.0

func (r *APIReconciler) Close(ctx context.Context) error

func (*APIReconciler) Reconcile added in v0.42.0

func (*APIReconciler) ResetState added in v0.42.0

func (r *APIReconciler) ResetState(res *runtimev1.Resource) error

type AlertReconciler added in v0.41.0

type AlertReconciler struct {
	C *runtime.Controller
}

func (*AlertReconciler) AssignSpec added in v0.41.0

func (r *AlertReconciler) AssignSpec(from, to *runtimev1.Resource) error

func (*AlertReconciler) AssignState added in v0.41.0

func (r *AlertReconciler) AssignState(from, to *runtimev1.Resource) error

func (*AlertReconciler) Close added in v0.41.0

func (r *AlertReconciler) Close(ctx context.Context) error

func (*AlertReconciler) Reconcile added in v0.41.0

func (*AlertReconciler) ResetState added in v0.41.0

func (r *AlertReconciler) ResetState(res *runtimev1.Resource) error

type ComponentReconciler added in v0.44.0

type ComponentReconciler struct {
	C *runtime.Controller
}

func (*ComponentReconciler) AssignSpec added in v0.44.0

func (r *ComponentReconciler) AssignSpec(from, to *runtimev1.Resource) error

func (*ComponentReconciler) AssignState added in v0.44.0

func (r *ComponentReconciler) AssignState(from, to *runtimev1.Resource) error

func (*ComponentReconciler) Close added in v0.44.0

func (r *ComponentReconciler) Close(ctx context.Context) error

func (*ComponentReconciler) Reconcile added in v0.44.0

func (*ComponentReconciler) ResetState added in v0.44.0

func (r *ComponentReconciler) ResetState(res *runtimev1.Resource) error

type DashboardReconciler added in v0.42.0

type DashboardReconciler struct {
	C *runtime.Controller
}

func (*DashboardReconciler) AssignSpec added in v0.42.0

func (r *DashboardReconciler) AssignSpec(from, to *runtimev1.Resource) error

func (*DashboardReconciler) AssignState added in v0.42.0

func (r *DashboardReconciler) AssignState(from, to *runtimev1.Resource) error

func (*DashboardReconciler) Close added in v0.42.0

func (r *DashboardReconciler) Close(ctx context.Context) error

func (*DashboardReconciler) Reconcile added in v0.42.0

func (*DashboardReconciler) ResetState added in v0.42.0

func (r *DashboardReconciler) ResetState(res *runtimev1.Resource) error

type MetricsViewReconciler

type MetricsViewReconciler struct {
	C *runtime.Controller
}

func (*MetricsViewReconciler) AssignSpec added in v0.33.0

func (r *MetricsViewReconciler) AssignSpec(from, to *runtimev1.Resource) error

func (*MetricsViewReconciler) AssignState added in v0.33.0

func (r *MetricsViewReconciler) AssignState(from, to *runtimev1.Resource) error

func (*MetricsViewReconciler) Close

func (*MetricsViewReconciler) Reconcile

func (*MetricsViewReconciler) ResetState added in v0.34.0

func (r *MetricsViewReconciler) ResetState(res *runtimev1.Resource) error

type MigrationReconciler

type MigrationReconciler struct {
	C *runtime.Controller
}

func (*MigrationReconciler) AssignSpec added in v0.33.0

func (r *MigrationReconciler) AssignSpec(from, to *runtimev1.Resource) error

func (*MigrationReconciler) AssignState added in v0.33.0

func (r *MigrationReconciler) AssignState(from, to *runtimev1.Resource) error

func (*MigrationReconciler) Close

func (r *MigrationReconciler) Close(ctx context.Context) error

func (*MigrationReconciler) Reconcile

func (*MigrationReconciler) ResetState added in v0.34.0

func (r *MigrationReconciler) ResetState(res *runtimev1.Resource) error

type ModelReconciler

type ModelReconciler struct {
	C *runtime.Controller
}

func (*ModelReconciler) AssignSpec added in v0.33.0

func (r *ModelReconciler) AssignSpec(from, to *runtimev1.Resource) error

func (*ModelReconciler) AssignState added in v0.33.0

func (r *ModelReconciler) AssignState(from, to *runtimev1.Resource) error

func (*ModelReconciler) Close

func (r *ModelReconciler) Close(ctx context.Context) error

func (*ModelReconciler) Reconcile

func (*ModelReconciler) ResetState added in v0.34.0

func (r *ModelReconciler) ResetState(res *runtimev1.Resource) error

type ProjectParserReconciler

type ProjectParserReconciler struct {
	C *runtime.Controller
}

func (*ProjectParserReconciler) AssignSpec added in v0.33.0

func (r *ProjectParserReconciler) AssignSpec(from, to *runtimev1.Resource) error

func (*ProjectParserReconciler) AssignState added in v0.33.0

func (r *ProjectParserReconciler) AssignState(from, to *runtimev1.Resource) error

func (*ProjectParserReconciler) Close

func (*ProjectParserReconciler) Reconcile

func (*ProjectParserReconciler) ResetState added in v0.34.0

func (r *ProjectParserReconciler) ResetState(res *runtimev1.Resource) error

type PullTriggerReconciler

type PullTriggerReconciler struct {
	C *runtime.Controller
}

PullTriggerReconciler reconciles a PullTrigger. When a PullTrigger is created, the reconciler will retrigger the global project parser resource, causing it to pull and reparse the project. It will then delete the PullTrigger resource.

func (*PullTriggerReconciler) AssignSpec added in v0.33.0

func (r *PullTriggerReconciler) AssignSpec(from, to *runtimev1.Resource) error

func (*PullTriggerReconciler) AssignState added in v0.33.0

func (r *PullTriggerReconciler) AssignState(from, to *runtimev1.Resource) error

func (*PullTriggerReconciler) Close

func (*PullTriggerReconciler) Reconcile

func (*PullTriggerReconciler) ResetState added in v0.34.0

func (r *PullTriggerReconciler) ResetState(res *runtimev1.Resource) error

type RefreshTriggerReconciler

type RefreshTriggerReconciler struct {
	C *runtime.Controller
}

RefreshTriggerReconciler reconciles a RefreshTrigger. When a RefreshTrigger is created, the reconciler will refresh source and model by setting Trigger=true in their specs. After that, it will delete the RefreshTrigger resource.

func (*RefreshTriggerReconciler) AssignSpec added in v0.33.0

func (r *RefreshTriggerReconciler) AssignSpec(from, to *runtimev1.Resource) error

func (*RefreshTriggerReconciler) AssignState added in v0.33.0

func (r *RefreshTriggerReconciler) AssignState(from, to *runtimev1.Resource) error

func (*RefreshTriggerReconciler) Close

func (*RefreshTriggerReconciler) Reconcile

func (*RefreshTriggerReconciler) ResetState added in v0.34.0

func (r *RefreshTriggerReconciler) ResetState(res *runtimev1.Resource) error

type ReportReconciler added in v0.36.0

type ReportReconciler struct {
	C *runtime.Controller
}

func (*ReportReconciler) AssignSpec added in v0.36.0

func (r *ReportReconciler) AssignSpec(from, to *runtimev1.Resource) error

func (*ReportReconciler) AssignState added in v0.36.0

func (r *ReportReconciler) AssignState(from, to *runtimev1.Resource) error

func (*ReportReconciler) Close added in v0.36.0

func (r *ReportReconciler) Close(ctx context.Context) error

func (*ReportReconciler) Reconcile added in v0.36.0

func (*ReportReconciler) ResetState added in v0.36.0

func (r *ReportReconciler) ResetState(res *runtimev1.Resource) error

type SourceReconciler

type SourceReconciler struct {
	C *runtime.Controller
}

func (*SourceReconciler) AssignSpec added in v0.33.0

func (r *SourceReconciler) AssignSpec(from, to *runtimev1.Resource) error

func (*SourceReconciler) AssignState added in v0.33.0

func (r *SourceReconciler) AssignState(from, to *runtimev1.Resource) error

func (*SourceReconciler) Close

func (r *SourceReconciler) Close(ctx context.Context) error

func (*SourceReconciler) Reconcile

func (*SourceReconciler) ResetState added in v0.34.0

func (r *SourceReconciler) ResetState(res *runtimev1.Resource) error

type ThemeReconciler added in v0.38.0

type ThemeReconciler struct {
	C *runtime.Controller
}

func (*ThemeReconciler) AssignSpec added in v0.38.0

func (r *ThemeReconciler) AssignSpec(from, to *runtimev1.Resource) error

func (*ThemeReconciler) AssignState added in v0.38.0

func (r *ThemeReconciler) AssignState(from, to *runtimev1.Resource) error

func (*ThemeReconciler) Close added in v0.38.0

func (r *ThemeReconciler) Close(ctx context.Context) error

func (*ThemeReconciler) Reconcile added in v0.38.0

func (*ThemeReconciler) ResetState added in v0.38.0

func (r *ThemeReconciler) ResetState(res *runtimev1.Resource) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL