applier

package
v1.20.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: Apache-2.0 Imports: 44 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StatusEnabled is used to allow kpt applier to inject the actuation status
	// into the ResourceGroup object.
	StatusEnabled = "enabled"
	//  StatusDisabled is used to stop kpt applier to inject the actuation status
	// into the ResourceGroup object.
	StatusDisabled = "disabled"

	// StatusModeKey annotates a ResourceGroup CR
	// to communicate with the ResourceGroup controller.
	// When the value is set to "disabled", the ResourceGroup controller
	// ignores the ResourceGroup CR.
	StatusModeKey = configsync.ConfigSyncPrefix + "status"
)
View Source
const ApplierErrorCode = "2009"

ApplierErrorCode is the error code for apply failures.

Variables

This section is empty.

Functions

func DeleteErrorForResource added in v1.15.1

func DeleteErrorForResource(err error, id core.ID) status.Error

DeleteErrorForResource indicates that the applier failed to delete the given resource.

func Error

func Error(err error) status.Error

Error indicates that the applier failed to apply some resources.

func ErrorForResource

func ErrorForResource(err error, id core.ID) status.Error

ErrorForResource indicates that the applier failed to apply the given resource.

func ErrorForResourceWithResource added in v1.19.0

func ErrorForResourceWithResource(err error, id core.ID, resource client.Object) status.Error

ErrorForResourceWithResource returns an Error that indicates that the applier failed to apply the given resource and includes the resource itself

func InventoryID

func InventoryID(name, namespace string) string

InventoryID returns the inventory id of an inventory object. The inventory object generated by ConfigSync is in the same namespace as RootSync or RepoSync. The inventory ID is assigned as <NAMESPACE>_<NAME>.

func KptManagementConflictError

func KptManagementConflictError(resource client.Object) status.Error

KptManagementConflictError indicates that the passed resource is illegally declared in multiple repositories. TODO: merge with status.ManagementConflictError if cli-utils supports reporting the conflicting manager in InventoryOverlapError.

func ObjMetaFromObject added in v1.15.1

func ObjMetaFromObject(obj client.Object) object.ObjMetadata

ObjMetaFromObject constructs an ObjMetadata representing the Object.

func PruneErrorForResource

func PruneErrorForResource(err error, id core.ID) status.Error

PruneErrorForResource indicates that the applier failed to prune the given resource.

func SkipErrorForResource

func SkipErrorForResource(err error, id core.ID, strategy actuation.ActuationStrategy) status.Error

SkipErrorForResource indicates that the applier skipped apply or delete of the given resource.

func WaitErrorForResource added in v1.16.0

func WaitErrorForResource(err error, id core.ID) status.Error

WaitErrorForResource indicates that the applier failed to wait for the given resource.

Types

type Applier

type Applier interface {
	// Apply creates, updates, or prunes all managed resources, depending on
	// the new desired resource objects.
	// Error events are sent to the eventHandler.
	// Returns the status of the applied objects and statistics of the sync.
	// This is called by the reconciler when changes are detected in the
	// source of truth (git, OCI, helm) and periodically.
	Apply(ctx context.Context, eventHandler func(Event), desiredResources []client.Object) (ObjectStatusMap, *stats.SyncStats)
}

Applier is a bulk client for applying a set of desired resource objects and tracking them in a ResourceGroup inventory. This enables pruning objects by removing them from the list of desired resource objects and re-applying.

type ClientSet added in v1.15.1

type ClientSet struct {
	KptApplier   KptApplier
	KptDestroyer KptDestroyer
	InvClient    inventory.Client
	Client       client.Client
	Mapper       meta.RESTMapper
	StatusMode   string
	ApplySetID   string
}

ClientSet wraps the various Kubernetes clients required for building a Config Sync applier.Applier.

func NewClientSet added in v1.15.1

func NewClientSet(c client.Client, configFlags *genericclioptions.ConfigFlags, statusMode, applySetID string) (*ClientSet, error)

NewClientSet constructs a new ClientSet.

type Destroyer added in v1.15.1

type Destroyer interface {
	// Destroy deletes all managed resources.
	// Error events are sent to the eventHandler.
	// Returns the status of the destroyed objects and statistics of the sync.
	// This is called by the reconciler finalizer when deletion propagation is
	// enabled.
	Destroy(ctx context.Context, eventHandler func(Event)) (ObjectStatusMap, *stats.SyncStats)
}

Destroyer is a bulk client for deleting all the managed resource objects tracked in a single ResourceGroup inventory.

type ErrorEvent added in v1.19.0

type ErrorEvent struct {
	Error status.Error
}

ErrorEvent is sent after the supervisor has errored. Generally, the supervisor will still continue until success or timeout.

func (ErrorEvent) Type added in v1.19.0

func (e ErrorEvent) Type() EventType

Type returns the type of the event.

type Event added in v1.19.0

type Event interface {
	// Type returns the type of the event.
	Type() EventType
}

Event is sent to the eventHandler by the supervisor.

type EventType added in v1.19.0

type EventType string

EventType is the type used by SuperEvent.Type

const (
	// ErrorEventType is the type of the ErrorEvent
	ErrorEventType EventType = "ErrorEvent"
)

type KptApplier added in v1.15.1

type KptApplier interface {
	Run(context.Context, inventory.Info, object.UnstructuredSet, apply.ApplierOptions) <-chan event.Event
}

KptApplier is the interface exposed by cli-utils apply.Applier. Using an interface, instead of the concrete struct, allows for easier testing.

type KptDestroyer added in v1.15.1

type KptDestroyer interface {
	Run(context.Context, inventory.Info, apply.DestroyerOptions) <-chan event.Event
}

KptDestroyer is the interface exposed by cli-utils apply.Destroyer. Using an interface, instead of the concrete struct, allows for easier testing.

type ObjectStatus

type ObjectStatus struct {
	// Strategy indicates the method of actuation (apply or delete) used or planned to be used.
	Strategy actuation.ActuationStrategy
	// Actuation indicates whether actuation has been performed yet and how it went.
	Actuation actuation.ActuationStatus
	// Reconcile indicates whether reconciliation has been performed yet and how it went.
	Reconcile actuation.ReconcileStatus
}

ObjectStatus is a subset of actuation.ObjectStatus for tracking object status as a map value instead of a list value.

type ObjectStatusMap

type ObjectStatusMap map[core.ID]*ObjectStatus

ObjectStatusMap is a map of object IDs to ObjectStatus.

func (ObjectStatusMap) Filter

Filter returns an unsorted list of IDs that satisfy the specified constraints. Use -1 to specify the constraint is not required.

func (ObjectStatusMap) Log

func (m ObjectStatusMap) Log(logger infofLogger)

Log uses the specified logger to log object statuses. This produces multiple log entries, if the logger is enabled. Takes a minimal logger interface in order to make testing easier, but is designed for use with a leveled klog, like klog.V(3)

type Supervisor added in v1.15.1

type Supervisor interface {
	Applier
	Destroyer
}

Supervisor is a bulk client for applying and deleting a mutable set of resource objects. Managed objects are tracked in a ResourceGroup inventory object.

Supervisor satisfies both the Applier and Destroyer interfaces, with a shared lock, preventing Apply and Destroy from running concurrently.

The Applier and Destroyer share an error cache. So the Errors method will return the last errors from Apply or the Destroy, whichever came last.

func NewNamespaceSupervisor added in v1.15.1

func NewNamespaceSupervisor(cs *ClientSet, namespace declared.Scope, syncName string, reconcileTimeout time.Duration) (Supervisor, error)

NewNamespaceSupervisor constructs a Supervisor that can manage resource objects in a single namespace.

func NewRootSupervisor added in v1.15.1

func NewRootSupervisor(cs *ClientSet, syncName string, reconcileTimeout time.Duration) (Supervisor, error)

NewRootSupervisor constructs a Supervisor that can manage both cluster-level and namespace-level resource objects in a single cluster.

func NewSupervisor added in v1.15.1

func NewSupervisor(cs *ClientSet, scope declared.Scope, syncName string, reconcileTimeout time.Duration) (Supervisor, error)

NewSupervisor constructs either a cluster-level or namespace-level Supervisor, based on the specified scope.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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