Documentation
¶
Index ¶
- Constants
- func GetShortId(id string) string
- func MakeUniqueName(prefix string) (string, string, error)
- func MakeValidLabelValue(s string) string
- func NewControllerManagerOptions(lifetimeCtx context.Context, scheme *apiruntime.Scheme, log logr.Logger) ctrl.Options
- func NewResourceHarvester() *resourceHarvester
- func SetupEndpointIndexWithManager(mgr ctrl.Manager) error
- type AdditionalReconciliationDelay
- type Cloner
- type ContainerExecReconciler
- type ContainerNetworkTunnelProxyReconciler
- type ContainerNetworkTunnelProxyReconcilerConfig
- type ContainerReconciler
- type ContainerReconcilerConfig
- type ContainerWatcher
- type ControllerContextOption
- type DeferredMapOperation
- type EndpointOwner
- type ExecutableReconciler
- func (r *ExecutableReconciler) OnMainProcessChanged(runID RunID, pid process.Pid_t)
- func (r *ExecutableReconciler) OnRunCompleted(runID RunID, exitCode *int32, err error)
- func (r *ExecutableReconciler) OnRunMessage(runID RunID, level RunMessageLevel, message string)
- func (r *ExecutableReconciler) OnStartupCompleted(exeName types.NamespacedName, startResult *ExecutableStartResult)
- func (r *ExecutableReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)
- func (r *ExecutableReconciler) SetupWithManager(mgr ctrl.Manager, name string) error
- type ExecutableReplicaSetReconciler
- type ExecutableReplicaSetState
- type ExecutableRunInfo
- func (ri *ExecutableRunInfo) ApplyTo(exe *apiv1.Executable, log logr.Logger) objectChange
- func (ri *ExecutableRunInfo) Clone() *ExecutableRunInfo
- func (ri *ExecutableRunInfo) GetResourceId() string
- func (ri *ExecutableRunInfo) String() string
- func (ri *ExecutableRunInfo) UpdateFrom(other *ExecutableRunInfo) bool
- type ExecutableRunner
- type ExecutableStartResult
- func (res *ExecutableStartResult) Clone() *ExecutableStartResult
- func (res *ExecutableStartResult) Equal(other *ExecutableStartResult) bool
- func (res *ExecutableStartResult) IsSuccessfullyCompleted() bool
- func (res *ExecutableStartResult) String() string
- func (res *ExecutableStartResult) UpdateFrom(other *ExecutableStartResult) bool
- type ExecutableStartuptStage
- type KubernetesObjectStateType
- type NetworkReconciler
- type ObjectStateMap
- func (m *ObjectStateMap[StateKeyT, OS, POS, PObj]) BorrowByNamespacedName(namespaceName types.NamespacedName) (StateKeyT, POS)
- func (m *ObjectStateMap[StateKeyT, OS, POS, PObj]) BorrowByStateKey(stateKey StateKeyT) (types.NamespacedName, POS)
- func (m *ObjectStateMap[StateKeyT, OS, POS, PObj]) Clear()
- func (m *ObjectStateMap[StateKeyT, OS, POS, PObj]) DeleteByNamespacedName(namespaceName types.NamespacedName)
- func (m *ObjectStateMap[StateKeyT, OS, POS, PObj]) DeleteByStateKey(stateKey StateKeyT)
- func (m *ObjectStateMap[StateKeyT, OS, POS, PObj]) QueueDeferredOp(namespaceName types.NamespacedName, op DeferredMapOperation[StateKeyT, PObj]) bool
- func (m *ObjectStateMap[StateKeyT, OS, POS, PObj]) Range(f func(types.NamespacedName, StateKeyT, POS) bool)
- func (m *ObjectStateMap[StateKeyT, OS, POS, PObj]) RunDeferredOps(namespaceName types.NamespacedName, obj PObj)
- func (m *ObjectStateMap[StateKeyT, OS, POS, PObj]) Store(namespaceName types.NamespacedName, k2 StateKeyT, pos POS)
- func (m *ObjectStateMap[StateKeyT, OS, POS, PObj]) Update(namespaceName types.NamespacedName, stateKey StateKeyT, pos POS) bool
- func (m *ObjectStateMap[StateKeyT, OS, POS, PObj]) UpdateChangingStateKey(namespaceName types.NamespacedName, oldStateKey StateKeyT, ...) bool
- type PInMemoryObjectState
- type PReconcilerType
- type Patcher
- type ReconcilerBase
- func (rb *ReconcilerBase[T, PT]) GetReconciliationEventSource() ctrl_source.Source
- func (rb *ReconcilerBase[T, PT]) SaveChanges(ctx context.Context, obj PT, patch ctrl_client.Patch, change objectChange, ...) (ctrl.Result, error)
- func (rb *ReconcilerBase[T, PT]) SaveChangesWithDelay(ctx context.Context, obj PT, patch ctrl_client.Patch, change objectChange, ...) (ctrl.Result, error)
- func (rb *ReconcilerBase[T, PT]) ScheduleReconciliation(nn types.NamespacedName)
- func (rb *ReconcilerBase[T, PT]) ScheduleReconciliationWithDelay(nn types.NamespacedName, delay AdditionalReconciliationDelay)
- func (rb *ReconcilerBase[T, PT]) StartReconciliation(req ctrl.Request) (ctrl_client.Reader, logr.Logger)
- type ReconcilerType
- type RunChangeHandler
- type RunID
- type RunMessageLevel
- type ServiceReconciler
- type ServiceReconcilerConfig
- type ServiceWorkloadEndpointKey
- type UpdateableFrom
- type VolumeReconciler
Constants ¶
const ( PersistentLabel = "com.microsoft.developer.usvc-dev.persistent" CreatorProcessIdLabel = "com.microsoft.developer.usvc-dev.creatorProcessId" CreatorProcessStartTimeLabel = "com.microsoft.developer.usvc-dev.creatorProcessStartTime" ContainerIdLabel = "com.microsoft.developer.usvc-dev.containerId" MaxConcurrentReconciles = 6 )
const ( ExecutableReplicaStateAnnotation = "executable-replica-set.usvc-dev.developer.microsoft.com/replica-state" ExecutableDisplayNameAnnotation = "executable-replica-set.usvc-dev.developer.microsoft.com/display-name" ExecutableReplicaIdAnnotation = "executable-replica-set.usvc-dev.developer.microsoft.com/replica-id" ExecutableReplicaSetNameAnnotation = "executable-replica-set.usvc-dev.developer.microsoft.com/replica-set-name" // Used by .NET Aspire. // CONSIDER having means to create this annotation based on information in Executable spec template. OtelServiceinstaneIdAnnotation = "otel-service-instance-id" )
const (
DefaultMaxParallelContainerStarts uint8 = 6
)
const ( // With the default additional reconciliation delay of 2 seconds, this results in approximately 60 seconds // of the ServiceReconciler attempting to start the service (proxies) before giving up. // A typical failure is associated with port conflict, which may be transient. MaxServiceStartAttempts = 30 )
const (
NetworkResourceNameField = ".metadata.networkResourceName"
)
const (
RuntimeContainerHealthProbeName = "__runtime"
)
const (
// Annotation for an Endpoint object that links it to a specific tunnel that serves it.
TunnelIdAnnotation = "container-network-tunnel-proxy.usvc-dev.developer.microsoft.com/tunnel-id"
)
Variables ¶
This section is empty.
Functions ¶
func GetShortId ¶
Returns a short version of the ID (the first 12 characters). Intended for use with container resource IDs, which are usually long and not very human-readable. The short ID is used in logs and other places where a shorter identifier is more convenient.
func MakeUniqueName ¶
Returns a name made probabilistically unique by appending a random postfix, together with the used random postfix and an error, if any.
func MakeValidLabelValue ¶
Computes a valid Kubernetes label value from an arbitrary string. If the passed string is a valid label value, it is returned unchanged. Otherwise, a hash of the string is computed and the returned value is the hash in hexadecimal form, prefixed with "x-".
func NewResourceHarvester ¶
func NewResourceHarvester() *resourceHarvester
Types ¶
type AdditionalReconciliationDelay ¶
type AdditionalReconciliationDelay int
const ( StandardDelay AdditionalReconciliationDelay = 0 // Zero value means standard delay NoDelay AdditionalReconciliationDelay = 1 LongDelay AdditionalReconciliationDelay = 2 TestDelay AdditionalReconciliationDelay = 3 )
type Cloner ¶
type Cloner[T any] interface { // Performs a deep copy of the object (to the extent necessary). Clone() T }
type ContainerExecReconciler ¶
type ContainerExecReconciler struct {
*ReconcilerBase[apiv1.ContainerExec, *apiv1.ContainerExec]
// contains filtered or unexported fields
}
func NewContainerExecReconciler ¶
func NewContainerExecReconciler( lifetimeCtx context.Context, client ctrl_client.Client, noCacheClient ctrl_client.Reader, log logr.Logger, orchestrator containers.ContainerOrchestrator, ) *ContainerExecReconciler
func (*ContainerExecReconciler) SetupWithManager ¶
func (r *ContainerExecReconciler) SetupWithManager(mgr ctrl.Manager, name string) error
type ContainerNetworkTunnelProxyReconciler ¶
type ContainerNetworkTunnelProxyReconciler struct {
*ReconcilerBase[apiv1.ContainerNetworkTunnelProxy, *apiv1.ContainerNetworkTunnelProxy]
*ContainerWatcher[apiv1.ContainerNetworkTunnelProxy]
// contains filtered or unexported fields
}
func NewContainerNetworkTunnelProxyReconciler ¶
func NewContainerNetworkTunnelProxyReconciler( lifetimeCtx context.Context, client ctrl_client.Client, noCacheClient ctrl_client.Reader, config ContainerNetworkTunnelProxyReconcilerConfig, log logr.Logger, ) *ContainerNetworkTunnelProxyReconciler
func (*ContainerNetworkTunnelProxyReconciler) SetupWithManager ¶
func (r *ContainerNetworkTunnelProxyReconciler) SetupWithManager(mgr ctrl.Manager, name string) error
type ContainerNetworkTunnelProxyReconcilerConfig ¶
type ContainerNetworkTunnelProxyReconcilerConfig struct {
Orchestrator containers.ContainerOrchestrator // Mandatory
ProcessExecutor process.Executor // Mandatory
// The factory function to create a TunnelControlClient used to control the proxy pair.
// Normal execution uses "real" gRPC client, tests use a stub since most tests do not run real tunnels.
// Mandatory.
MakeTunnelControlClient func(grpc.ClientConnInterface) dcptunproto.TunnelControlClient
// Overrides the most recent image builds file path.
// Used primarily for testing purposes.
MostRecentImageBuildsFilePath string
// Specifies how many attempts to prepare a tunnel will be made before giving up and marking the tunnel as failed.
// Defaults to defaultMaxTunnelPreparationAttempts, but much lower value is used for tests to simulate failures quickly.
MaxTunnelPreparationAttempts uint32
// If not zero, specifies how long the controller will wait for an attempt to start the client proxy container to succeed.
// Used primarily for testing purposes.
ContainerStartupTimeoutOverride time.Duration
}
type ContainerReconciler ¶
type ContainerReconciler struct {
*ReconcilerBase[apiv1.Container, *apiv1.Container]
*ContainerWatcher[apiv1.Container]
// contains filtered or unexported fields
}
func NewContainerReconciler ¶
func NewContainerReconciler( lifetimeCtx context.Context, client ctrl_client.Client, noCacheClient ctrl_client.Reader, log logr.Logger, orchestrator containers.ContainerOrchestrator, healthProbeSet *health.HealthProbeSet, config ContainerReconcilerConfig, ) *ContainerReconciler
func (*ContainerReconciler) SetupWithManager ¶
func (r *ContainerReconciler) SetupWithManager(mgr ctrl.Manager, name string) error
type ContainerWatcher ¶
type ContainerWatcher[T commonapi.ObjectStruct] struct { // Callbacks to execute when a container or network event is received ProcessContainerEvent func(em containers.EventMessage) ProcessNetworkEvent func(em containers.EventMessage) // contains filtered or unexported fields }
Provides data and common functionality for reconcilers that need to watch (Docker/Podman) containers
func NewContainerWatcher ¶
func NewContainerWatcher[T commonapi.ObjectStruct]( orchestrator containers.ContainerOrchestrator, lock sync.Locker, lifetimeCtx context.Context, ) *ContainerWatcher[T]
func (*ContainerWatcher[T]) EnsureContainerWatchForResource ¶
func (r *ContainerWatcher[T]) EnsureContainerWatchForResource(resourceID types.UID, log logr.Logger)
func (*ContainerWatcher[T]) ReleaseContainerWatchForResource ¶
func (r *ContainerWatcher[T]) ReleaseContainerWatchForResource(resourceID types.UID, log logr.Logger)
type ControllerContextOption ¶
type ControllerContextOption string
type DeferredMapOperation ¶
type DeferredMapOperation[StateKeyT comparable, PObj commonapi.DcpModelObject] func(types.NamespacedName, StateKeyT, PObj)
type EndpointOwner ¶
type EndpointOwner[EndpointCreationContext any] interface { ctrl_client.Client // contains filtered or unexported methods }
type ExecutableReconciler ¶
type ExecutableReconciler struct {
*ReconcilerBase[apiv1.Executable, *apiv1.Executable]
ExecutableRunners map[apiv1.ExecutionType]ExecutableRunner
// contains filtered or unexported fields
}
ExecutableReconciler reconciles a Executable object
func NewExecutableReconciler ¶
func NewExecutableReconciler( lifetimeCtx context.Context, client ctrl_client.Client, noCacheClient ctrl_client.Reader, log logr.Logger, executableRunners map[apiv1.ExecutionType]ExecutableRunner, healthProbeSet *health.HealthProbeSet, ) *ExecutableReconciler
func (*ExecutableReconciler) OnMainProcessChanged ¶
func (r *ExecutableReconciler) OnMainProcessChanged(runID RunID, pid process.Pid_t)
func (*ExecutableReconciler) OnRunCompleted ¶
func (r *ExecutableReconciler) OnRunCompleted(runID RunID, exitCode *int32, err error)
func (*ExecutableReconciler) OnRunMessage ¶
func (r *ExecutableReconciler) OnRunMessage(runID RunID, level RunMessageLevel, message string)
Handles run message notifications from the Executable runner.
func (*ExecutableReconciler) OnStartupCompleted ¶
func (r *ExecutableReconciler) OnStartupCompleted( exeName types.NamespacedName, startResult *ExecutableStartResult, )
Handle setting up process tracking once an Executable has transitioned from newly created or starting to a stable state such as running or finished.
func (*ExecutableReconciler) Reconcile ¶
func (r *ExecutableReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)
The main reconciler function of the Executable controller.
Notes: Updating the Executable path/working directory/arguments/environment will not effect an Executable run once it started. Status will be updated based on the status of the corresponding run and the run will be terminated if the Executable is deleted.
func (*ExecutableReconciler) SetupWithManager ¶
func (r *ExecutableReconciler) SetupWithManager(mgr ctrl.Manager, name string) error
type ExecutableReplicaSetReconciler ¶
type ExecutableReplicaSetReconciler struct {
*ReconcilerBase[apiv1.ExecutableReplicaSet, *apiv1.ExecutableReplicaSet]
// contains filtered or unexported fields
}
ExecutableReplicaSetReconciler reconciles an ExecutableReplicaSet object
func NewExecutableReplicaSetReconciler ¶
func NewExecutableReplicaSetReconciler( lifetimeCtx context.Context, client ctrl_client.Client, noCacheClient ctrl_client.Reader, log logr.Logger, ) *ExecutableReplicaSetReconciler
func (*ExecutableReplicaSetReconciler) Reconcile ¶
func (r *ExecutableReplicaSetReconciler) Reconcile(ctx context.Context, req reconcile.Request) (reconcile.Result, error)
Reconcile implements reconcile.Reconciler. The reconciler loop for ExecutableReplicaSet objects updates the status to reflect the current number of running replicas as well as attempting to ensure the replica count reaches the desired state. Changes to Executables "owned" by a given ExecutableReplicaSet will also trigger our reconciler loop, allowing us to respond to changes to both the ExecutableReplicaSet as well as its child Executables.
func (*ExecutableReplicaSetReconciler) SetupWithManager ¶
func (r *ExecutableReplicaSetReconciler) SetupWithManager(mgr ctrl.Manager, name string) error
type ExecutableReplicaSetState ¶
type ExecutableReplicaSetState string
const ( ExecutableReplicaSetStateActive ExecutableReplicaSetState = "active" ExecutableReplicaSetStateInactive ExecutableReplicaSetState = "inactive" )
type ExecutableRunInfo ¶
type ExecutableRunInfo struct {
// State of the run (starting, running, finished, etc.)
ExeState apiv1.ExecutableState
// Process ID of the process that runs the Executable
Pid *int64
// Run ID for the Executable
RunID RunID
// UID of the Executable
UID types.UID
// Exit code of the Executable process
ExitCode *int32
// Timestamp when the run was started
StartupTimestamp metav1.MicroTime
// Timestamp when the run was finished
FinishTimestamp metav1.MicroTime
// Paths to captured standard output and standard error files
StdOutFile string
StdErrFile string
// Paths to capture debug, info, and error logs
DebugLogFile string
InfoLogFile string
ErrorLogFile string
// The map of ports reserved for services that the Executable implements
ReservedPorts map[types.NamespacedName]int32
// contains filtered or unexported fields
}
Stores information about Executable run
func NewRunInfo ¶
func NewRunInfo(exe *apiv1.Executable) *ExecutableRunInfo
func (*ExecutableRunInfo) ApplyTo ¶
func (ri *ExecutableRunInfo) ApplyTo(exe *apiv1.Executable, log logr.Logger) objectChange
func (*ExecutableRunInfo) Clone ¶
func (ri *ExecutableRunInfo) Clone() *ExecutableRunInfo
func (*ExecutableRunInfo) GetResourceId ¶
func (ri *ExecutableRunInfo) GetResourceId() string
func (*ExecutableRunInfo) String ¶
func (ri *ExecutableRunInfo) String() string
func (*ExecutableRunInfo) UpdateFrom ¶
func (ri *ExecutableRunInfo) UpdateFrom(other *ExecutableRunInfo) bool
Updates the runInfo object from another instance that supplies new data about the run. Returns true if any changes were made, false otherwise.
The object that is updated may represent the "last known good" state of the run. Since change notifications about real-world counterparts of the Executable object come asynchronously and may come out of order, we do not take all updates blindly. For example, we restrict the state transitions to only the valid ones.
type ExecutableRunner ¶
type ExecutableRunner interface {
// Runs the Executable.
//
// The runChangeHandler is used to notify the caller about the run's progress and completion, see RunChangeHandler for more details.
//
// The following contract should be observed by the ExecutableRunner implementation:
// -- When the passed context is cancelled, the run should be automatically terminated.
// -- The runner should not try to change the passed Executable in any way.
// -- The method should always return a result (no nil return value).
StartRun(
ctx context.Context,
exe *apiv1.Executable,
runChangeHandler RunChangeHandler,
log logr.Logger,
) *ExecutableStartResult
// Stops the run with a given ID.
StopRun(ctx context.Context, runID RunID, log logr.Logger) error
}
ExecutableRunner is an entity that knows how to "run" an executable. Examples include ordinary (OS) process runner and IDE runner (which runs the executable inside IDE like VS or VS Code).
type ExecutableStartResult ¶
type ExecutableStartResult struct {
// State of the run after the start attempt.
// One of: Running, FailedToStart, or Finished
ExeState apiv1.ExecutableState
// Process ID of the process that runs the Executable
Pid *int64
// Run ID for the Executable
RunID RunID
// Paths to captured standard output and standard error files
StdOutFile string
StdErrFile string
// Timestamp for when the startup attempt was completed
CompletionTimestamp metav1.MicroTime
// The error that occurred during startup, if any.
// NOTE: if StartupError is nil, this does NOT necessarily mean that the startup was successful.
// The ExeState field must be checked to determine the actual outcome of the startup attempt.
// StartupError is an additional, explanatory error information.
StartupError error
// The function to call to indicate that the run change handler is ready
// to receive further updates about the run.
StartWaitForRunCompletion func()
}
func NewExecutableStartResult ¶
func NewExecutableStartResult() *ExecutableStartResult
func (*ExecutableStartResult) Clone ¶
func (res *ExecutableStartResult) Clone() *ExecutableStartResult
func (*ExecutableStartResult) Equal ¶
func (res *ExecutableStartResult) Equal(other *ExecutableStartResult) bool
func (*ExecutableStartResult) IsSuccessfullyCompleted ¶
func (res *ExecutableStartResult) IsSuccessfullyCompleted() bool
func (*ExecutableStartResult) String ¶
func (res *ExecutableStartResult) String() string
func (*ExecutableStartResult) UpdateFrom ¶
func (res *ExecutableStartResult) UpdateFrom(other *ExecutableStartResult) bool
type ExecutableStartuptStage ¶
type ExecutableStartuptStage int
The startup stage for an Executable run. Non-negative values indicate that the startup progressed beyond initialization stage and we are using the Executable runner with index equal to the stage value (0 for default runner, 1 for first fallback, etc.).
const ( StartupStageInitial ExecutableStartuptStage = -3 StartupStageCertificateDataReady ExecutableStartuptStage = -2 StartupStageDataInitialized ExecutableStartuptStage = -1 StartupStageDefaultRunner ExecutableStartuptStage = 0 )
func (ExecutableStartuptStage) String ¶
func (s ExecutableStartuptStage) String() string
type KubernetesObjectStateType ¶
type KubernetesObjectStateType interface {
~string
}
type NetworkReconciler ¶
type NetworkReconciler struct {
*ReconcilerBase[apiv1.ContainerNetwork, *apiv1.ContainerNetwork]
// contains filtered or unexported fields
}
func NewNetworkReconciler ¶
func NewNetworkReconciler( lifetimeCtx context.Context, client ctrl_client.Client, noCacheClient ctrl_client.Reader, log logr.Logger, orchestrator containers.ContainerOrchestrator, harvester *resourceHarvester, ) *NetworkReconciler
func (*NetworkReconciler) SetupWithManager ¶
func (r *NetworkReconciler) SetupWithManager(mgr ctrl.Manager, name string) error
type ObjectStateMap ¶
type ObjectStateMap[StateKeyT comparable, OS any, POS PInMemoryObjectState[OS], PObj commonapi.DcpModelObject] struct { // contains filtered or unexported fields }
func NewObjectStateMap ¶
func NewObjectStateMap[StateKeyT comparable, OS any, POS PInMemoryObjectState[OS], PObj commonapi.DcpModelObject]() *ObjectStateMap[StateKeyT, OS, POS, PObj]
func (*ObjectStateMap[StateKeyT, OS, POS, PObj]) BorrowByNamespacedName ¶
func (m *ObjectStateMap[StateKeyT, OS, POS, PObj]) BorrowByNamespacedName(namespaceName types.NamespacedName) (StateKeyT, POS)
Returns a clone of the object state for the given namespaced name. If the object state is not found, the second return value will be nil.
func (*ObjectStateMap[StateKeyT, OS, POS, PObj]) BorrowByStateKey ¶
func (m *ObjectStateMap[StateKeyT, OS, POS, PObj]) BorrowByStateKey(stateKey StateKeyT) (types.NamespacedName, POS)
Returns a clone of the object state for the given a state key. If the object state is not found, the second return value will be nil.
func (*ObjectStateMap[StateKeyT, OS, POS, PObj]) Clear ¶
func (m *ObjectStateMap[StateKeyT, OS, POS, PObj]) Clear()
Clear() removes all object states from the map.
func (*ObjectStateMap[StateKeyT, OS, POS, PObj]) DeleteByNamespacedName ¶
func (m *ObjectStateMap[StateKeyT, OS, POS, PObj]) DeleteByNamespacedName(namespaceName types.NamespacedName)
DeleteByNamespacedName() deletes the object state for the given namespaced name.
func (*ObjectStateMap[StateKeyT, OS, POS, PObj]) DeleteByStateKey ¶
func (m *ObjectStateMap[StateKeyT, OS, POS, PObj]) DeleteByStateKey(stateKey StateKeyT)
DeleteByStateKey() deletes the object state for the given state key.
func (*ObjectStateMap[StateKeyT, OS, POS, PObj]) QueueDeferredOp ¶
func (m *ObjectStateMap[StateKeyT, OS, POS, PObj]) QueueDeferredOp(namespaceName types.NamespacedName, op DeferredMapOperation[StateKeyT, PObj]) bool
QueueDeferredOp() queues a deferred operation to be run later (by calling RunDeferredOps()). The operation fails (returning false) if the object state is not found using the given key.
func (*ObjectStateMap[StateKeyT, OS, POS, PObj]) Range ¶
func (m *ObjectStateMap[StateKeyT, OS, POS, PObj]) Range(f func(types.NamespacedName, StateKeyT, POS) bool)
Range() iterates over all object states in the map and calls the given function for each one. Every instance presented to the function is a clone of the object state.
func (*ObjectStateMap[StateKeyT, OS, POS, PObj]) RunDeferredOps ¶
func (m *ObjectStateMap[StateKeyT, OS, POS, PObj]) RunDeferredOps(namespaceName types.NamespacedName, obj PObj)
RunDeferredOps() runs all deferred operations for the given namespaced name.
func (*ObjectStateMap[StateKeyT, OS, POS, PObj]) Store ¶
func (m *ObjectStateMap[StateKeyT, OS, POS, PObj]) Store(namespaceName types.NamespacedName, k2 StateKeyT, pos POS)
Stores the object state for the given namespaced name and state key, unconditionally overwriting any existing state.
func (*ObjectStateMap[StateKeyT, OS, POS, PObj]) Update ¶
func (m *ObjectStateMap[StateKeyT, OS, POS, PObj]) Update(namespaceName types.NamespacedName, stateKey StateKeyT, pos POS) bool
Updates the object state for the given namespaced name and state key. The operation fails (returning false) if the object state is not found using either key, or if no changes have been made to the object (UpdateFrom() returned false).
func (*ObjectStateMap[StateKeyT, OS, POS, PObj]) UpdateChangingStateKey ¶
func (m *ObjectStateMap[StateKeyT, OS, POS, PObj]) UpdateChangingStateKey(namespaceName types.NamespacedName, oldStateKey StateKeyT, newStateKey StateKeyT, pos POS) bool
UpdateChangingStateKey() is like Update(), with the additional effect of changing the state key the object state is stored under.
type PInMemoryObjectState ¶
type PInMemoryObjectState[IMOS any] interface { *IMOS Cloner[*IMOS] UpdateableFrom[*IMOS] }
type PReconcilerType ¶
type PReconcilerType[RT ReconcilerType] interface { *RT ctrl_client.Client }
type Patcher ¶
type Patcher func(ctx context.Context, obj ctrl_client.Object, patch ctrl_client.Patch) error
type ReconcilerBase ¶
type ReconcilerBase[T commonapi.ObjectStruct, PT commonapi.PCopyableObjectStruct[T]] struct { // The regular, cached client ctrl_client.Client // Non-cached client, to be used if a optimistic concurrency conflict occurs NoCacheClient ctrl_client.Reader // Base logger for the reconciler Log logr.Logger // Reconciler lifetime context, used to cancel operations during reconciler shutdown LifetimeCtx context.Context // contains filtered or unexported fields }
func NewReconcilerBase ¶
func NewReconcilerBase[T commonapi.ObjectStruct, PT commonapi.PCopyableObjectStruct[T]]( client ctrl_client.Client, noCacheClient ctrl_client.Reader, log logr.Logger, lifetimeCtx context.Context, ) *ReconcilerBase[T, PT]
func (*ReconcilerBase[T, PT]) GetReconciliationEventSource ¶
func (rb *ReconcilerBase[T, PT]) GetReconciliationEventSource() ctrl_source.Source
Gets a reconciliation event source for triggering reconciliations programmatically. The returned source should be passed to WatchesRawSource() controller builder method.
func (*ReconcilerBase[T, PT]) SaveChanges ¶
func (rb *ReconcilerBase[T, PT]) SaveChanges( ctx context.Context, obj PT, patch ctrl_client.Patch, change objectChange, onSuccessfulSave func(), log logr.Logger, ) (ctrl.Result, error)
Saves changes to the object and schedules additional reconciliation as appropriate. Standard delay is used for additional reconciliation. If conflicts occurred during previous save, additional delay will be exponentially increased up to maxConflictDelay.
func (*ReconcilerBase[T, PT]) SaveChangesWithDelay ¶
func (rb *ReconcilerBase[T, PT]) SaveChangesWithDelay( ctx context.Context, obj PT, patch ctrl_client.Patch, change objectChange, delay AdditionalReconciliationDelay, onSuccessfulSave func(), log logr.Logger, ) (ctrl.Result, error)
Saves changes to the object and schedules additional reconciliation as appropriate. Standard or long delay will be used for additional reconciliation, depending on the flag passed. If long delay is requested, it implies that additional reconciliation is needed. If conflicts occurred during previous save, reconciliation delay will be exponentially increased up to maxConflictDelay.
func (*ReconcilerBase[T, PT]) ScheduleReconciliation ¶
func (rb *ReconcilerBase[T, PT]) ScheduleReconciliation(nn types.NamespacedName)
Schedules reconciliation for specific object identified by namespaced name.
func (*ReconcilerBase[T, PT]) ScheduleReconciliationWithDelay ¶
func (rb *ReconcilerBase[T, PT]) ScheduleReconciliationWithDelay(nn types.NamespacedName, delay AdditionalReconciliationDelay)
Schedules reconciliation for specific object identified by namespaced name, delaying it by specified duration.
func (*ReconcilerBase[T, PT]) StartReconciliation ¶
func (rb *ReconcilerBase[T, PT]) StartReconciliation(req ctrl.Request) (ctrl_client.Reader, logr.Logger)
Marks the startup of another reconciliation. Returns object reader and a derived log to be used for the current reconciliation. The log has unique reconciliation sequence number and the namespaced name of the object being reconciled.
type ReconcilerType ¶
type ReconcilerType interface {
}
type RunChangeHandler ¶
type RunChangeHandler interface {
// Called when the main process of the run changes (is started or re-started).
//
// Note: if the startup is synchronous, this method may never be called. Instead, the process ID
// for the main process of the run will be reported via the runInfo parameter of the OnStartupCompleted() notification.
OnMainProcessChanged(runID RunID, pid process.Pid_t)
// Called when the run has completed.
// If err is nil, the run completed successfully and the exitCode value (if supplied) is valid.
// If err is not nil, the run did not complete successfully and the exitCode value is not valid.
// (and should be UnknownExitCode).
OnRunCompleted(runID RunID, exitCode *int32, err error)
// Called when startup has been completed for a run.
// The name parameter contains the name of the Executable that was started (or attempted to start).
// The result parameter contains the outcome of the startup attempt.
//
// The caller must call the result.StartWaitForRunCompletion function to receive further notifications about the run.
// For example, OnRunCompleted method call will be delayed till StartWaitForRunCompletion is called.
//
// In case of synchronous startup, this method will be called before ExecutableRunner.StartRun() returns.
OnStartupCompleted(name types.NamespacedName, result *ExecutableStartResult)
// Called when the runner needs to emit a user-targeted diagnostic message about a run.
OnRunMessage(runID RunID, level RunMessageLevel, message string)
}
type RunMessageLevel ¶
type RunMessageLevel string
const ( RunMessageLevelInfo RunMessageLevel = "info" RunMessageLevelDebug RunMessageLevel = "debug" RunMessageLevelError RunMessageLevel = "error" )
type ServiceReconciler ¶
type ServiceReconciler struct {
*ReconcilerBase[apiv1.Service, *apiv1.Service]
ProxyConfigDir string
// contains filtered or unexported fields
}
func NewServiceReconciler ¶
func NewServiceReconciler( lifetimeCtx context.Context, client ctrl_client.Client, noCacheClient ctrl_client.Reader, log logr.Logger, config ServiceReconcilerConfig, ) *ServiceReconciler
func (*ServiceReconciler) SetupWithManager ¶
func (r *ServiceReconciler) SetupWithManager(mgr ctrl.Manager, name string) error
type ServiceReconcilerConfig ¶
type ServiceReconcilerConfig struct {
ProcessExecutor process.Executor
CreateProxy proxy.ProxyFactory
AdditionalReconciliationDelay AdditionalReconciliationDelay
}
Stores ServiceReconciler dependencies and configuration that often varies between normal execution and testing.
type ServiceWorkloadEndpointKey ¶
type ServiceWorkloadEndpointKey struct {
commonapi.NamespacedNameWithKind
ServiceName string
}
type UpdateableFrom ¶
type VolumeReconciler ¶
type VolumeReconciler struct {
*ReconcilerBase[apiv1.ContainerVolume, *apiv1.ContainerVolume]
// contains filtered or unexported fields
}
func NewVolumeReconciler ¶
func NewVolumeReconciler( lifetimeCtx context.Context, client ctrl_client.Client, noCacheClient ctrl_client.Reader, log logr.Logger, orchestrator containers.VolumeOrchestrator, ) *VolumeReconciler
func (*VolumeReconciler) SetupWithManager ¶
func (r *VolumeReconciler) SetupWithManager(mgr ctrl.Manager, name string) error
Source Files
¶
- container_common.go
- container_controller.go
- container_exec_controller.go
- container_network_tunnel_proxy_controller.go
- container_network_tunnel_proxy_data.go
- container_watcher.go
- controller_common.go
- controller_common_metrics.go
- controller_harvest.go
- endpoint_common.go
- executable_controller.go
- executable_replica_set_controller.go
- executable_run_info.go
- executable_runner.go
- executable_start_result.go
- network_controller.go
- object_state_map.go
- reconciler_base.go
- reconciler_debouncer.go
- running_container_data.go
- service_controller.go
- service_controller_metrics.go
- volume_controller.go