remotecluster

package
v1.19.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: Apache-2.0 Imports: 14 Imported by: 4

README

pkg/provisioners/remotecluster

Intention

pkg/provisioners/remotecluster is the provisioner adapter for switching execution into a remote cluster scope. It is not just a convenience wrapper for "run this on another cluster." It coordinates remote-cluster lifecycle, remote client construction, and child provisioner execution inside that remote scope.

This package is one of the concrete places where the context-scoping model described in pkg/client becomes operational. Context here is not incidental metadata. It carries the active provisioning scope, and this package rewrites that scope so descendant provisioners operate against a remote cluster instead of the local control-plane view.

In practice the package does three things:

  • ensures the remote cluster itself is created or registered when this wrapper owns that responsibility
  • builds a Kubernetes client for the remote kubeconfig and installs a new cluster scope into context
  • runs a child provisioner inside that remote scope, and later coordinates its teardown before the remote itself is removed

Invariants And Guard Rails

  • ProvisionOn(child, ...) returns a provisioner that executes the child inside a remote cluster scope, not in the caller's current cluster scope.
  • The remote scope is installed by creating a new client.ClusterContext and attaching it to context. Descendant provisioners are expected to treat that as the active provisioning target, consistent with the pkg/client context model.
  • When the RemoteCluster wrapper is marked as the controller, it owns remote cluster registration/lifecycle and ensures the remote exists before child provisioning proceeds.
  • Multiple child provisioners can share one RemoteCluster wrapper. The internal reference counting exists so that shared remote lifecycle is created once and torn down only after all registered children have completed.
  • backgroundDeletion is propagated through context to descendants. It is a policy signal that the remote is being discarded and some child cleanup may be safely skipped when the remote itself will be destroyed anyway.
  • The package is intended for reconciler-driven use. Child provisioners are expected to be idempotent and to yield quickly when they cannot make progress.

Caveats

  • This package mixes several concerns in one place: remote lifecycle ownership, remote client construction, provisioning-scope context switching, descendant policy propagation, and shared reference counting.
  • Correctness depends on usage discipline. Callers must consistently reuse the same RemoteCluster wrapper when multiple child provisioners are meant to share one remote lifecycle; otherwise the internal reference counting model does not describe reality.
  • The package is tightly coupled to the context-scoping model from pkg/client. If that model is retired along with older CD/Argo-style provisioning flows, this package would likely need to shrink or be redesigned as well.
  • backgroundDeletion is a hidden context contract rather than an explicit method parameter on descendants, which makes behavior convenient but also less obvious at call sites.
  • During deprovision, failure to build the remote client due to provisioners.ErrYield is treated as a signal that child deprovisioning can be skipped because the remote is already effectively gone. That is a pragmatic lifecycle shortcut, not a universally safe remote-cleanup rule.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BackgroundDeletion

func BackgroundDeletion(p *remoteClusterProvisioner)

func BackgroundDeletionFromContext added in v0.1.64

func BackgroundDeletionFromContext(ctx context.Context) bool

func NewContextWithBackgroundDeletion added in v0.1.64

func NewContextWithBackgroundDeletion(ctx context.Context, backgroundDeletion bool) context.Context

func WithPrefix added in v0.1.94

func WithPrefix(prefix string) func(*remoteClusterProvisioner)

Types

type ProvisionerOption

type ProvisionerOption func(p *remoteClusterProvisioner)

Allows us to specify options for the provided provisioner.

type RemoteCluster

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

RemoteCluster provides generic handling of remote cluster instances. Specialization is delegated to a provider specific interface.

func New

func New(generator provisioners.RemoteCluster, controller bool) *RemoteCluster

New returns a new initialized provisioner object.

func (*RemoteCluster) ProvisionOn

ProvisionOn returns a provisioner that will provision the remote, and provision the child provisioner on that remote.

Jump to

Keyboard shortcuts

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