Documentation
¶
Overview ¶
Package ssa contains utils related to Server-Side-Apply.
Index ¶
- func ComputeRequestIdentifier(scheme *runtime.Scheme, resourceVersion string, obj client.Object) (string, error)
- func FilterIntent(ctx *FilterIntentInput) bool
- func FilterObject(obj *unstructured.Unstructured, input *FilterObjectInput)
- func IsPathAllowed(allowedPaths []contract.Path) func(path contract.Path) bool
- func IsPathIgnored(ignorePaths []contract.Path) func(path contract.Path) bool
- func IsPathNotAllowed(allowedPaths []contract.Path) func(path contract.Path) bool
- func MigrateManagedFields(ctx context.Context, c client.Client, object client.Object, ...) error
- func Patch(ctx context.Context, c client.Client, fieldManager string, ...) error
- func RemoveManagedFieldsForLabelsAndAnnotations(ctx context.Context, c client.Client, apiReader client.Reader, ...) error
- type Cache
- type FilterIntentInput
- type FilterObjectInput
- type Option
- type Options
- type WithCachingProxy
- type WithDryRun
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComputeRequestIdentifier ¶
func ComputeRequestIdentifier(scheme *runtime.Scheme, resourceVersion string, obj client.Object) (string, error)
ComputeRequestIdentifier computes a request identifier for the cache. The identifier is unique for a specific request to ensure we don't have to re-run the request once we found out that it would not produce a diff. The identifier consists of: gvk, namespace, name and resourceVersion of the object and a hash of the modified object. This ensures that we re-run the request as soon as anything changes.
func FilterIntent ¶
func FilterIntent(ctx *FilterIntentInput) bool
FilterIntent ensures that object only includes the fields and values for which the controller has an opinion, and filter out everything else by removing it from the Value. NOTE: This func is called recursively only for fields of type Map, but this is ok given the current use cases this func has to address. More specifically, we are using this func for filtering out not allowed paths and for ignore paths; all of them are defined in reconcile_state.go and are targeting well-known fields inside nested maps. Allowed paths / ignore paths which point to an array are not supported by the current implementation.
func FilterObject ¶
func FilterObject(obj *unstructured.Unstructured, input *FilterObjectInput)
FilterObject filter out changes not relevant for the controller.
func IsPathAllowed ¶ added in v1.5.0
IsPathAllowed returns true when the Path is one of the AllowedPaths.
func IsPathIgnored ¶ added in v1.5.0
IsPathIgnored returns true when the Path is one of the IgnorePaths.
func IsPathNotAllowed ¶ added in v1.5.0
IsPathNotAllowed returns true when the Path is NOT one of the AllowedPaths.
func MigrateManagedFields ¶
func MigrateManagedFields(ctx context.Context, c client.Client, object client.Object, fieldManager, metadataFieldManager string) error
MigrateManagedFields migrates managedFields. ManagedFields are only migrated if fieldManager owns labels+annotations The migration deletes all non-status managedField entries for fieldManager:Apply and manager:Update. Additionally it adds a seed entry for metadataFieldManager. Note: We have to call this func for every Machine created with CAPI <= v1.11 once. Given that this was introduced in CAPI v1.12 and our n-3 upgrade policy this can be removed with CAPI v1.15.
func Patch ¶
func Patch(ctx context.Context, c client.Client, fieldManager string, modified client.Object, opts ...Option) error
Patch executes an SSA patch. If WithCachingProxy is set and the request didn't change the object we will cache this result, so subsequent calls don't have to run SSA again.
func RemoveManagedFieldsForLabelsAndAnnotations ¶
func RemoveManagedFieldsForLabelsAndAnnotations(ctx context.Context, c client.Client, apiReader client.Reader, object client.Object, fieldManager string) error
RemoveManagedFieldsForLabelsAndAnnotations removes labels and annotations from managedFields entries. This func is e.g. used in the following context: * First a full object is created with fieldManager. * Then this func is called to drop ownership for labels and annotations * And then in a subsequent syncMachines call a metadataFieldManager can take ownership for labels and annotations. Note: This is done so that this func does not rely on managedFields being stored in the cache, so we can optimize memory usage by dropping managedFields before storing objects in the cache.
Types ¶
type Cache ¶
type Cache interface {
// Add adds the given key to the Cache.
// Note: keys expire after the ttl.
Add(key string)
// Has checks if the given key (still) exists in the Cache.
// Note: keys expire after the ttl.
Has(key, kind string) bool
}
Cache caches SSA request results. Specifically we only use it to cache that a certain request doesn't have to be repeated anymore because there was no diff.
type FilterIntentInput ¶
type FilterIntentInput struct {
// the Path of the field being processed.
Path contract.Path
// the Value for the current Path.
Value interface{}
// ShouldFilter handle the func that determine if the current Path should be dropped or not.
ShouldFilter func(path contract.Path) bool
}
FilterIntentInput holds info required while filtering the intent for server side apply. NOTE: in server side apply an intent is a partial object that only includes the fields and values for which the user has an opinion.
type FilterObjectInput ¶
type FilterObjectInput struct {
// AllowedPaths instruct FilterObject to ignore everything except given paths.
AllowedPaths []contract.Path
// IgnorePaths instruct FilterObject to ignore given paths.
// NOTE: IgnorePaths are used to filter out fields nested inside AllowedPaths, e.g.
// spec.ControlPlaneEndpoint.
// NOTE: ignore paths which point to an array are not supported by the current implementation.
IgnorePaths []contract.Path
}
FilterObjectInput holds info required while filtering the object.
type Option ¶
type Option interface {
// ApplyToOptions applies this configuration to the given Options.
ApplyToOptions(*Options)
}
Option is the interface for configuration that modifies Options for a patch request.
type WithCachingProxy ¶
WithCachingProxy enables caching for the patch request. The original and modified object will be used to generate an identifier for the request. The cache will be used to cache the result of the request.
func (WithCachingProxy) ApplyToOptions ¶
func (w WithCachingProxy) ApplyToOptions(in *Options)
ApplyToOptions applies WithCachingProxy to the given Options.
type WithDryRun ¶
type WithDryRun struct{}
WithDryRun enables the DryRunAll option.
func (WithDryRun) ApplyToOptions ¶
func (w WithDryRun) ApplyToOptions(in *Options)
ApplyToOptions applies WithDryRun to the given Options.