resourcekeeper

package
v1.9.11 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// AllowCrossNamespaceResource indicates whether application can apply resources into other namespaces
	AllowCrossNamespaceResource = true
	// AllowResourceTypes if not empty, application can only apply resources with specified types
	AllowResourceTypes = ""
)
View Source
var (
	// MarkWithProbability optimize ResourceTracker gc for legacy resource by reducing the frequency of outdated rt check
	MarkWithProbability = 0.1
)
View Source
var MaxDispatchConcurrent = 10

MaxDispatchConcurrent is the max dispatch concurrent number

Functions

func ApplyStrategies added in v1.4.0

func ApplyStrategies(ctx context.Context, h *resourceKeeper, manifest *unstructured.Unstructured, matchedAffectStage v1alpha1.ApplyOnceAffectStrategy) (*unstructured.Unstructured, error)

ApplyStrategies will generate manifest with applyOnceStrategy

func DeleteManagedResourceInApplication added in v1.7.0

func DeleteManagedResourceInApplication(ctx context.Context, cli client.Client, mr v1beta1.ManagedResource, obj *unstructured.Unstructured, app *v1beta1.Application) error

DeleteManagedResourceInApplication delete managed resource in application

func IsResourceManagedByApplication added in v1.7.0

func IsResourceManagedByApplication(manifest *unstructured.Unstructured, app *v1beta1.Application) bool

IsResourceManagedByApplication check if resource is managed by application If the resource has no ResourceVersion, always return true. If the owner label of the resource equals the given app, return true. If the sharer label of the resource contains the given app, return true. Otherwise, return false.

func ListApplicationRevisions added in v1.9.0

func ListApplicationRevisions(ctx context.Context, cli client.Client, appName string, appNs string) ([]v1beta1.ApplicationRevision, error)

ListApplicationRevisions get application revisions by label

func PhaseFrom added in v1.9.0

func PhaseFrom(ctx context.Context) common.ApplicationPhase

PhaseFrom extract phase from context

func UpdateSharedManagedResourceOwner added in v1.7.0

func UpdateSharedManagedResourceOwner(ctx context.Context, cli client.Client, manifest *unstructured.Unstructured, sharedBy string) error

UpdateSharedManagedResourceOwner update owner & sharer labels for managed resource

func WithPhase added in v1.9.0

func WithPhase(ctx context.Context, phase common.ApplicationPhase) context.Context

WithPhase inject phase into context

Types

type AppRevisionLimitGCOption added in v1.9.0

type AppRevisionLimitGCOption int

AppRevisionLimitGCOption is the maximum number of application revisions that will be maintained

func (AppRevisionLimitGCOption) ApplyToGCConfig added in v1.9.0

func (option AppRevisionLimitGCOption) ApplyToGCConfig(cfg *gcConfig)

ApplyToGCConfig apply change to gc config

type CreatorOption added in v1.4.0

type CreatorOption struct {
	Creator string
}

CreatorOption set the creator of the resource

func (CreatorOption) ApplyToDispatchConfig added in v1.4.0

func (option CreatorOption) ApplyToDispatchConfig(cfg *dispatchConfig)

ApplyToDispatchConfig apply change to dispatch config

type DeleteOption

type DeleteOption interface {
	ApplyToDeleteConfig(*deleteConfig)
}

DeleteOption option for delete

type DependencyGCOption added in v1.4.0

type DependencyGCOption struct{}

DependencyGCOption recycle the resource in the order of reverse dependency

func (DependencyGCOption) ApplyToGCConfig added in v1.4.0

func (option DependencyGCOption) ApplyToGCConfig(cfg *gcConfig)

ApplyToGCConfig apply change to gc config

type DisableApplicationRevisionGCOption added in v1.9.0

type DisableApplicationRevisionGCOption struct{}

DisableApplicationRevisionGCOption disable garbage collect application revision resourcetrackers

func (DisableApplicationRevisionGCOption) ApplyToGCConfig added in v1.9.0

func (option DisableApplicationRevisionGCOption) ApplyToGCConfig(cfg *gcConfig)

ApplyToGCConfig apply change to gc config

type DisableGCComponentRevisionOption

type DisableGCComponentRevisionOption struct{}

DisableGCComponentRevisionOption disable the component revision gc process this option should be switched on when application workflow is suspending/terminating

func (DisableGCComponentRevisionOption) ApplyToGCConfig

func (option DisableGCComponentRevisionOption) ApplyToGCConfig(cfg *gcConfig)

ApplyToGCConfig apply change to gc config

type DisableLegacyGCOption

type DisableLegacyGCOption struct{}

DisableLegacyGCOption disable garbage collect legacy resourcetrackers

func (DisableLegacyGCOption) ApplyToGCConfig

func (option DisableLegacyGCOption) ApplyToGCConfig(cfg *gcConfig)

ApplyToGCConfig apply change to gc config

type DisableMarkStageGCOption

type DisableMarkStageGCOption struct{}

DisableMarkStageGCOption disable the mark stage in gc process (no rt will be marked to be deleted) this option should be switched on when application workflow is suspending/terminating since workflow is not finished so outdated versions should be kept

func (DisableMarkStageGCOption) ApplyToGCConfig

func (option DisableMarkStageGCOption) ApplyToGCConfig(cfg *gcConfig)

ApplyToGCConfig apply change to gc config

type DispatchOption

type DispatchOption interface {
	ApplyToDispatchConfig(*dispatchConfig)
}

DispatchOption option for dispatch

type GCOption

type GCOption interface {
	ApplyToGCConfig(*gcConfig)
}

GCOption option for gc

type GarbageCollectStrategyOption

type GarbageCollectStrategyOption v1alpha1.GarbageCollectStrategy

GarbageCollectStrategyOption apply garbage collect strategy to resourcetracker recording

func (GarbageCollectStrategyOption) ApplyToDeleteConfig

func (option GarbageCollectStrategyOption) ApplyToDeleteConfig(cfg *deleteConfig)

ApplyToDeleteConfig apply change to delete config

func (GarbageCollectStrategyOption) ApplyToDispatchConfig

func (option GarbageCollectStrategyOption) ApplyToDispatchConfig(cfg *dispatchConfig)

ApplyToDispatchConfig apply change to dispatch config

type MetaOnlyOption

type MetaOnlyOption struct{}

MetaOnlyOption record only meta part in resourcetracker, which disables the configuration-drift-prevention

func (MetaOnlyOption) ApplyToDispatchConfig

func (option MetaOnlyOption) ApplyToDispatchConfig(cfg *dispatchConfig)

ApplyToDispatchConfig apply change to dispatch config

type NamespaceAdmissionHandler added in v1.3.0

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

NamespaceAdmissionHandler defines the handler to validate if the resource namespace is valid to be dispatch/delete

func (*NamespaceAdmissionHandler) Validate added in v1.3.0

Validate check if cross namespace is available

type PassiveGCOption

type PassiveGCOption struct{}

PassiveGCOption disable the active gc for outdated versions. Old versioned resourcetracker will not be recycled except all of their managed resources have already been deleted or controlled by later resourcetrackers.

func (PassiveGCOption) ApplyToGCConfig

func (option PassiveGCOption) ApplyToGCConfig(cfg *gcConfig)

ApplyToGCConfig apply change to gc config

type ResourceAdmissionHandler added in v1.3.0

type ResourceAdmissionHandler interface {
	Validate(ctx context.Context, manifests []*unstructured.Unstructured) error
}

ResourceAdmissionHandler defines the handler to validate the admission of resource operation

type ResourceKeeper

type ResourceKeeper interface {
	Dispatch(context.Context, []*unstructured.Unstructured, []apply.ApplyOption, ...DispatchOption) error
	Delete(context.Context, []*unstructured.Unstructured, ...DeleteOption) error
	GarbageCollect(context.Context, ...GCOption) (bool, []v1beta1.ManagedResource, error)
	StateKeep(context.Context) error
	ContainsResources([]*unstructured.Unstructured) bool

	DispatchComponentRevision(context.Context, *appsv1.ControllerRevision) error
	DeleteComponentRevision(context.Context, *appsv1.ControllerRevision) error
}

ResourceKeeper handler for dispatching and deleting resources

func NewResourceKeeper

func NewResourceKeeper(ctx context.Context, cli client.Client, app *v1beta1.Application) (_ ResourceKeeper, err error)

NewResourceKeeper create a handler for dispatching and deleting resources

type ResourceTypeAdmissionHandler added in v1.3.0

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

ResourceTypeAdmissionHandler defines the handler to validate if the resource type is valid to be dispatch/delete

func (*ResourceTypeAdmissionHandler) Validate added in v1.3.0

Validate check if resource type is valid

type SkipGCOption added in v1.5.0

type SkipGCOption struct{}

SkipGCOption marks the recorded resource to skip gc

func (SkipGCOption) ApplyToDeleteConfig added in v1.5.0

func (option SkipGCOption) ApplyToDeleteConfig(cfg *deleteConfig)

ApplyToDeleteConfig apply change to delete config

func (SkipGCOption) ApplyToDispatchConfig added in v1.5.0

func (option SkipGCOption) ApplyToDispatchConfig(cfg *dispatchConfig)

ApplyToDispatchConfig apply change to dispatch config

type UseRootOption

type UseRootOption struct{}

UseRootOption let the recording and management of target resource belongs to the RootRT instead of VersionedRT. This will let the resource be alive as long as the application is still alive.

func (UseRootOption) ApplyToDeleteConfig

func (option UseRootOption) ApplyToDeleteConfig(cfg *deleteConfig)

ApplyToDeleteConfig apply change to delete config

func (UseRootOption) ApplyToDispatchConfig

func (option UseRootOption) ApplyToDispatchConfig(cfg *dispatchConfig)

ApplyToDispatchConfig apply change to dispatch config

Jump to

Keyboard shortcuts

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