Documentation
¶
Index ¶
- Constants
- type CollectionInfo
- type ConditionsMarker
- func (m *ConditionsMarker) GraphResolutionFailed(msg string, args ...any)
- func (m *ConditionsMarker) GraphResolved()
- func (m *ConditionsMarker) InstanceManaged()
- func (m *ConditionsMarker) InstanceNotManaged(format string, a ...any)
- func (m *ConditionsMarker) ResourcesDeleting(msg string, args ...any)
- func (m *ConditionsMarker) ResourcesNotReady(msg string, args ...any)
- func (m *ConditionsMarker) ResourcesReady()
- func (m *ConditionsMarker) ResourcesUnderDeletion(msg string, args ...any)
- type Controller
- type GraphRevisionResolver
- type NodeState
- type ReconcileConfig
- type ReconcileContext
- type StateManager
Constants ¶
const ( Ready = "Ready" InstanceManaged = "InstanceManaged" GraphResolved = "GraphResolved" ResourcesReady = "ResourcesReady" )
const FieldManagerForLabeler = "kro.run/labeller"
FieldManagerForLabeler is the field manager name used when applying labels.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CollectionInfo ¶ added in v0.8.0
CollectionInfo holds collection item metadata for decorator.
type ConditionsMarker ¶ added in v0.6.0
type ConditionsMarker struct {
// contains filtered or unexported fields
}
func NewConditionsMarkerFor ¶ added in v0.6.0
func NewConditionsMarkerFor(obj *unstructured.Unstructured) *ConditionsMarker
func (*ConditionsMarker) GraphResolutionFailed ¶ added in v0.8.0
func (m *ConditionsMarker) GraphResolutionFailed(msg string, args ...any)
GraphResolutionFailed signals there was an issue creating the runtime graph or resolving resources.
func (*ConditionsMarker) GraphResolved ¶ added in v0.6.0
func (m *ConditionsMarker) GraphResolved()
GraphResolved signals the runtime graph has been created and resources resolved.
func (*ConditionsMarker) InstanceManaged ¶ added in v0.6.0
func (m *ConditionsMarker) InstanceManaged()
InstanceManaged signals the instance has proper finalizers and labels set.
func (*ConditionsMarker) InstanceNotManaged ¶ added in v0.6.0
func (m *ConditionsMarker) InstanceNotManaged(format string, a ...any)
InstanceNotManaged signals there was an issue setting up the instance management.
func (*ConditionsMarker) ResourcesDeleting ¶ added in v0.9.0
func (m *ConditionsMarker) ResourcesDeleting(msg string, args ...any)
ResourcesDeleting signals there are managed resources currently terminating.
func (*ConditionsMarker) ResourcesNotReady ¶ added in v0.6.0
func (m *ConditionsMarker) ResourcesNotReady(msg string, args ...any)
ResourcesNotReady signals there are resources in the graph that are not ready.
func (*ConditionsMarker) ResourcesReady ¶ added in v0.6.0
func (m *ConditionsMarker) ResourcesReady()
ResourcesReady signals all resources in the graph are created and ready.
func (*ConditionsMarker) ResourcesUnderDeletion ¶ added in v0.8.0
func (m *ConditionsMarker) ResourcesUnderDeletion(msg string, args ...any)
ResourcesUnderDeletion signals the controller is currently deleting resources.
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller manages the reconciliation of a single instance of a ResourceGraphDefinition, / it is responsible for reconciling the instance and its sub-resources.
The controller is responsible for the following: - Reconciling the instance - Reconciling the sub-resources of the instance - Updating the status of the instance - Managing finalizers, owner references and labels - Handling errors and retries - Performing cleanup operations (garbage collection)
For each instance of a ResourceGraphDefinition, the controller creates a new instance of the InstanceGraphReconciler to manage the reconciliation of the instance and its sub-resources.
It is important to state that when the controller is reconciling an instance, it creates and uses a new instance of the ResourceGraphDefinitionRuntime to uniquely manage the state of the instance and its sub-resources. This ensure that at each reconciliation loop, the controller is working with a fresh state of the instance and its sub-resources. Controller owns reconciliation for instances of a ResourceGraphDefinition.
func NewController ¶
func NewController( log logr.Logger, reconcileConfig ReconcileConfig, gvr schema.GroupVersionResource, graphResolver GraphRevisionResolver, namespaced bool, client kroclient.SetInterface, instanceLabeler metadata.Labeler, childResourceLabeler metadata.Labeler, coord *dynamiccontroller.WatchCoordinator, eventRecorder record.EventRecorder, ) *Controller
NewController constructs a new controller that resolves the newest issued graph revision for the RGD from a GraphRevisionResolver.
type GraphRevisionResolver ¶ added in v0.9.0
type GraphRevisionResolver interface {
// GetLatestRevision returns the newest issued revision currently present in
// the in-memory registry for this resolver's RGD.
//
// The boolean return is false when no revision is currently cached for that
// RGD, for example before warmup completes or after pruning.
GetLatestRevision() (revisions.Entry, bool)
// GetGraphRevision returns a specific revision from the in-memory registry
// for this resolver's RGD.
//
// The boolean return is false when that revision is not present in cache,
// for example because it has not been warmed yet or has already been pruned.
GetGraphRevision(revision int64) (revisions.Entry, bool)
}
GraphRevisionResolver resolves compiled graph revisions for a single RGD.
Implementations are already scoped to one RGD's graph revisions. Callers do not pass an RGD identifier on each method call; they only ask for the newest issued revision or a specific revision number for that RGD.
type NodeState ¶ added in v0.8.0
NodeState holds the current reconciliation state for a node.
func (*NodeState) SetDeleted ¶ added in v0.8.0
func (st *NodeState) SetDeleted()
SetDeleted marks the node as deleted and clears any error.
func (*NodeState) SetDeleting ¶ added in v0.8.0
func (st *NodeState) SetDeleting()
SetDeleting marks the node as deletion-in-progress and clears any error.
func (*NodeState) SetInProgress ¶ added in v0.8.0
func (st *NodeState) SetInProgress()
SetInProgress marks the node as in progress and clears any error.
func (*NodeState) SetReady ¶ added in v0.8.0
func (st *NodeState) SetReady()
SetReady marks the node as ready/synced and clears any error.
func (*NodeState) SetSkipped ¶ added in v0.8.0
func (st *NodeState) SetSkipped()
SetSkipped marks the node as intentionally skipped and clears any error.
func (*NodeState) SetWaitingForReadiness ¶ added in v0.8.0
SetWaitingForReadiness marks the node as waiting for readiness, optionally recording err.
type ReconcileConfig ¶
type ReconcileConfig struct {
// DefaultRequeueDuration is the fixed delay used when the instance
// reconciler needs to retry after transient cluster state changes.
// Set to 0 to disable delayed requeues.
DefaultRequeueDuration time.Duration
// DeletionGraceTimeDuration is the duration to wait after initializing a resource
// deletion before considering it failed
// Not implemented.
DeletionGraceTimeDuration time.Duration
// DeletionPolicy is the deletion policy to use when deleting resources in the graph
// TODO(a-hilaly): need to define think the different deletion policies we need to
// support.
DeletionPolicy string
// RGDConfig holds RGD runtime configuration parameters.
RGDConfig graph.RGDConfig
}
ReconcileConfig holds configuration parameters for the reconciliation process. It allows the customization of various aspects of the controller's behavior.
type ReconcileContext ¶ added in v0.8.0
type ReconcileContext struct {
Ctx context.Context
Log logr.Logger
GVR schema.GroupVersionResource
Namespaced bool
Client dynamic.Interface
RestMapper meta.RESTMapper
Labeler metadata.Labeler
Runtime runtime.Interface
Instance *unstructured.Unstructured
Config ReconcileConfig
Mark *ConditionsMarker
StateManager *StateManager
// Watcher is the per-instance watch handle from the coordinator.
// Use dynamiccontroller.NoopInstanceWatcher{} in tests.
Watcher dynamiccontroller.InstanceWatcher
}
func NewReconcileContext ¶ added in v0.8.0
func NewReconcileContext( ctx context.Context, log logr.Logger, gvr schema.GroupVersionResource, namespaced bool, client dynamic.Interface, restMapper meta.RESTMapper, labeler metadata.Labeler, rt runtime.Interface, config ReconcileConfig, instance *unstructured.Unstructured, ) *ReconcileContext
NewReconcileContext constructs a ReconcileContext for a single reconciliation cycle. It bundles all dependencies needed to reconcile an instance's resources:
- client/restMapper: for Kubernetes API operations
- labeler: for applying kro metadata labels to resources
- rt: the runtime containing resolved resource templates, and helpers to figure out readiness, inclusion etc...
- instance: the instance CR being reconciled
It also initializes internal state (Mark for conditions, StateManager for node states).
func (*ReconcileContext) InstanceClient ¶ added in v0.8.0
func (rcx *ReconcileContext) InstanceClient() dynamic.ResourceInterface
type StateManager ¶ added in v0.8.0
type StateManager struct {
State v1alpha1.InstanceState
NodeStates map[string]*NodeState
ReconcileErr error
}
StateManager tracks instance and node states during reconciliation. It is not safe for concurrent use; reconciliation processes nodes sequentially.
func (*StateManager) NewNodeState ¶ added in v0.8.0
func (s *StateManager) NewNodeState(id string) *NodeState
NewNodeState initializes and registers node state as InProgress. Returns a pointer for processApplyResults and deletion paths that update state on already-registered nodes.
func (*StateManager) NodeErrors ¶ added in v0.8.0
func (s *StateManager) NodeErrors() error
NodeErrors aggregates errors across all node states.
func (*StateManager) SetNodeState ¶ added in v0.9.0
func (s *StateManager) SetNodeState(id string, state NodeState)
SetNodeState registers a node state by value. This is the preferred registration method for processNode — it makes the caller the single point where state is written.
func (*StateManager) Update ¶ added in v0.8.0
func (s *StateManager) Update()
Update recomputes the instance state from node states.