dispatch

package
v1.1.11 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2021 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConstructResourceTrackerName

func ConstructResourceTrackerName(appRevName, ns string) string

ConstructResourceTrackerName generates resource tracker name with given app revision name and namespace. App revision name and namespace must be non-empty. The logic of this package is highly coupled with this naming rule!

func ExtractAppName

func ExtractAppName(resourceTrackerName, ns string) string

ExtractAppName get application name from resource tracker name

func ExtractAppRevisionName

func ExtractAppRevisionName(resourceTrackerName, ns string) string

ExtractAppRevisionName get application revision name from resource tracker name

func IsLifeLongResourceTracker added in v1.1.4

func IsLifeLongResourceTracker(rt v1beta1.ResourceTracker) bool

IsLifeLongResourceTracker check if resourcetracker shares the same whole life with the entire application

Types

type AppManifestsDispatcher

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

AppManifestsDispatcher dispatch application manifests into K8s and record the dispatched manifests' references in a resource tracker which is named by a particular rule: name = appRevision's Name + appRevision's namespace. A bundle of manifests to be dispatched MUST come from the given application revision.

func NewAppManifestsDispatcher

func NewAppManifestsDispatcher(c client.Client, appRev *v1beta1.ApplicationRevision) *AppManifestsDispatcher

NewAppManifestsDispatcher creates an AppManifestsDispatcher.

func (*AppManifestsDispatcher) DereferenceScopes

func (a *AppManifestsDispatcher) DereferenceScopes(ctx context.Context, wlRef *v1.ObjectReference, scopes []*v1.ObjectReference) error

DereferenceScopes remove workload reference from scopes' workloadRefPath

func (*AppManifestsDispatcher) Dispatch

Dispatch apply manifests into k8s and return a resource tracker recording applied manifests' references. If GC is enabled, it will do GC after applying. If 'UpgradeAndSkipGC' is enabled, it will: - create new resources if not exist before - update unchanged resources' owner from the previous resource tracker to the new one - skip deleting(GC) any resources

func (*AppManifestsDispatcher) EndAndGC

EndAndGC return an AppManifestsDispatcher that do GC after dispatching resources. For resources exists in two revision, dispatcher will update their owner to the new resource tracker. GC will calculate diff between the dispatched resources and ones recorded in the given resource tracker.

func (*AppManifestsDispatcher) ImmutableResourcesUpdate

func (a *AppManifestsDispatcher) ImmutableResourcesUpdate(ctx context.Context, res *unstructured.Unstructured, ownerRef metav1.OwnerReference, applyOpts []apply.ApplyOption) (bool, error)

ImmutableResourcesUpdate only updates the ownerReference TODO(wonderflow): we should allow special fields to be updated. e.g. the resources.requests for bound claims for PV should be able to update

func (*AppManifestsDispatcher) ReferenceScopes

func (a *AppManifestsDispatcher) ReferenceScopes(ctx context.Context, wlRef *v1.ObjectReference, scopes []*v1.ObjectReference) error

ReferenceScopes add workload reference to scopes' workloadRefPath

func (*AppManifestsDispatcher) StartAndSkipGC

func (a *AppManifestsDispatcher) StartAndSkipGC(previousRT *v1beta1.ResourceTracker) *AppManifestsDispatcher

StartAndSkipGC return an AppManifestsDispatcher that skips GC after dispatching resources. For resources exists in two revision, dispatcher will update their owner to the new resource tracker. It's helpful in a rollout scenario where new revision is going to create a new workload while the old one should not be deleted before rollout is terminated.

type GCHandler

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

GCHandler implement GarbageCollector interface

func NewGCHandler

func NewGCHandler(c client.Client, ns string, appRev v1beta1.ApplicationRevision) *GCHandler

NewGCHandler create a GCHandler

func (*GCHandler) GarbageCollect

func (h *GCHandler) GarbageCollect(ctx context.Context, oldRT, newRT *v1beta1.ResourceTracker, legacyRTs []*v1beta1.ResourceTracker) error

GarbageCollect delete the old resources that are no longer in the new resource tracker

type GarbageCollector

type GarbageCollector interface {
	GarbageCollect(ctx context.Context, oldRT, newRT *v1beta1.ResourceTracker, legacyRTs []*v1beta1.ResourceTracker) error
}

GarbageCollector do GC according two resource trackers

type ObjectOwner

type ObjectOwner interface {
	GetOwnerReferences() []metav1.OwnerReference
	SetOwnerReferences([]metav1.OwnerReference)
}

ObjectOwner is a interface for get and set ownerReference

Jump to

Keyboard shortcuts

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