reconcilers

package
v0.33.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2023 License: Apache-2.0 Imports: 20 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.Deleted will be true)
  • 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 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.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GlobalProjectParserName = &runtimev1.ResourceName{Kind: runtime.ResourceKindProjectParser, Name: "parser"}

Functions

This section is empty.

Types

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

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

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

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

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

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

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

Jump to

Keyboard shortcuts

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