fieldmanager

package
v0.23.7 Latest Latest
Warning

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

Go to latest
Published: May 26, 2022 License: Apache-2.0 Imports: 25 Imported by: 26

Documentation

Index

Constants

View Source
const DefaultMaxUpdateManagers int = 10

DefaultMaxUpdateManagers defines the default maximum retained number of managedFields entries from updates if the number of update managers exceeds this, the oldest entries will be merged until the number is below the maximum. TODO(jennybuckley): Determine if this is really the best value. Ideally we wouldn't unnecessarily merge too many entries.

View Source
const DefaultTrackOnCreateProbability float32 = 1

DefaultTrackOnCreateProbability defines the default probability that the field management of an object starts being tracked from the object's creation, instead of from the first time the object is applied to.

View Source
const InvalidManagedFieldsAfterMutatingAdmissionWarningFormat = "" /* 160-byte string literal not displayed */

InvalidManagedFieldsAfterMutatingAdmissionWarningFormat is the warning that a client receives when a create/update/patch request results in invalid managedFields after going through the admission chain.

Variables

This section is empty.

Functions

func NewManagedFieldsValidatingAdmissionController added in v0.21.0

func NewManagedFieldsValidatingAdmissionController(wrap admission.Interface) admission.Interface

NewManagedFieldsValidatingAdmissionController validates the managedFields after calling the provided admission and resets them to their original state if they got changed to an invalid value

Types

type DeducedTypeConverter added in v0.20.0

type DeducedTypeConverter struct{}

DeducedTypeConverter is a TypeConverter for CRDs that don't have a schema. It does implement the same interface though (and create the same types of objects), so that everything can still work the same. CRDs are merged with all their fields being "atomic" (lists included).

Note that this is not going to be sufficient for converting to/from CRDs that have a schema defined (we don't support that schema yet). TODO(jennybuckley): Use the schema provided by a CRD if it exists.

func (DeducedTypeConverter) ObjectToTyped added in v0.20.0

func (DeducedTypeConverter) ObjectToTyped(obj runtime.Object) (*typed.TypedValue, error)

ObjectToTyped converts an object into a TypedValue with a "deduced type".

func (DeducedTypeConverter) TypedToObject added in v0.20.0

func (DeducedTypeConverter) TypedToObject(value *typed.TypedValue) (runtime.Object, error)

TypedToObject transforms the typed value into a runtime.Object. That is not specific to deduced type.

type FieldManager

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

FieldManager updates the managed fields and merge applied configurations.

func NewDefaultCRDFieldManager added in v0.17.0

func NewDefaultCRDFieldManager(typeConverter TypeConverter, objectConverter runtime.ObjectConvertor, objectDefaulter runtime.ObjectDefaulter, objectCreater runtime.ObjectCreater, kind schema.GroupVersionKind, hub schema.GroupVersion, subresource string, resetFields map[fieldpath.APIVersion]*fieldpath.Set) (_ *FieldManager, err error)

NewDefaultCRDFieldManager creates a new FieldManager specifically for CRDs. This allows for the possibility of fields which are not defined in models, as well as having no models defined at all.

func NewDefaultFieldManager added in v0.17.0

func NewDefaultFieldManager(typeConverter TypeConverter, objectConverter runtime.ObjectConvertor, objectDefaulter runtime.ObjectDefaulter, objectCreater runtime.ObjectCreater, kind schema.GroupVersionKind, hub schema.GroupVersion, subresource string, resetFields map[fieldpath.APIVersion]*fieldpath.Set) (*FieldManager, error)

NewDefaultFieldManager creates a new FieldManager that merges apply requests and update managed fields for other types of requests.

func NewFieldManager

func NewFieldManager(f Manager, subresource string) *FieldManager

NewFieldManager creates a new FieldManager that decodes, manages, then re-encodes managedFields on update and apply requests.

func (*FieldManager) Apply

func (f *FieldManager) Apply(liveObj, appliedObj runtime.Object, manager string, force bool) (object runtime.Object, err error)

Apply is used when server-side apply is called, as it merges the object and updates the managed fields.

func (*FieldManager) Update

func (f *FieldManager) Update(liveObj, newObj runtime.Object, manager string) (object runtime.Object, err error)

Update is used when the object has already been merged (non-apply use-case), and simply updates the managed fields in the output object.

func (*FieldManager) UpdateNoErrors added in v0.16.11

func (f *FieldManager) UpdateNoErrors(liveObj, newObj runtime.Object, manager string) runtime.Object

UpdateNoErrors is the same as Update, but it will not return errors. If an error happens, the object is returned with managedFields cleared.

type Managed added in v0.17.0

type Managed interface {
	// Fields gets the fieldpath.ManagedFields.
	Fields() fieldpath.ManagedFields

	// Times gets the timestamps associated with each operation.
	Times() map[string]*metav1.Time
}

Managed groups a fieldpath.ManagedFields together with the timestamps associated with each operation.

func DecodeManagedFields added in v0.21.0

func DecodeManagedFields(encodedManagedFields []metav1.ManagedFieldsEntry) (Managed, error)

DecodeManagedFields converts ManagedFields from the wire format (api format) to the format used by sigs.k8s.io/structured-merge-diff

type Manager added in v0.17.0

type Manager interface {
	// Update is used when the object has already been merged (non-apply
	// use-case), and simply updates the managed fields in the output
	// object.
	//  * `liveObj` is not mutated by this function
	//  * `newObj` may be mutated by this function
	// Returns the new object with managedFields removed, and the object's new
	// proposed managedFields separately.
	Update(liveObj, newObj runtime.Object, managed Managed, manager string) (runtime.Object, Managed, error)

	// Apply is used when server-side apply is called, as it merges the
	// object and updates the managed fields.
	//  * `liveObj` is not mutated by this function
	//  * `newObj` may be mutated by this function
	// Returns the new object with managedFields removed, and the object's new
	// proposed managedFields separately.
	Apply(liveObj, appliedObj runtime.Object, managed Managed, fieldManager string, force bool) (runtime.Object, Managed, error)
}

Manager updates the managed fields and merges applied configurations.

func NewBuildManagerInfoManager added in v0.17.0

func NewBuildManagerInfoManager(f Manager, gv schema.GroupVersion, subresource string) Manager

NewBuildManagerInfoManager creates a new Manager that converts the manager name into a unique identifier combining operation and version for update requests, and just operation for apply requests.

func NewCRDStructuredMergeManager added in v0.17.0

func NewCRDStructuredMergeManager(typeConverter TypeConverter, objectConverter runtime.ObjectConvertor, objectDefaulter runtime.ObjectDefaulter, gv schema.GroupVersion, hub schema.GroupVersion, resetFields map[fieldpath.APIVersion]*fieldpath.Set) (_ Manager, err error)

NewCRDStructuredMergeManager creates a new Manager specifically for CRDs. This allows for the possibility of fields which are not defined in models, as well as having no models defined at all.

func NewCapManagersManager added in v0.17.0

func NewCapManagersManager(fieldManager Manager, maxUpdateManagers int) Manager

NewCapManagersManager creates a new wrapped FieldManager which ensures that the number of managers from updates does not exceed maxUpdateManagers, by merging some of the oldest entries on each update.

func NewLastAppliedManager added in v0.19.0

func NewLastAppliedManager(fieldManager Manager, typeConverter TypeConverter, objectConverter runtime.ObjectConvertor, groupVersion schema.GroupVersion) Manager

NewLastAppliedManager converts the client-side apply annotation to server-side apply managed fields

func NewLastAppliedUpdater added in v0.19.0

func NewLastAppliedUpdater(fieldManager Manager) Manager

NewLastAppliedUpdater sets the client-side apply annotation up to date with server-side apply managed fields

func NewManagedFieldsUpdater added in v0.18.0

func NewManagedFieldsUpdater(fieldManager Manager) Manager

NewManagedFieldsUpdater is responsible for updating the managedfields in the object, updating the time of the operation as necessary. For updates, it uses a hard-coded manager to detect if things have changed, and swaps back the correct manager after the operation is done.

func NewProbabilisticSkipNonAppliedManager added in v0.18.0

func NewProbabilisticSkipNonAppliedManager(fieldManager Manager, objectCreater runtime.ObjectCreater, gvk schema.GroupVersionKind, p float32) Manager

NewProbabilisticSkipNonAppliedManager creates a new wrapped FieldManager that starts tracking managers after the first apply, or starts tracking on create with p probability.

func NewSkipNonAppliedManager added in v0.17.0

func NewSkipNonAppliedManager(fieldManager Manager, objectCreater runtime.ObjectCreater, gvk schema.GroupVersionKind) Manager

NewSkipNonAppliedManager creates a new wrapped FieldManager that only starts tracking managers after the first apply.

func NewStripMetaManager added in v0.17.0

func NewStripMetaManager(fieldManager Manager) Manager

NewStripMetaManager creates a new Manager that strips metadata and typemeta fields from the manager's fieldset.

func NewStructuredMergeManager added in v0.17.0

func NewStructuredMergeManager(typeConverter TypeConverter, objectConverter runtime.ObjectConvertor, objectDefaulter runtime.ObjectDefaulter, gv schema.GroupVersion, hub schema.GroupVersion, resetFields map[fieldpath.APIVersion]*fieldpath.Set) (Manager, error)

NewStructuredMergeManager creates a new Manager that merges apply requests and update managed fields for other types of requests.

type ResourcePathMappings added in v0.22.0

type ResourcePathMappings map[string]fieldpath.Path

ResourcePathMappings maps a group/version to its replicas path. The assumption is that all the paths correspond to leaf fields.

type ScaleHandler added in v0.22.0

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

ScaleHandler manages the conversion of managed fields between a main resource and the scale subresource

func NewScaleHandler added in v0.22.0

func NewScaleHandler(parentEntries []metav1.ManagedFieldsEntry, groupVersion schema.GroupVersion, mappings ResourcePathMappings) *ScaleHandler

NewScaleHandler creates a new ScaleHandler

func (*ScaleHandler) ToParent added in v0.22.0

func (h *ScaleHandler) ToParent(scaleEntries []metav1.ManagedFieldsEntry) ([]metav1.ManagedFieldsEntry, error)

ToParent merges `scaleEntries` with the entries of the main resource and transforms them accordingly

func (*ScaleHandler) ToSubresource added in v0.22.0

func (h *ScaleHandler) ToSubresource() ([]metav1.ManagedFieldsEntry, error)

ToSubresource filter the managed fields of the main resource and convert them so that they can be handled by scale. For the managed fields that have a replicas path it performs two changes:

  1. APIVersion is changed to the APIVersion of the scale subresource
  2. Replicas path of the main resource is transformed to the replicas path of the scale subresource

type TypeConverter added in v0.20.0

type TypeConverter interface {
	ObjectToTyped(runtime.Object) (*typed.TypedValue, error)
	TypedToObject(*typed.TypedValue) (runtime.Object, error)
}

TypeConverter allows you to convert from runtime.Object to typed.TypedValue and the other way around.

func NewTypeConverter added in v0.20.0

func NewTypeConverter(models proto.Models, preserveUnknownFields bool) (TypeConverter, error)

NewTypeConverter builds a TypeConverter from a proto.Models. This will automatically find the proper version of the object, and the corresponding schema information.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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