Documentation
¶
Index ¶
- Constants
- Variables
- func ConfigureEngineForTest(eng engine.ContainerEngine)
- func IsControllerWorkload(labels map[string]string, containerID, image string, ...) bool
- func IsEdgeletSelfContainer(labels map[string]string, containerImage string) bool
- func IsQuiesced() bool
- func SetQuiesced(v bool)
- type ContainerManager
- func (cm *ContainerManager) AddContainer(ctx context.Context, ms *models.Microservice) error
- func (cm *ContainerManager) GetContainerForMicroservice(microserviceUUID string) (*engine.Container, error)
- func (cm *ContainerManager) KillContainerByMicroserviceUUID(ctx context.Context, microserviceUUID string) error
- func (cm *ContainerManager) RecreateContainer(ctx context.Context, ms *models.Microservice, opts RecreateOptions) (string, error)
- func (cm *ContainerManager) RemoveContainerByID(ctx context.Context, containerID string, withCleanup bool, removeImage bool) error
- func (cm *ContainerManager) RemoveContainerByMicroserviceUUID(ctx context.Context, microserviceUUID string, withCleanup bool, ...) error
- func (cm *ContainerManager) RemoveContainerRuntimeForEngineSwitch(ctx context.Context, containerID string) error
- func (cm *ContainerManager) StartContainerByMicroserviceUUID(ctx context.Context, microserviceUUID string) error
- func (cm *ContainerManager) StopContainerByMicroserviceUUID(ctx context.Context, microserviceUUID string) error
- func (cm *ContainerManager) UpdateContainer(ctx context.Context, ms *models.Microservice, withCleanup bool) error
- type ContainerTask
- type ExecSessionCallbackInterface
- type LocalDeployProgressCallback
- type MicroserviceManagerInterface
- type ProcessManager
- func (pm *ProcessManager) CleanupForEngineSwitch(ctx context.Context) error
- func (pm *ProcessManager) CreateExecSession(microserviceUUID string, command []string, ...) (string, error)
- func (pm *ProcessManager) DeleteControlPlane() error
- func (pm *ProcessManager) DrainRuntimeForShutdown(timeout time.Duration) error
- func (pm *ProcessManager) GetContainerByID(containerID string) (*engine.Container, error)
- func (pm *ProcessManager) GetContainerByIDPrefix(prefix string) (*engine.Container, []string, error)
- func (pm *ProcessManager) GetContainerForMicroservice(microserviceUUID string) (*engine.Container, error)
- func (pm *ProcessManager) GetExecSessionExitCode(execID string) (int, error)
- func (pm *ProcessManager) GetExecSessionStatus(execID string) (any, error)
- func (pm *ProcessManager) GetLatestMicroservices() []*models.Microservice
- func (pm *ProcessManager) GetMicroserviceUUIDForContainer(container engine.Container) string
- func (pm *ProcessManager) GetModuleIndex() int
- func (pm *ProcessManager) GetName() string
- func (pm *ProcessManager) InspectContainerRaw(containerID string) (map[string]any, error)
- func (pm *ProcessManager) KillMicroservice(microserviceUUID string) error
- func (pm *ProcessManager) LaunchLocalMicroservice(ms *models.Microservice, registry *models.Registry, hostIP string) (string, error)
- func (pm *ProcessManager) LaunchLocalMicroserviceWithProgress(ms *models.Microservice, registry *models.Registry, hostIP string, ...) (string, error)
- func (pm *ProcessManager) ListImages() ([]engine.ImageInfo, error)
- func (pm *ProcessManager) LoadImageFromPath(path string) ([]engine.LoadedImage, error)
- func (pm *ProcessManager) PruneContainers() (*engine.ContainerPruneReport, error)
- func (pm *ProcessManager) PruneDanglingImages() (*engine.ImagePruneReport, error)
- func (pm *ProcessManager) PruneVolumes() (*engine.VolumePruneReport, error)
- func (pm *ProcessManager) PullImage(imageRef string, registry *models.Registry, platform string) error
- func (pm *ProcessManager) PullImageWithProgress(imageRef string, registry *models.Registry, platform string, ...) error
- func (pm *ProcessManager) RemoveContainerByContainerID(containerID string) error
- func (pm *ProcessManager) RemoveImage(selector string) error
- func (pm *ProcessManager) RemoveMicroservice(microserviceUUID string) error
- func (pm *ProcessManager) ResizeExecSession(execID string, cols, rows uint32) error
- func (pm *ProcessManager) RestartMicroservice(microserviceUUID string) error
- func (pm *ProcessManager) SetEngine(eng engine.ContainerEngine, engineName string)
- func (pm *ProcessManager) Start(eng engine.ContainerEngine, microserviceManager MicroserviceManagerInterface) error
- func (pm *ProcessManager) StartMicroservice(microserviceUUID string) error
- func (pm *ProcessManager) Stop() error
- func (pm *ProcessManager) StopExecSession(_ string, execID string) error
- func (pm *ProcessManager) StopMicroservice(microserviceUUID string) error
- func (pm *ProcessManager) StopRunningMicroservices(iofogUUID string, withCleanup bool) error
- func (pm *ProcessManager) StopRunningMicroservicesWithScope(iofogUUID string, withCleanup bool, includeLocal bool) error
- func (pm *ProcessManager) StreamMicroserviceLogs(microserviceUUID string, cfg *engine.TailConfig, handler engine.LogTailHandler) error
- func (pm *ProcessManager) SyncApplyControlPlaneDeployment(item *models.ControlPlaneDeployment, progress LocalDeployProgressCallback) error
- func (pm *ProcessManager) TailMicroserviceLogs(microserviceUUID string, cfg *engine.TailConfig) ([]map[string]any, error)
- func (pm *ProcessManager) Update()
- type RecreateOptions
- type RestartStuckChecker
- type TaskAction
- type TaskQueue
Constants ¶
const ( // IntervalInMinutes is the time window for checking stuck restarts IntervalInMinutes = 10 // AbnormalNumberOfRestarts is the threshold for considering a microservice stuck AbnormalNumberOfRestarts = 10 )
const (
ContainerManagerModuleName = "Container Manager"
)
const (
ProcessManagerModuleName = "Process Manager"
)
Variables ¶
var ErrControlPlaneNotFound = errors.New("control plane deployment not found")
Functions ¶
func ConfigureEngineForTest ¶
func ConfigureEngineForTest(eng engine.ContainerEngine)
ConfigureEngineForTest wires a test engine into the process manager singleton.
func IsControllerWorkload ¶
func IsControllerWorkload(labels map[string]string, containerID, image string, dep *models.ControlPlaneDeployment) bool
IsControllerWorkload reports whether labels, container ID, and image match the singleton control plane deployment record (full controller identity).
func IsEdgeletSelfContainer ¶
IsEdgeletSelfContainer reports whether the container is the edgelet daemon running inside its own image (EDGELET_DAEMON=container). Set EDGELET_IMAGE on the host container to the image ref used at deploy time so the watchdog can skip self-removal.
func IsQuiesced ¶
func IsQuiesced() bool
IsQuiesced reports whether reconcile is paused (e.g. pending engine restart).
Types ¶
type ContainerManager ¶
type ContainerManager struct {
// contains filtered or unexported fields
}
ContainerManager manages container operations via a ContainerEngine.
func NewContainerManager ¶
func NewContainerManager(eng engine.ContainerEngine, microserviceManager MicroserviceManagerInterface, engineName string) *ContainerManager
NewContainerManager creates a new ContainerManager
func (*ContainerManager) AddContainer ¶
func (cm *ContainerManager) AddContainer(ctx context.Context, ms *models.Microservice) error
AddContainer creates and starts a container for a microservice. It holds IsUpdating=true for the duration so the reconciliation loop treats this microservice as "in-flight" and does not enqueue a second ADD task.
func (*ContainerManager) GetContainerForMicroservice ¶
func (cm *ContainerManager) GetContainerForMicroservice(microserviceUUID string) (*engine.Container, error)
GetContainerForMicroservice returns the container for a microservice, using DB-first lookup when available (iofog engine) with label-based fallback.
func (*ContainerManager) KillContainerByMicroserviceUUID ¶
func (cm *ContainerManager) KillContainerByMicroserviceUUID(ctx context.Context, microserviceUUID string) error
KillContainerByMicroserviceUUID forcefully stops a container by microservice UUID.
func (*ContainerManager) RecreateContainer ¶
func (cm *ContainerManager) RecreateContainer(ctx context.Context, ms *models.Microservice, opts RecreateOptions) (string, error)
RecreateContainer removes an existing workload container when present, then creates and starts a new one from the microservice spec.
func (*ContainerManager) RemoveContainerByID ¶
func (cm *ContainerManager) RemoveContainerByID(ctx context.Context, containerID string, withCleanup bool, removeImage bool) error
RemoveContainerByID removes a container by concrete engine-assigned container ID. This is primarily used by watchdog unknown-container cleanup where there is no guaranteed iofog microservice UUID mapping.
func (*ContainerManager) RemoveContainerByMicroserviceUUID ¶
func (cm *ContainerManager) RemoveContainerByMicroserviceUUID(ctx context.Context, microserviceUUID string, withCleanup bool, removeImage bool) error
RemoveContainerByMicroserviceUUID removes a container by microservice UUID. withCleanup controls Docker named-volume removal (passed to engine.RemoveContainer). removeImage controls whether the container image is also removed after container deletion — set true for normal lifecycle deletions, false for the deprovision path.
func (*ContainerManager) RemoveContainerRuntimeForEngineSwitch ¶
func (cm *ContainerManager) RemoveContainerRuntimeForEngineSwitch(ctx context.Context, containerID string) error
RemoveContainerRuntimeForEngineSwitch removes a workload container without deleting deploy spec rows.
func (*ContainerManager) StartContainerByMicroserviceUUID ¶
func (cm *ContainerManager) StartContainerByMicroserviceUUID(ctx context.Context, microserviceUUID string) error
StartContainerByMicroserviceUUID starts a container by microservice UUID.
func (*ContainerManager) StopContainerByMicroserviceUUID ¶
func (cm *ContainerManager) StopContainerByMicroserviceUUID(ctx context.Context, microserviceUUID string) error
StopContainerByMicroserviceUUID stops a container by microservice UUID
func (*ContainerManager) UpdateContainer ¶
func (cm *ContainerManager) UpdateContainer(ctx context.Context, ms *models.Microservice, withCleanup bool) error
UpdateContainer updates a container for a microservice
type ContainerTask ¶
type ContainerTask struct {
Action TaskAction
MicroserviceUUID string
OperationID string // correlation id for structured logging (set on first execute)
Retries int
Command []string
ExecID string
}
ContainerTask represents a task to be executed on a container
func NewContainerTask ¶
func NewContainerTask(action TaskAction, microserviceUUID string) *ContainerTask
NewContainerTask creates a new ContainerTask
func NewContainerTaskWithExec ¶
func NewContainerTaskWithExec(action TaskAction, microserviceUUID string, command []string) *ContainerTask
NewContainerTaskWithExec creates a new ContainerTask for exec operations
func (*ContainerTask) IncrementRetries ¶
func (t *ContainerTask) IncrementRetries()
IncrementRetries increments the retry count
type ExecSessionCallbackInterface ¶
type ExecSessionCallbackInterface interface {
GetStdinReader() io.Reader
GetStdoutWriter() io.Writer
GetStderrWriter() io.Writer
OnComplete()
OnError(err error)
IsRunning() bool
}
ExecSessionCallbackInterface defines the interface for exec session callbacks
type LocalDeployProgressCallback ¶
LocalDeployProgressCallback reports local deployment runtime stage transitions.
type MicroserviceManagerInterface ¶
type MicroserviceManagerInterface interface {
GetLatestMicroservices() []*models.Microservice
GetCurrentMicroservices() []*models.Microservice
FindLatestMicroserviceByUUID(uuid string) *models.Microservice
GetRegistry(id int) *models.Registry
SetCurrentMicroservices(microservices []*models.Microservice)
}
MicroserviceManagerInterface defines the interface for microservice management This will be implemented by FieldAgent or a dedicated MicroserviceManager
type ProcessManager ¶
type ProcessManager struct {
// contains filtered or unexported fields
}
ProcessManager manages container lifecycle via a ContainerEngine.
func GetInstance ¶
func GetInstance() *ProcessManager
GetInstance returns the singleton ProcessManager instance
func (*ProcessManager) CleanupForEngineSwitch ¶
func (pm *ProcessManager) CleanupForEngineSwitch(ctx context.Context) error
CleanupForEngineSwitch stops/removes all managed workload containers and clears ephemeral DB state.
func (*ProcessManager) CreateExecSession ¶
func (pm *ProcessManager) CreateExecSession(microserviceUUID string, command []string, callback ExecSessionCallbackInterface) (string, error)
CreateExecSession creates and starts an exec session for a microservice. It calls engine.CreateExecSession to register the exec spec, then engine.StartExecSession to attach the callback's I/O pipes and launch the process. This two-phase: createExecSession + startExecSession.
func (*ProcessManager) DeleteControlPlane ¶
func (pm *ProcessManager) DeleteControlPlane() error
DeleteControlPlane stops the controller container, removes volumes, and deletes the singleton row.
func (*ProcessManager) DrainRuntimeForShutdown ¶
func (pm *ProcessManager) DrainRuntimeForShutdown(timeout time.Duration) error
DrainRuntimeForShutdown best-effort drains runtime tasks before manager teardown. It is used during daemon shutdown so containerd can stop without lingering shims.
func (*ProcessManager) GetContainerByID ¶
func (pm *ProcessManager) GetContainerByID(containerID string) (*engine.Container, error)
GetContainerByID resolves one container by concrete container id.
func (*ProcessManager) GetContainerByIDPrefix ¶
func (pm *ProcessManager) GetContainerByIDPrefix(prefix string) (*engine.Container, []string, error)
GetContainerByIDPrefix resolves a container by ID prefix. Returns the matched container and a list of matching IDs for ambiguity reporting.
func (*ProcessManager) GetContainerForMicroservice ¶
func (pm *ProcessManager) GetContainerForMicroservice(microserviceUUID string) (*engine.Container, error)
GetContainerForMicroservice resolves runtime container by microservice UUID.
func (*ProcessManager) GetExecSessionExitCode ¶
func (pm *ProcessManager) GetExecSessionExitCode(execID string) (int, error)
GetExecSessionExitCode returns the exit status for completed exec sessions.
func (*ProcessManager) GetExecSessionStatus ¶
func (pm *ProcessManager) GetExecSessionStatus(execID string) (any, error)
GetExecSessionStatus reports whether the exec process identified by execID is running.
func (*ProcessManager) GetLatestMicroservices ¶
func (pm *ProcessManager) GetLatestMicroservices() []*models.Microservice
GetLatestMicroservices returns the latest microservices from the microservice manager
func (*ProcessManager) GetMicroserviceUUIDForContainer ¶
func (pm *ProcessManager) GetMicroserviceUUIDForContainer(container engine.Container) string
GetMicroserviceUUIDForContainer derives a microservice selector from a container.
func (*ProcessManager) GetModuleIndex ¶
func (pm *ProcessManager) GetModuleIndex() int
GetModuleIndex returns the module index
func (*ProcessManager) GetName ¶
func (pm *ProcessManager) GetName() string
GetName returns the module name
func (*ProcessManager) InspectContainerRaw ¶
func (pm *ProcessManager) InspectContainerRaw(containerID string) (map[string]any, error)
InspectContainerRaw returns full engine-native inspect payload for a container.
func (*ProcessManager) KillMicroservice ¶
func (pm *ProcessManager) KillMicroservice(microserviceUUID string) error
KillMicroservice sends a forceful kill signal to a runtime microservice container.
func (*ProcessManager) LaunchLocalMicroservice ¶
func (pm *ProcessManager) LaunchLocalMicroservice(ms *models.Microservice, registry *models.Registry, hostIP string) (string, error)
LaunchLocalMicroservice creates and starts a locally deployed microservice.
func (*ProcessManager) LaunchLocalMicroserviceWithProgress ¶
func (pm *ProcessManager) LaunchLocalMicroserviceWithProgress(ms *models.Microservice, registry *models.Registry, hostIP string, progress LocalDeployProgressCallback) (string, error)
LaunchLocalMicroserviceWithProgress creates and starts a locally deployed microservice while reporting stage transitions.
func (*ProcessManager) ListImages ¶
func (pm *ProcessManager) ListImages() ([]engine.ImageInfo, error)
ListImages returns local runtime images from the active engine.
func (*ProcessManager) LoadImageFromPath ¶
func (pm *ProcessManager) LoadImageFromPath(path string) ([]engine.LoadedImage, error)
LoadImageFromPath imports an image archive from daemon-local path.
func (*ProcessManager) PruneContainers ¶
func (pm *ProcessManager) PruneContainers() (*engine.ContainerPruneReport, error)
PruneContainers prunes stopped/orphaned containers.
func (*ProcessManager) PruneDanglingImages ¶
func (pm *ProcessManager) PruneDanglingImages() (*engine.ImagePruneReport, error)
PruneDanglingImages prunes dangling images.
func (*ProcessManager) PruneVolumes ¶
func (pm *ProcessManager) PruneVolumes() (*engine.VolumePruneReport, error)
PruneVolumes prunes unused/orphaned volume artifacts.
func (*ProcessManager) PullImage ¶
func (pm *ProcessManager) PullImage(imageRef string, registry *models.Registry, platform string) error
PullImage pulls an image using optional registry credentials and platform selector.
func (*ProcessManager) PullImageWithProgress ¶
func (pm *ProcessManager) PullImageWithProgress(imageRef string, registry *models.Registry, platform string, onProgress func(float32)) error
PullImageWithProgress pulls an image and reports progress percent when available.
func (*ProcessManager) RemoveContainerByContainerID ¶
func (pm *ProcessManager) RemoveContainerByContainerID(containerID string) error
RemoveContainerByContainerID removes a runtime container by concrete container id.
func (*ProcessManager) RemoveImage ¶
func (pm *ProcessManager) RemoveImage(selector string) error
RemoveImage removes an image by ID or name reference.
func (*ProcessManager) RemoveMicroservice ¶
func (pm *ProcessManager) RemoveMicroservice(microserviceUUID string) error
RemoveMicroservice removes a runtime microservice container.
func (*ProcessManager) ResizeExecSession ¶
func (pm *ProcessManager) ResizeExecSession(execID string, cols, rows uint32) error
ResizeExecSession resizes a running tty exec session.
func (*ProcessManager) RestartMicroservice ¶
func (pm *ProcessManager) RestartMicroservice(microserviceUUID string) error
RestartMicroservice performs stop then start for a runtime microservice container.
func (*ProcessManager) SetEngine ¶
func (pm *ProcessManager) SetEngine(eng engine.ContainerEngine, engineName string)
SetEngine swaps the active container engine without restarting the process manager.
func (*ProcessManager) Start ¶
func (pm *ProcessManager) Start(eng engine.ContainerEngine, microserviceManager MicroserviceManagerInterface) error
Start starts the ProcessManager with a given container engine.
func (*ProcessManager) StartMicroservice ¶
func (pm *ProcessManager) StartMicroservice(microserviceUUID string) error
StartMicroservice starts a runtime microservice container.
func (*ProcessManager) StopExecSession ¶
func (pm *ProcessManager) StopExecSession(_ string, execID string) error
StopExecSession kills and deregisters the exec process in the engine. Called when the controller closes the WebSocket so the exec ID can be reused.
func (*ProcessManager) StopMicroservice ¶
func (pm *ProcessManager) StopMicroservice(microserviceUUID string) error
StopMicroservice stops a runtime microservice container.
func (*ProcessManager) StopRunningMicroservices ¶
func (pm *ProcessManager) StopRunningMicroservices(iofogUUID string, withCleanup bool) error
StopRunningMicroservices stops all running microservices matching the iofogUuid. When withCleanup=true (deprovision flow), containers are also removed along with their volumes.
func (*ProcessManager) StopRunningMicroservicesWithScope ¶
func (pm *ProcessManager) StopRunningMicroservicesWithScope(iofogUUID string, withCleanup bool, includeLocal bool) error
StopRunningMicroservicesWithScope stops running microservices matching iofogUuid. includeLocal=false preserves local-scope workloads during deprovision cleanup.
func (*ProcessManager) StreamMicroserviceLogs ¶
func (pm *ProcessManager) StreamMicroserviceLogs(microserviceUUID string, cfg *engine.TailConfig, handler engine.LogTailHandler) error
StreamMicroserviceLogs streams logs for one runtime microservice using the provided tail handler.
func (*ProcessManager) SyncApplyControlPlaneDeployment ¶
func (pm *ProcessManager) SyncApplyControlPlaneDeployment(item *models.ControlPlaneDeployment, progress LocalDeployProgressCallback) error
SyncApplyControlPlaneDeployment persists and synchronously launches or recreates the controller container.
func (*ProcessManager) TailMicroserviceLogs ¶
func (pm *ProcessManager) TailMicroserviceLogs(microserviceUUID string, cfg *engine.TailConfig) ([]map[string]any, error)
TailMicroserviceLogs returns bounded logs for one runtime microservice.
func (*ProcessManager) Update ¶
func (pm *ProcessManager) Update()
Update notifies the ProcessManager of changes updates registries and notifies monitor thread
type RecreateOptions ¶
RecreateOptions controls remove+create lifecycle recreation.
type RestartStuckChecker ¶
type RestartStuckChecker struct {
// contains filtered or unexported fields
}
RestartStuckChecker tracks restart timestamps to detect stuck microservices
func GetRestartStuckChecker ¶
func GetRestartStuckChecker() *RestartStuckChecker
GetRestartStuckChecker returns the singleton RestartStuckChecker instance
func (*RestartStuckChecker) Clear ¶
func (r *RestartStuckChecker) Clear(microserviceUUID string)
Clear removes all tracking data for a microservice (useful for cleanup)
func (*RestartStuckChecker) IsStuck ¶
func (r *RestartStuckChecker) IsStuck(microserviceUUID string) bool
IsStuck checks if a microservice is stuck in restart loop Returns true if the microservice has restarted 10+ times in the last 10 minutes
func (*RestartStuckChecker) IsStuckInContainerCreation ¶
func (r *RestartStuckChecker) IsStuckInContainerCreation(microserviceUUID string) bool
IsStuckInContainerCreation checks if a microservice is stuck in container creation Returns true if the microservice has attempted container creation 10+ times in the last 10 minutes
type TaskAction ¶
type TaskAction string
TaskAction represents the type of container task
const ( TaskActionAdd TaskAction = "ADD" TaskActionUpdate TaskAction = "UPDATE" TaskActionRemove TaskAction = "REMOVE" TaskActionRemoveWithCleanup TaskAction = "REMOVE_WITH_CLEAN_UP" TaskActionStop TaskAction = "STOP" TaskActionCreateExec TaskAction = "CREATE_EXEC" TaskActionGetExecStatus TaskAction = "GET_EXEC_STATUS" TaskActionKillExec TaskAction = "KILL_EXEC" )
type TaskQueue ¶
type TaskQueue struct {
// contains filtered or unexported fields
}
TaskQueue manages container tasks in a thread-safe queue
func NewTaskQueue ¶
NewTaskQueue creates a new TaskQueue with the specified buffer size
func (*TaskQueue) Add ¶
func (q *TaskQueue) Add(task *ContainerTask)
Add adds a task to the queue. Silently drops the task if the queue is full (capacity = 100); this should never happen under normal operating conditions.
func (*TaskQueue) Get ¶
func (q *TaskQueue) Get(ctx context.Context) (*ContainerTask, bool)
Get blocks until a task is available or the context is canceled. Returns (task, true) on success and (nil, false) when the context is done.
func (*TaskQueue) TryGet ¶
func (q *TaskQueue) TryGet() (*ContainerTask, bool)
TryGet attempts to retrieve a task from the queue without blocking.