Documentation ¶
Overview ¶
Package reconciler reconciles resources in a graph.
Steps ¶
The reconciliation process consists at a high level of 3 steps:
Get existing resources
Existing resources for the project in the current namespace are listed. Any previously created resources are returned.
Create or Update resources
The desired graph is walked in the order specified by the dependencies. Each resource encountered is compared to existing resources.
- When an exact match is found, the walk continues to the next resource, with the output passed to it.
- If an existing resource with the same type and name exists but the input values do not match, the resource is updated.
- When no resource exists for the type-name combination, it is created.
Delete resources
Resources that were not matched in the create/update phase are cleaned up. Thus, resources are always created in the desired state, before anything gets removed.
Concurrency ¶
When possible, changes are performed concurrently.
A and B execute concurrently. When both have been executed (without error), C is executed. A --> C B -/ A is executed, then B & C concurrently, then D. A -> B -> D \- C -/
Retries ¶
All operations are retried with exponential backoff. If a non-retryiable error occurs, the resource definition should wrap the returned error with backoff.PermanentError(err).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultConcurrency = 10
DefaultConcurrency is the default maximum concurrency to use.
In practice, the reconciler is likely bound by network i/o.
Functions ¶
This section is empty.
Types ¶
type Graph ¶
type Graph interface { LeafResources() []*resource.Desired ParentResources(child string) []*resource.Desired DependenciesOf(child string) []*resource.Dependency }
A Graph contains the desired graph to reconcile.
type IDGenerator ¶
type IDGenerator interface {
GenerateID() string
}
An IDGenerator generates unique identifiers for created resources.
type IDGeneratorFunc ¶
type IDGeneratorFunc func() string
IDGeneratorFunc is a function type that implements the IDGenerator interface.
func (IDGeneratorFunc) GenerateID ¶
func (fn IDGeneratorFunc) GenerateID() string
GenerateID calls the wrapped function.
type Reconciler ¶
type Reconciler struct { Resources ResourceStorage Source SourceStorage Registry Registry IDGen IDGenerator // Concurrency sets the maximum allowed concurrency to use. // If not set, DefaultConcurrency is used. Concurrency uint // Logger logs reconciliation updates. If not set, logs are discarded. Logger *zap.Logger // Backoff algorithm used for retries. If not set, exponential backoff is used. Backoff func() backoff.BackOff }
A Reconciler reconciles changes to a graph.
See package doc for details.
type ResourceStorage ¶
type ResourceStorage interface { PutResource(ctx context.Context, project string, resource *resource.Deployed) error DeleteResource(ctx context.Context, project string, resource *resource.Deployed) error ListResources(ctx context.Context, project string) ([]*resource.Deployed, error) }
ResourceStorage persists resources.
type SourceStorage ¶
SourceStorage provides resource source code.