reconciler

package
v1.16.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FinalizerName is the string that is used as finalizer on managed resource
	// objects.
	FinalizerName = "finalizer.managedresource.krateo.io"
)
View Source
const ReasonReadyNotSetAfterObserve event.Reason = "ReadyNotSetAfterObserve"

Event reasons. ReasonReadyNotSetAfterObserve is the reason of the Warning event the runtime records when a provider breaks the Ready contract: Observe succeeded but left Ready at NotObserved. Exported so providers' tests can assert on the event. See the Ready contract on ExternalClient.Observe.

Variables

This section is empty.

Functions

func ControllerName

func ControllerName(kind string) string

ControllerName returns the recommended name for controllers that use this package to reconcile a particular kind of managed resource.

func IsReadyAssessed added in v1.8.0

func IsReadyAssessed(err error) bool

IsReadyAssessed reports whether err, or any error it wraps, was marked with ReadyAssessed. It is false for a nil error.

func ReadyAssessed added in v1.8.0

func ReadyAssessed(err error) error

ReadyAssessed marks err, returned by Connect or Observe, as one that does not concern readiness: the provider set the Ready condition itself during this call, and the error is about something else (for example a write that failed after the external resource was read). The runtime then leaves Ready as the provider set it, instead of setting it to NotObserved. Synced still reports err as a ReconcileError. See the Ready contract on ExternalClient.Observe.

Wrap only when the provider really set Ready on this call. An error that means "I could not tell" must not be wrapped: there Ready=NotObserved is the truthful answer.

The message of the returned error is err's, and errors.Is, errors.As and errors.Unwrap see through it to err. ReadyAssessed(nil) returns nil, so

return obs, reconciler.ReadyAssessed(err)

is safe whether or not err is nil.

Types

type CriticalAnnotationUpdateFn

type CriticalAnnotationUpdateFn func(ctx context.Context, o client.Object) error

A CriticalAnnotationUpdateFn may be used when it is critical that annotations must be updated before returning from the Reconcile loop.

func (CriticalAnnotationUpdateFn) UpdateCriticalAnnotations

func (fn CriticalAnnotationUpdateFn) UpdateCriticalAnnotations(ctx context.Context, o client.Object) error

UpdateCriticalAnnotations of the supplied object.

type CriticalAnnotationUpdater

type CriticalAnnotationUpdater interface {
	UpdateCriticalAnnotations(ctx context.Context, o client.Object) error
}

A CriticalAnnotationUpdater is used when it is critical that annotations must be updated before returning from the Reconcile loop.

type ExternalClient

type ExternalClient interface {
	// Observe the external resource the supplied Managed resource
	// represents, if any. Observe implementations must not modify the
	// external resource, but may update the supplied Managed resource to
	// reflect the state of the external resource. Status modifications are
	// automatically persisted unless ResourceLateInitialized is true - see
	// ResourceLateInitialized for more detail.
	//
	// When the external resource does not exist, return ResourceExists: false
	// with a nil error. An error ends the reconcile before Create and before
	// an unresolved create handshake can be resolved, which needs Observe's
	// answer. Before returning an error, ask whether answering
	// ResourceExists: false could make Create duplicate the resource. If not,
	// answer. If so, return an error only for a transient failure that a
	// retry can resolve; a permanent one (for example a local template that
	// never renders) keeps the resource stuck until the provider changes.
	// See docs/overview.md.
	//
	// Every Observe that returns a nil error must set the Ready condition on
	// mg, on every path, including those that report ResourceExists: false.
	// When Connect or Observe returns an error, the runtime sets Ready to
	// NotObserved (Status Unknown) next to the error on Synced, unless Ready
	// is Deleting or the error is wrapped with ReadyAssessed, which an Observe
	// returns when it set Ready itself and the error concerns something else.
	// The runtime never sets Ready on recovery: a successful Observe that
	// leaves Ready at NotObserved is reported as a provider defect.
	// reconcilertest.AssertObserveSetsReady checks this in a provider's tests.
	Observe(ctx context.Context, mg resource.Managed) (ExternalObservation, error)

	// Create an external resource per the specifications of the supplied
	// Managed resource. Called when Observe reports that the associated
	// external resource does not exist. Create implementations may update
	// managed resource annotations, and those updates will be persisted.
	// All other updates will be discarded.
	Create(ctx context.Context, mg resource.Managed) error

	// Update the external resource represented by the supplied Managed
	// resource, if necessary. Called unless Observe reports that the
	// associated external resource is up to date.
	Update(ctx context.Context, mg resource.Managed) error

	// Delete the external resource upon deletion of its associated Managed
	// resource. Called when the managed resource has been deleted.
	Delete(ctx context.Context, mg resource.Managed) error
}

An ExternalClient manages the lifecycle of an external resource. None of the calls here should be blocking. All of the calls should be idempotent. For example, Create call should not return AlreadyExists error if it's called again with the same parameters or Delete call should not return error if there is an ongoing deletion or resource does not exist.

Each method's ctx holds its own child span of the reconcile (observe, create, update or delete) with tracing on: use it for the calls the method makes, and bind a Logger to it with logging.WithContext, so they join the trace. Never use a ctx kept from Connect.

A method that writes the managed object to the API server must leave mg describing what is stored. Write mg itself, so the client decodes the response into it. Or write a copy that carries mg's resourceVersion, then copy the new resourceVersion and every field you wrote onto mg. Never copy only the resourceVersion: the runtime's next write would succeed and revert your write. A method that re-reads before writing must copy the whole written object onto mg, not only its version, or it can revert another writer's change. A write that leaves mg stale makes the runtime's next write of the object fail with a conflict. After Observe, that includes the finalizer, create-pending and marker writes as well as status.

Copy the new resourceVersion onto mg only after a write succeeded: an attempt that read and then failed to write must leave mg untouched. A wrong version succeeds against the wrong object state; a stale one fails loudly.

A re-read-then-write still reverts a change someone else made between the runtime's read and yours, including a human's status patch; write mg itself if that matters.

The runtime does not retry or merge a status write that conflicts. It returns the error, which names this rule and keeps the pass's own error. reconcilertest.AssertLeavesManagedCurrent checks the rule in a provider's tests.

type ExternalClientFns

type ExternalClientFns struct {
	ObserveFn func(ctx context.Context, mg resource.Managed) (ExternalObservation, error)
	CreateFn  func(ctx context.Context, mg resource.Managed) error
	UpdateFn  func(ctx context.Context, mg resource.Managed) error
	DeleteFn  func(ctx context.Context, mg resource.Managed) error
}

ExternalClientFns are a series of functions that satisfy the ExternalClient interface.

func (ExternalClientFns) Create

Create an external resource per the specifications of the supplied Managed resource.

func (ExternalClientFns) Delete

Delete the external resource upon deletion of its associated Managed resource.

func (ExternalClientFns) Observe

Observe the external resource the supplied Managed resource represents, if any.

func (ExternalClientFns) Update

Update the external resource represented by the supplied Managed resource, if necessary.

type ExternalConnectDisconnecter

type ExternalConnectDisconnecter interface {
	ExternalConnecter
	ExternalDisconnecter
}

An ExternalConnectDisconnecter produces a new ExternalClient given the supplied Managed resource.

func NewNopDisconnecter

func NewNopDisconnecter(c ExternalConnecter) ExternalConnectDisconnecter

NewNopDisconnecter converts an ExternalConnecter into an ExternalConnectDisconnecter with a no-op Disconnect method.

type ExternalConnectDisconnecterFns

type ExternalConnectDisconnecterFns struct {
	ConnectFn    func(ctx context.Context, mg resource.Managed) (ExternalClient, error)
	DisconnectFn func(ctx context.Context) error
}

ExternalConnectDisconnecterFns are functions that satisfy the ExternalConnectDisconnecter interface.

func (ExternalConnectDisconnecterFns) Connect

Connect to the provider specified by the supplied managed resource and produce an ExternalClient.

func (ExternalConnectDisconnecterFns) Disconnect

Disconnect from the provider and close the ExternalClient.

type ExternalConnecter

type ExternalConnecter interface {
	// Connect to the provider specified by the supplied managed resource and
	// produce an ExternalClient.
	Connect(ctx context.Context, mg resource.Managed) (ExternalClient, error)
}

An ExternalConnecter produces a new ExternalClient given the supplied Managed resource.

With tracing on, Connect's ctx holds the reconcile's connect span, which ends when Connect returns. An ExternalClient built here must not keep that ctx for later calls: each ExternalClient method gets its own ctx, with its own span, and must use that one (docs/design-tracing.md §4.4).

type ExternalConnectorFn

type ExternalConnectorFn func(ctx context.Context, mg resource.Managed) (ExternalClient, error)

An ExternalConnectorFn is a function that satisfies the ExternalConnecter interface.

func (ExternalConnectorFn) Connect

Connect to the provider specified by the supplied managed resource and produce an ExternalClient.

type ExternalDisconnecter

type ExternalDisconnecter interface {
	// Disconnect from the provider and close the ExternalClient.
	Disconnect(ctx context.Context) error
}

An ExternalDisconnecter disconnects from a provider.

type ExternalDisconnectorFn

type ExternalDisconnectorFn func(ctx context.Context) error

An ExternalDisconnectorFn is a function that satisfies the ExternalConnecter interface.

func (ExternalDisconnectorFn) Disconnect

func (ed ExternalDisconnectorFn) Disconnect(ctx context.Context) error

Disconnect from provider and close the ExternalClient.

type ExternalObservation

type ExternalObservation struct {
	// ResourceExists must be true if a corresponding external resource exists
	// for the managed resource. Typically this is proven by the presence of an
	// external resource of the expected kind whose unique identifier matches
	// the managed resource's external name. The Provider Runtime uses this information to
	// determine whether it needs to create or delete the external resource.
	ResourceExists bool

	// ResourceUpToDate should be true if the corresponding external resource
	// appears to be up-to-date - i.e. updating the external resource to match
	// the desired state of the managed resource would be a no-op. Keep in mind
	// that often only a subset of external resource fields can be updated.
	// The Provider Runtime uses this information to determine whether it needs to update
	// the external resource.
	ResourceUpToDate bool

	// ResourceLateInitialized should be true if the managed resource's spec was
	// updated during its observation. A provider may update a
	// managed resource's spec fields after it is created or updated, as long as
	// the updates are limited to setting previously unset fields, and adding
	// keys to maps. Provider Runtime uses this information to determine whether
	// changes to the spec were made during observation that must be persisted.
	// Note that changes to the spec will be persisted before changes to the
	// status, and that pending changes to the status may be lost when the spec
	// is persisted. Status changes will be persisted by the first subsequent
	// observation that _does not_ late initialize the managed resource, so it
	// is important that Observe implementations do not late initialize the
	// resource every time they are called.
	ResourceLateInitialized bool

	// Diff is a Debug level message that is sent to the reconciler when
	// there is a change in the observed Managed Resource. It is useful for
	// finding where the observed diverges from the desired state.
	// The string should be a cmp.Diff that details the difference.
	Diff string
}

An ExternalObservation is the result of an observation of an external resource.

type MetricsRecorder

type MetricsRecorder interface {
	RecordGetDuration(ctx context.Context, d time.Duration)
	IncGetFailure(ctx context.Context)

	RecordConnectDuration(ctx context.Context, d time.Duration)
	IncConnectFailure(ctx context.Context)
	RecordObserveDuration(ctx context.Context, d time.Duration)
	IncObserveFailure(ctx context.Context)
	RecordCreateDuration(ctx context.Context, d time.Duration)
	IncCreateFailure(ctx context.Context)
	RecordUpdateDuration(ctx context.Context, d time.Duration)
	IncUpdateFailure(ctx context.Context)
	RecordDeleteDuration(ctx context.Context, d time.Duration)
	IncDeleteFailure(ctx context.Context)
	RecordFinalizerAddDuration(ctx context.Context, d time.Duration)
	IncFinalizerAddFailure(ctx context.Context)
	RecordFinalizerRemoveDuration(ctx context.Context, d time.Duration)
	IncFinalizerRemoveFailure(ctx context.Context)
	RecordStatusUpdateDuration(ctx context.Context, d time.Duration)
	IncStatusUpdateFailure(ctx context.Context)

	RecordReconcileDuration(ctx context.Context, d time.Duration)
	IncReconcileSuccess(ctx context.Context)
	IncReconcileFailure(ctx context.Context)
	IncReconcileRequeueAfter(ctx context.Context)
	IncReconcileRequeueImmediate(ctx context.Context)
	IncReconcileErrorRequeue(ctx context.Context)
	AddReconcileInFlight(delta int64)
}

MetricsRecorder records high-level reconcile metrics.

type NopClient

type NopClient struct{}

A NopClient does nothing.

func (*NopClient) Create

func (c *NopClient) Create(ctx context.Context, mg resource.Managed) error

Create does nothing. It returns an empty ExternalCreation and no error.

func (*NopClient) Delete

func (c *NopClient) Delete(ctx context.Context, mg resource.Managed) error

Delete does nothing. It never returns an error.

func (*NopClient) Observe

Observe does nothing. It returns an empty ExternalObservation and no error.

func (*NopClient) Update

func (c *NopClient) Update(ctx context.Context, mg resource.Managed) error

Update does nothing. It returns an empty ExternalUpdate and no error.

type NopConnecter

type NopConnecter struct{}

A NopConnecter does nothing.

func (*NopConnecter) Connect

Connect returns a NopClient. It never returns an error.

type NopDisconnecter

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

A NopDisconnecter converts an ExternalConnecter into an ExternalConnectDisconnecter with a no-op Disconnect method.

func (*NopDisconnecter) Connect

Connect calls the underlying ExternalConnecter's Connect method.

func (*NopDisconnecter) Disconnect

func (c *NopDisconnecter) Disconnect(_ context.Context) error

Disconnect does nothing. It never returns an error.

type PollIntervalHook

type PollIntervalHook func(managed resource.Managed, pollInterval time.Duration) time.Duration

PollIntervalHook represents the function type passed to the WithPollIntervalHook option to support dynamic computation of the poll interval.

type RateLimitKeyer added in v1.9.0

type RateLimitKeyer interface {
	RateLimitKey(mg resource.Managed) (string, error)
}

RateLimitKeyer names the rate-limited scope a managed resource's external calls belong to, typically the endpoint host, or host|credential when the quota is per identity. It must not do I/O: it is called before every gated call, including when the endpoint is throttled.

It is needed only for per-endpoint API rate limits. Implement it on the ExternalConnecter, the ExternalClient, or both. With a Governor configured (WithRateLimitGovernor):

  • Connect is gated on the connecter's key, when the connecter implements it.
  • Observe, Create, Update and Delete are gated on the client's key, or on the connecter's when only the connecter implements it.
  • A connecter and client that implement neither are not gated per endpoint. With saturation enabled, their calls still need a slot in the process-wide local capacity: saturation bounds every gated call.

Key on the credential's reference (for example the Secret's namespace and name), never its value: credentials rotate, and a key that changes on rotation splits one quota into several, each believing it has all of it. Return the same string the provider reports in ratelimit.Signal.Key (for an HTTP API, httpsignal.HostKey of its base URL), or signals throttle a key no call is gated on.

An empty key means the object's calls are not gated per endpoint. An error is a provider defect: the call proceeds without per-endpoint gating (still bounded by saturation when that is on), and the runtime logs it once per object.

type RateLimitKeysProvider added in v1.10.0

type RateLimitKeysProvider interface {
	RateLimitKeys(mg resource.Managed) ([]string, error)
}

RateLimitKeysProvider is RateLimitKeyer for an object whose calls reach several rate-limited scopes, such as a sync from one endpoint to another. One key can't describe that honestly: a throttled scope the call isn't gated on keeps being called, and a single shared key slows the healthy scope too.

A gated call then needs a slot in every key plus the local one, all or nothing, and is deferred when any of them is held or full. Its deferral names the key that stopped it. Return only the scopes the object's calls really reach, so return one key for an object whose endpoints are the same.

Everything RateLimitKeyer says about keys holds for each one: it must not do I/O, key on the credential's reference, and return the strings the provider reports in ratelimit.Signal.Key. Implement it on the ExternalConnecter, the ExternalClient, or both; it follows the same rules as RateLimitKeyer, and wins on a type that implements both. Empty keys are ignored. A nil or empty result means the object's calls are not gated per endpoint, and an error is treated as for RateLimitKeyer.

type Reconciler

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

A Reconciler reconciles managed resources by creating and managing the lifecycle of an external resource, i.e. a resource in an external system such as a cloud provider API. Each controller must watch the managed resource kind for which it is responsible.

func NewReconciler

func NewReconciler(m manager.Manager, of resource.ManagedKind, o ...ReconcilerOption) *Reconciler

NewReconciler returns a Reconciler that reconciles managed resources of the supplied ManagedKind with resources in an external system such as a cloud provider API. It panics if asked to reconcile a managed resource kind that is not registered with the supplied manager's runtime.Scheme. The returned Reconciler reconciles with a dummy, no-op 'external system' by default; callers should supply an ExternalConnector that returns an ExternalClient capable of managing resources in a real system.

func (*Reconciler) Reconcile

func (r *Reconciler) Reconcile(ctx context.Context, req reconcile.Request) (result reconcile.Result, err error)

Reconcile a managed resource with an external resource.

It reads the object, then opens the reconcile root span, start-stamped at the top of Reconcile so it covers the read, as the parent-or-link decision says (docs/design-tracing.md §4.1, §6.2). It binds the per-reconcile Logger to the span's context, and runs the pass with the span in every context it hands on. With tracing off no span starts.

type ReconcilerOption

type ReconcilerOption func(*Reconciler)

A ReconcilerOption configures a Reconciler.

func WithAPIReader added in v1.16.0

func WithAPIReader(rd client.Reader) ReconcilerOption

WithAPIReader gives the Reconciler a reader that reads the API server live, such as mgr.GetAPIReader(). It's used for one thing: when a status write conflicts, the Reconciler reads the object once through it and adds to the error the live resourceVersion and generation, the top-level status keys that differ from the pass's read, and the newest managedFields entry, as a hint. Nothing is decided from that read. A failed read gives the plain message.

Setting it costs one in-memory deep copy of the managed object per pass (the pass's read, kept for the comparison), and one uncached Get, only when a status write conflicts. With a rate-limit governor too, the governor reuses that copy, so a pass takes one copy, or two on a pass where the trace marker write moved the version, which happens at most once per trace window.

Without it, or with a nil reader, a status conflict's error is the plain message. NewReconciler can't take the reader from its manager itself: a test manager such as fake.Manager embeds a nil manager.Manager, whose GetAPIReader would panic.

func WithCreateRecoveryGracePeriod added in v1.4.0

func WithCreateRecoveryGracePeriod(d time.Duration) ReconcilerOption

WithCreateRecoveryGracePeriod specifies how long an UNRESOLVED create handshake keeps refusing before the reconciler concludes the create never reached the external system and retries it.

This is the confirm-the-negative window. Inside it nothing is recreated, so a create that DID land but is not yet visible in an eventually-consistent API is adopted rather than duplicated. Once it elapses with the resource still absent, refusing further would strand the resource forever — see the recovery branch in Reconcile. Defaults to 2 minutes.

Providers whose external API is slower to converge should raise this. Setting it to zero makes recovery retry immediately, which is only safe when the external API is strongly consistent.

func WithCreateRecoveryReobserveInterval added in v1.4.0

func WithCreateRecoveryReobserveInterval(d time.Duration) ReconcilerOption

WithCreateRecoveryReobserveInterval specifies how soon to re-observe an unresolved create while still inside the recovery grace period. Defaults to 15 seconds.

func WithCreationGracePeriod

func WithCreationGracePeriod(d time.Duration) ReconcilerOption

WithCreationGracePeriod configures an optional period during which we will wait for the external API to report that a newly created external resource exists. This allows us to tolerate eventually consistent APIs that do not immediately report that newly created resources exist when queried. All resources have a 30 second grace period by default.

func WithCriticalAnnotationUpdater

func WithCriticalAnnotationUpdater(u CriticalAnnotationUpdater) ReconcilerOption

WithCriticalAnnotationUpdater specifies how the Reconciler should update a managed resource's critical annotations. Implementations typically contain some kind of retry logic to increase the likelihood that critical annotations (like non-deterministic external names) will be persisted.

func WithExternalConnectDisconnecter

func WithExternalConnectDisconnecter(c ExternalConnectDisconnecter) ReconcilerOption

WithExternalConnectDisconnecter specifies how the Reconciler should connect and disconnect to the API used to sync and delete external resources.

func WithExternalConnecter

func WithExternalConnecter(c ExternalConnecter) ReconcilerOption

WithExternalConnecter specifies how the Reconciler should connect to the API used to sync and delete external resources.

func WithFinalizer

func WithFinalizer(f resource.Finalizer) ReconcilerOption

WithFinalizer specifies how the Reconciler should add and remove finalizers to and from the managed resource.

func WithLogger

func WithLogger(l logging.Logger) ReconcilerOption

WithLogger specifies how the Reconciler should log messages.

func WithMetrics

func WithMetrics(m MetricsRecorder) ReconcilerOption

WithMetrics specifies how the Reconciler should record telemetry.

func WithPollInterval

func WithPollInterval(after time.Duration) ReconcilerOption

WithPollInterval specifies how long the Reconciler should wait before queueing a new reconciliation after a successful reconcile. The Reconciler requeues after a specified duration when it is not actively waiting for an external operation, but wishes to check whether an existing external resource needs to be synced to its Managed resource.

func WithPollIntervalHook

func WithPollIntervalHook(hook PollIntervalHook) ReconcilerOption

WithPollIntervalHook adds a hook that can be used to configure the delay before an up-to-date resource is reconciled again after a successful reconcile. If this option is passed multiple times, only the latest hook will be used.

func WithPollJitterHook

func WithPollJitterHook(jitter time.Duration) ReconcilerOption

WithPollJitterHook adds a simple PollIntervalHook to add jitter to the poll interval used when queuing a new reconciliation after a successful reconcile. The added jitter will be a random duration between -jitter and +jitter. This option wraps WithPollIntervalHook, and is subject to the same constraint that only the latest hook will be used.

func WithRateLimitGovernor added in v1.9.0

func WithRateLimitGovernor(g *ratelimit.Governor) ReconcilerOption

WithRateLimitGovernor gates Connect and every ExternalClient call through g, for connecters and clients that implement RateLimitKeyer, and installs g as the ratelimit sink of the context those calls receive, so ratelimit.Report reaches it. A deferred call is not made: the pass writes Synced=False/ReconcileDeferred, leaves Ready unchanged, and requeues after the deferral's delay with a nil error, so no failure backoff is consumed.

The controller's own saturation is not gated here. With saturation on, build the controller with controller.Options.ForControllerRuntime: its queue takes a local slot before each reconcile and gives it back after, so the slot covers the whole reconcile and nothing is written on the object for it.

Share one Governor across the process's reconcilers; each one registers with it, which raises its ceiling by MaxConcurrentReconciles. Build it with controller.Options.SetupRateLimitGovernor, which also adds it to the manager so its saturation sampler runs. A nil g, the default, gates nothing and leaves Report a no-op, so

reconciler.WithRateLimitGovernor(o.RateLimitGovernor)

is safe whether or not the provider's chart enabled the governor.

func WithRecorder

func WithRecorder(er event.Recorder) ReconcilerOption

WithRecorder specifies how the Reconciler should record events.

func WithThrottledRecorder

func WithThrottledRecorder(er event.Recorder) ReconcilerOption

WithThrottledRecorder specifies a separate event recorder for events that are emitted when an error is encountered during reconciliation. This allows users of the Reconciler to choose to emit these events at a different level (e.g. Warning instead of Normal) without having to use the same level for all events. Defaults to the same recorder as the one set by WithRecorder if not specified.

func WithTimeout

func WithTimeout(duration time.Duration) ReconcilerOption

WithTimeout specifies the timeout duration cumulatively for all the calls happen in the reconciliation function. In case the deadline exceeds, reconciler will still have some time to make the necessary calls to report the error such as status update.

func WithTraceContinueWindow added in v1.14.0

func WithTraceContinueWindow(d time.Duration) ReconcilerOption

WithTraceContinueWindow sets how long a new krateo.io/traceparent value keeps making Parent passes that don't act, before the marker is written without an action and later passes link (docs/design-tracing.md §6.2). The default is 10 minutes. A provider polling much more slowly than that needs a window longer than its poll. 0 means: continue on the first pass, the first-sight rule.

func WithTracerProvider added in v1.14.0

func WithTracerProvider(tp trace.TracerProvider) ReconcilerOption

WithTracerProvider sets the TracerProvider the Reconciler's spans go to, instead of the one tracing.SetTracerProvider set (which telemetry.Setup sets with tracing on). It exists for tests, and for a reconciler that should use a different provider. nil means: use tracing.TracerProvider().

type RetryingCriticalAnnotationUpdater

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

A RetryingCriticalAnnotationUpdater is a CriticalAnnotationUpdater that retries annotation updates in the face of API server errors.

func NewRetryingCriticalAnnotationUpdater

func NewRetryingCriticalAnnotationUpdater(c client.Client) *RetryingCriticalAnnotationUpdater

NewRetryingCriticalAnnotationUpdater returns a CriticalAnnotationUpdater that retries annotation updates in the face of API server errors.

func (*RetryingCriticalAnnotationUpdater) UpdateCriticalAnnotations

func (u *RetryingCriticalAnnotationUpdater) UpdateCriticalAnnotations(ctx context.Context, o client.Object) error

UpdateCriticalAnnotations persists the runtime's own annotations of the supplied Object: krateo.io/external-name, krateo.io/external-create-pending, krateo.io/external-create-succeeded, krateo.io/external-create-failed and krateo.io/traceparent-continued, those of them it carries. It re-reads the object and writes those keys back onto what it read, retrying in the face of any API server error several times, in order to ensure annotations that contain critical state are persisted.

Every other annotation is left as the API server has it, so a value another writer set after the object was read is never reverted. An annotation a provider set on the object in memory, other than the keys above, is not persisted here. Any pending changes to the supplied Object's spec, status, or other metadata are reset to their current state according to the API server.

Directories

Path Synopsis
Package reconcilertest helps providers test their ExternalClient against the contracts pkg/reconciler relies on.
Package reconcilertest helps providers test their ExternalClient against the contracts pkg/reconciler relies on.

Jump to

Keyboard shortcuts

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