synchronizer

package
v0.0.0-...-1ea09f2 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2025 License: MIT Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RolloutMessageCompleted        = "Rollout has completed"
	RolloutMessageCronJobCompleted = "No support for monitoring CronJobs"
	RolloutMessageJobCompleted     = "Job finished successfully"
	RolloutMessageJobFailed        = "Job has failed"
)
View Source
const (
	NaiseratorFinalizer = "naiserator.nais.io/finalizer"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Generator

type Generator interface {
	Prepare(ctx context.Context, source resource.Source, kube client.Client) (interface{}, error)
	Generate(source resource.Source, options interface{}) (resource.Operations, error)
}

Generator transform CRD objects such as Application, Naisjob into other kinds of Kubernetes resources. First, `Prepare()` is called. This function has access to (read-only) cluster operations and returns a configuration object. Then, `Generate()` is called with the configuration object, and returns a full set of Kubernetes resources.

type Rollout

type Rollout struct {
	Source              resource.Source
	ResourceOperations  resource.Operations
	Options             interface{}
	CorrelationID       string
	SynchronizationHash string
}

Rollout represents the data necessary to rollout an application to Kubernetes.

type RolloutMonitor

type RolloutMonitor struct {
	// contains filtered or unexported fields
}

type Synchronizer

type Synchronizer struct {
	client.Client
	// contains filtered or unexported fields
}

Synchronizer creates child resources from Application resources in the cluster. If the child resources does not match the Application spec, the resources are updated.

func NewSynchronizer

func NewSynchronizer(
	cli client.Client,
	simpleClient client.Client,
	config config.Config,
	generator Generator,
	kafka kafka.Interface,
	listers []client.ObjectList,
	scheme *runtime.Scheme,
) *Synchronizer

func (*Synchronizer) ClusterOperations

func (n *Synchronizer) ClusterOperations(ctx context.Context, rollout Rollout) []commit

ClusterOperations generates a set of functions that will perform the rollout in the cluster.

func (*Synchronizer) MonitorRollout

func (n *Synchronizer) MonitorRollout(app generator.MonitorSource, logger log.Entry)

func (*Synchronizer) Prepare

func (n *Synchronizer) Prepare(ctx context.Context, source resource.Source) (*Rollout, error)

Prepare converts a NAIS application spec into a Rollout object. The Rollout object contains callback functions that commits changes in the cluster. Prepare is a read-only operation.

func (*Synchronizer) Reconcile

func (n *Synchronizer) Reconcile(ctx context.Context, req ctrl.Request, app resource.Source) (ctrl.Result, error)

Reconcile processes the work queue

func (*Synchronizer) Sync

func (n *Synchronizer) Sync(ctx context.Context, rollout Rollout) (bool, error)

func (*Synchronizer) Unreferenced

func (n *Synchronizer) Unreferenced(ctx context.Context, rollout Rollout) ([]runtime.Object, error)

Unreferenced return all resources in cluster which was created by synchronizer previously, but is not included in the current rollout.

func (*Synchronizer) UpdateResource

func (n *Synchronizer) UpdateResource(ctx context.Context, source resource.Source, updateFunc func(resource.Source) error) error

UpdateResource atomically updates a resource. Locks the resource to avoid race conditions.

Jump to

Keyboard shortcuts

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