Documentation
¶
Index ¶
- type BaseFinalizer
- func (f *BaseFinalizer) Execute(ctx context.Context, service *types.Service) error
- func (f *BaseFinalizer) GetCompletedAt() *time.Time
- func (f *BaseFinalizer) GetCreatedAt() time.Time
- func (f *BaseFinalizer) GetDependencies() []types.FinalizerDependency
- func (f *BaseFinalizer) GetError() string
- func (f *BaseFinalizer) GetID() string
- func (f *BaseFinalizer) GetStatus() types.FinalizerStatus
- func (f *BaseFinalizer) GetType() types.FinalizerType
- func (f *BaseFinalizer) GetUpdatedAt() time.Time
- func (f *BaseFinalizer) SetCompletedAt(t time.Time)
- func (f *BaseFinalizer) SetError(err string)
- func (f *BaseFinalizer) SetStatus(status types.FinalizerStatus)
- func (f *BaseFinalizer) ToFinalizer() types.Finalizer
- func (f *BaseFinalizer) Validate(service *types.Service) error
- type FinalizerEvent
- type FinalizerExecutor
- type FinalizerFactory
- type FinalizerInterface
- type FinalizerRegistry
- func (r *FinalizerRegistry) Create(finalizerType types.FinalizerType) (FinalizerInterface, error)
- func (r *FinalizerRegistry) Get(finalizerType types.FinalizerType) (FinalizerInterface, bool)
- func (r *FinalizerRegistry) IsRegistered(finalizerType types.FinalizerType) bool
- func (r *FinalizerRegistry) ListTypes() []types.FinalizerType
- func (r *FinalizerRegistry) Register(finalizerType types.FinalizerType, factory FinalizerFactory)
- type InstanceCleanupFinalizer
- type ServiceDeregisterFinalizer
- type VolumeCleanupFinalizer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseFinalizer ¶
type BaseFinalizer struct {
ID string `json:"id"`
Type types.FinalizerType `json:"type"`
Status types.FinalizerStatus `json:"status"`
Error string `json:"error,omitempty"`
Dependencies []types.FinalizerDependency `json:"dependencies,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
}
BaseFinalizer provides a basic implementation of FinalizerInterface
func NewBaseFinalizer ¶
func NewBaseFinalizer(finalizerType types.FinalizerType, dependencies []types.FinalizerDependency) *BaseFinalizer
NewBaseFinalizer creates a new base finalizer with the given type
func (*BaseFinalizer) GetCompletedAt ¶
func (f *BaseFinalizer) GetCompletedAt() *time.Time
GetCompletedAt returns when this finalizer completed (if it has)
func (*BaseFinalizer) GetCreatedAt ¶
func (f *BaseFinalizer) GetCreatedAt() time.Time
GetCreatedAt returns when this finalizer was created
func (*BaseFinalizer) GetDependencies ¶
func (f *BaseFinalizer) GetDependencies() []types.FinalizerDependency
GetDependencies returns the list of finalizers this one depends on
func (*BaseFinalizer) GetError ¶
func (f *BaseFinalizer) GetError() string
GetError returns any error from the last execution
func (*BaseFinalizer) GetID ¶
func (f *BaseFinalizer) GetID() string
GetID returns the unique identifier for this finalizer
func (*BaseFinalizer) GetStatus ¶
func (f *BaseFinalizer) GetStatus() types.FinalizerStatus
GetStatus returns the current status of this finalizer
func (*BaseFinalizer) GetType ¶
func (f *BaseFinalizer) GetType() types.FinalizerType
GetType returns the type of this finalizer
func (*BaseFinalizer) GetUpdatedAt ¶
func (f *BaseFinalizer) GetUpdatedAt() time.Time
GetUpdatedAt returns when this finalizer was last updated
func (*BaseFinalizer) SetCompletedAt ¶
func (f *BaseFinalizer) SetCompletedAt(t time.Time)
SetCompletedAt sets the completion time
func (*BaseFinalizer) SetError ¶
func (f *BaseFinalizer) SetError(err string)
SetError sets an error message
func (*BaseFinalizer) SetStatus ¶
func (f *BaseFinalizer) SetStatus(status types.FinalizerStatus)
SetStatus sets the status of this finalizer
func (*BaseFinalizer) ToFinalizer ¶
func (f *BaseFinalizer) ToFinalizer() types.Finalizer
ToFinalizer converts to the types.Finalizer struct
type FinalizerEvent ¶
type FinalizerEvent struct {
FinalizerID string
FinalizerType types.FinalizerType
Status types.FinalizerStatus
Error string
Timestamp time.Time
}
FinalizerEvent represents an event emitted during finalizer execution
type FinalizerExecutor ¶
type FinalizerExecutor struct {
// contains filtered or unexported fields
}
FinalizerExecutor executes finalizers with dependency resolution, timeouts, and retries
func DefaultFinalizerExecutor ¶
func DefaultFinalizerExecutor( storeInstance store.Store, instanceController types.InstanceFinalizerInterface, healthController types.HealthFinalizerInterface, logger log.Logger, ) *FinalizerExecutor
DefaultFinalizerExecutor creates a finalizer executor with sensible defaults and automatically registers common finalizers
func NewFinalizerExecutor ¶
func NewFinalizerExecutor( registry *FinalizerRegistry, logger log.Logger, timeoutConfig types.FinalizerTimeoutConfig, retryPolicy worker.RetryPolicy, ) *FinalizerExecutor
NewFinalizerExecutor creates a new finalizer executor
func (*FinalizerExecutor) ExecuteFinalizers ¶
func (e *FinalizerExecutor) ExecuteFinalizers(ctx context.Context, service *types.Service, finalizerTypes []types.FinalizerType) (<-chan FinalizerEvent, error)
ExecuteFinalizers executes a list of finalizers in dependency order It returns a channel that emits events for real-time progress tracking
type FinalizerFactory ¶
type FinalizerFactory func() FinalizerInterface
FinalizerFactory is a function that creates a new finalizer instance
type FinalizerInterface ¶
type FinalizerInterface interface {
// GetID returns the unique identifier for this finalizer
GetID() string
// GetType returns the type of this finalizer
GetType() types.FinalizerType
// GetStatus returns the current status of this finalizer
GetStatus() types.FinalizerStatus
// SetStatus sets the status of this finalizer
SetStatus(status types.FinalizerStatus)
// GetError returns any error from the last execution
GetError() string
// SetError sets an error message
SetError(err string)
// GetDependencies returns the list of finalizers this one depends on
GetDependencies() []types.FinalizerDependency
// Execute performs the cleanup operation
Execute(ctx context.Context, service *types.Service) error
// Validate checks if the finalizer can be executed
Validate(service *types.Service) error
// GetCreatedAt returns when this finalizer was created
GetCreatedAt() time.Time
// GetUpdatedAt returns when this finalizer was last updated
GetUpdatedAt() time.Time
// GetCompletedAt returns when this finalizer completed (if it has)
GetCompletedAt() *time.Time
// SetCompletedAt sets the completion time
SetCompletedAt(t time.Time)
// ToFinalizer converts to the types.Finalizer struct
ToFinalizer() types.Finalizer
}
FinalizerInterface defines the contract for finalizers
type FinalizerRegistry ¶
type FinalizerRegistry struct {
// contains filtered or unexported fields
}
FinalizerRegistry manages finalizer types and creates instances
func NewFinalizerRegistry ¶
func NewFinalizerRegistry() *FinalizerRegistry
NewFinalizerRegistry creates a new finalizer registry
func (*FinalizerRegistry) Create ¶
func (r *FinalizerRegistry) Create(finalizerType types.FinalizerType) (FinalizerInterface, error)
Create creates a new finalizer instance of the given type
func (*FinalizerRegistry) Get ¶
func (r *FinalizerRegistry) Get(finalizerType types.FinalizerType) (FinalizerInterface, bool)
Get creates a finalizer instance (alias for Create for backward compatibility)
func (*FinalizerRegistry) IsRegistered ¶
func (r *FinalizerRegistry) IsRegistered(finalizerType types.FinalizerType) bool
IsRegistered checks if a finalizer type is registered
func (*FinalizerRegistry) ListTypes ¶
func (r *FinalizerRegistry) ListTypes() []types.FinalizerType
ListTypes returns all registered finalizer types
func (*FinalizerRegistry) Register ¶
func (r *FinalizerRegistry) Register(finalizerType types.FinalizerType, factory FinalizerFactory)
Register registers a finalizer factory for a given type
type InstanceCleanupFinalizer ¶
type InstanceCleanupFinalizer struct {
*BaseFinalizer
// contains filtered or unexported fields
}
InstanceCleanupFinalizer handles cleanup of service instances
func NewInstanceCleanupFinalizer ¶
func NewInstanceCleanupFinalizer(store store.Store, instanceController types.InstanceFinalizerInterface, healthController types.HealthFinalizerInterface, logger log.Logger) *InstanceCleanupFinalizer
NewInstanceCleanupFinalizer creates a new instance cleanup finalizer
type ServiceDeregisterFinalizer ¶
type ServiceDeregisterFinalizer struct {
*BaseFinalizer
// contains filtered or unexported fields
}
ServiceDeregisterFinalizer handles deregistering the service from service discovery
func NewServiceDeregisterFinalizer ¶
func NewServiceDeregisterFinalizer(store store.Store, logger log.Logger) *ServiceDeregisterFinalizer
NewServiceDeregisterFinalizer creates a new service deregister finalizer
type VolumeCleanupFinalizer ¶
type VolumeCleanupFinalizer struct {
*BaseFinalizer
// contains filtered or unexported fields
}
VolumeCleanupFinalizer removes Volume rows whose OwnerService matches the service being deleted. The VolumeController's WatchEventDeleted handler then runs the per-volume reclaim policy: drivers honour ReclaimPolicyDelete (call driver.Delete on the handle) and skip ReclaimPolicyRetain (leave the handle in place for later salvage).
Volumes without OwnerService set are NOT touched: those are operator- owned resources whose lifetime is independent of any one service.
Runs after instance cleanup so workloads cannot be re-attached to a volume that is about to be reclaimed, and before service deregister so the OwnerService back-pointer is still resolvable.
func NewVolumeCleanupFinalizer ¶
func NewVolumeCleanupFinalizer(store store.Store, logger log.Logger) *VolumeCleanupFinalizer
NewVolumeCleanupFinalizer creates a new volume cleanup finalizer.
func (*VolumeCleanupFinalizer) Execute ¶
Execute walks volumes in the service's namespace and:
- Clears BoundNode + BoundClaim on every volume claimed by an instance of this service. The agent's volumes Subsystem observes the update via its watch, shouldMount flips to false, and tearDown (Unmount + Detach) fires. For cloud-driver volumes with reclaimPolicy:retain this is the only step that happens — the Volume row stays, the operator manages the backing-store lifecycle out-of-band.
- For volumes the service OWNS (claimTemplate), also deletes the Volume row. The VolumeController's WatchEventDeleted handler then runs the per-volume reclaim policy.
Step 1 runs even for non-owned (operator-managed `claim:`) volumes so an in-place service teardown doesn't leave a stranded BoundClaim pointing at a Deleted instance — which would otherwise require an operator to `rune volume detach --force` before the volume could be reused.