Documentation ¶
Index ¶
- func ConstructResourceTrackerName(appRevName, ns string) string
- func ExtractAppName(resourceTrackerName, ns string) string
- func ExtractAppRevisionName(resourceTrackerName, ns string) string
- type AppManifestsDispatcher
- func (a *AppManifestsDispatcher) DereferenceScopes(ctx context.Context, wlRef *v1.ObjectReference, scopes []*v1.ObjectReference) error
- func (a *AppManifestsDispatcher) Dispatch(ctx context.Context, manifests []*unstructured.Unstructured) (*v1beta1.ResourceTracker, error)
- func (a *AppManifestsDispatcher) EndAndGC(rt *v1beta1.ResourceTracker) *AppManifestsDispatcher
- func (a *AppManifestsDispatcher) ImmutableResourcesUpdate(ctx context.Context, res *unstructured.Unstructured, ...) (bool, error)
- func (a *AppManifestsDispatcher) ReferenceScopes(ctx context.Context, wlRef *v1.ObjectReference, scopes []*v1.ObjectReference) error
- func (a *AppManifestsDispatcher) StartAndSkipGC(previousRT *v1beta1.ResourceTracker) *AppManifestsDispatcher
- type GCHandler
- type GarbageCollector
- type ObjectOwner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConstructResourceTrackerName ¶
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 ¶
ExtractAppName get application name from resource tracker name
func ExtractAppRevisionName ¶
ExtractAppRevisionName get application revision name from resource tracker name
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 ¶
func (a *AppManifestsDispatcher) Dispatch(ctx context.Context, manifests []*unstructured.Unstructured) (*v1beta1.ResourceTracker, error)
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 ¶
func (a *AppManifestsDispatcher) EndAndGC(rt *v1beta1.ResourceTracker) *AppManifestsDispatcher
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 ¶
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