Documentation
¶
Index ¶
- Constants
- func ApplyDesiredRuntimeClasses(cfg *config.Config, items []*models.ControllerRuntimeClass) error
- func ConfigureRegisterTestClient(baseURL string, httpClient *http.Client)
- func ConfigureRegisterTestRuntime(ctx context.Context, connected bool)
- func IsControllerEndpointMissing(err error) bool
- func IsControllerNotReady(err error) bool
- func IsLegacyControllerAuthError(err error) bool
- func IsNonRetryableAgentAuthError(err error) bool
- func IsRetryableControllerError(err error) bool
- func MarkControllerRegisterSucceededForTest(uuid string)
- func ParseControllerAPIError(status int, body string) error
- func ReadFile(filename string) (json.RawMessage, int64, error)
- func ReadFileAsArray(filename string) ([]map[string]any, int64, error)
- func ResetControllerRegisterStateForTest()
- func SaveFile(data any, filename string) error
- type APIClient
- func (c *APIClient) Delete(ctx context.Context, command string) error
- func (c *APIClient) GetJSON(ctx context.Context, command string, result any) error
- func (c *APIClient) PatchJSON(ctx context.Context, command string, body any) error
- func (c *APIClient) Ping(ctx context.Context) (bool, error)
- func (c *APIClient) PostJSON(ctx context.Context, command string, body any, result any) error
- func (c *APIClient) PutJSON(ctx context.Context, command string, body any) error
- func (c *APIClient) Request(ctx context.Context, command string, requestType RequestType, ...) (map[string]any, error)
- type CacheFile
- type ConnectionState
- type ControllerAPIError
- type ExecSession
- type ExecSessionCallback
- func (c *ExecSessionCallback) Close()
- func (c *ExecSessionCallback) GetExecID() string
- func (c *ExecSessionCallback) GetStderrWriter() io.Writer
- func (c *ExecSessionCallback) GetStdin() io.WriteCloser
- func (c *ExecSessionCallback) GetStdinReader() io.Reader
- func (c *ExecSessionCallback) GetStdoutWriter() io.Writer
- func (c *ExecSessionCallback) IsRunning() bool
- func (c *ExecSessionCallback) OnActivation()
- func (c *ExecSessionCallback) OnComplete()
- func (c *ExecSessionCallback) OnError(err error)
- func (c *ExecSessionCallback) SetExecID(execID string)
- func (c *ExecSessionCallback) SetOnCloseHandler(handler func())
- func (c *ExecSessionCallback) SetOnErrorHandler(handler func([]byte))
- func (c *ExecSessionCallback) SetOnInputHandler(handler func([]byte))
- func (c *ExecSessionCallback) SetOnOutputHandler(handler func([]byte))
- func (c *ExecSessionCallback) WriteInput(data []byte) error
- type ExecSessionInfo
- type ExecSessionManager
- func (esm *ExecSessionManager) FetchExecSessions(ctx context.Context) ([]*ExecSession, error)
- func (esm *ExecSessionManager) GetCallback(sessionID string) *ExecSessionCallback
- func (esm *ExecSessionManager) HandleExecSessions(fetchedSessions []*ExecSession)
- func (esm *ExecSessionManager) ListActiveControllerSessionIDs(msUUID string) []string
- func (esm *ExecSessionManager) SetProcessManager(pm *processmanager.ProcessManager)
- func (esm *ExecSessionManager) StopAllInteractiveForMicroservice(msUUID string)
- func (esm *ExecSessionManager) StopExecSession(sessionID string)
- type ExecSessionWebSocketHandler
- func (h *ExecSessionWebSocketHandler) Connect() error
- func (h *ExecSessionWebSocketHandler) Disconnect()
- func (h *ExecSessionWebSocketHandler) GetConnectionState() ConnectionState
- func (h *ExecSessionWebSocketHandler) IsActive() bool
- func (h *ExecSessionWebSocketHandler) IsConnected() bool
- func (h *ExecSessionWebSocketHandler) Reset()
- func (h *ExecSessionWebSocketHandler) SendMessage(msgType byte, data []byte) error
- func (h *ExecSessionWebSocketHandler) SetExecSessionManager(esm *ExecSessionManager)
- type FieldAgent
- func (fa *FieldAgent) Clear()
- func (fa *FieldAgent) Deprovision(clearCredentials bool) error
- func (fa *FieldAgent) DeprovisionWithOptions(clearCredentials bool, scope string, purgeVolumes bool) error
- func (fa *FieldAgent) DeprovisionWithScope(clearCredentials bool, scope string) error
- func (fa *FieldAgent) FindLatestMicroserviceByUUID(uuid string) *models.Microservice
- func (fa *FieldAgent) FogKnowledgeStatus() (knowledgeStatus string, activeKnowledge int, knowledgeLastUpdate int64)
- func (fa *FieldAgent) GetContainerConfig(microserviceUUID string) (string, bool)
- func (fa *FieldAgent) GetCurrentMicroservices() []*models.Microservice
- func (fa *FieldAgent) GetLatestMicroservices() []*models.Microservice
- func (fa *FieldAgent) GetModuleIndex() int
- func (fa *FieldAgent) GetName() string
- func (fa *FieldAgent) GetRegistry(id int) *models.Registry
- func (fa *FieldAgent) InstanceGPSConfigUpdated() error
- func (fa *FieldAgent) IsControllerConnected(fromFile bool) bool
- func (fa *FieldAgent) NotProvisioned() bool
- func (fa *FieldAgent) OnProcessManagerReady()
- func (fa *FieldAgent) PostStatusHelper()
- func (fa *FieldAgent) Provision(key string) error
- func (fa *FieldAgent) SetControllerStatus(status models.ControllerStatus)
- func (fa *FieldAgent) SetCurrentMicroservices(microservices []*models.Microservice)
- func (fa *FieldAgent) SetKnowledgeManager(m *knowledgemanager.Manager)
- func (fa *FieldAgent) SetModelManager(m *modelmanager.Manager)
- func (fa *FieldAgent) SetOnConfigsUpdate(callback func(changedUUIDs []string) error)
- func (fa *FieldAgent) SetOnMicroservicesUpdate(callback func([]*models.Microservice) error)
- func (fa *FieldAgent) SetOnRegistriesUpdate(callback func([]*models.Registry) error)
- func (fa *FieldAgent) SetProcessManager(pm *processmanager.ProcessManager)
- func (fa *FieldAgent) Start() error
- func (fa *FieldAgent) Stop() error
- func (fa *FieldAgent) SyncControllerRegister(force bool) bool
- func (fa *FieldAgent) Update() error
- type LogConnectionState
- type LogSession
- type LogSessionInfo
- type LogSessionManager
- func (lsm *LogSessionManager) FetchLogSessions(ctx context.Context) ([]*LogSession, error)
- func (lsm *LogSessionManager) HandleLogSessions(fetchedSessions []*LogSession)
- func (lsm *LogSessionManager) HandleWebSocketTransportClose(sessionID string)
- func (lsm *LogSessionManager) SetEngine(e engine.ContainerEngine)
- func (lsm *LogSessionManager) SetProcessManager(pm *processmanager.ProcessManager)
- func (lsm *LogSessionManager) StartLogStreamingOnActivation(sessionID string, tailConfigMap map[string]any)
- func (lsm *LogSessionManager) StartWorker(ctx context.Context)
- func (lsm *LogSessionManager) StopLogSession(sessionID string)
- type LogSessionWebSocketHandler
- func (h *LogSessionWebSocketHandler) Connect() error
- func (h *LogSessionWebSocketHandler) Disconnect()
- func (h *LogSessionWebSocketHandler) DisconnectWithReason(reason string)
- func (h *LogSessionWebSocketHandler) GetConnectionState() LogConnectionState
- func (h *LogSessionWebSocketHandler) IsActive() bool
- func (h *LogSessionWebSocketHandler) IsConnected() bool
- func (h *LogSessionWebSocketHandler) Reset()
- func (h *LogSessionWebSocketHandler) SendMessage(msgType byte, data []byte) error
- func (h *LogSessionWebSocketHandler) SetLogSessionManager(lsm *LogSessionManager)
- type Orchestrator
- func (o *Orchestrator) GetControllerCert(ctx context.Context) (string, error)
- func (o *Orchestrator) GetJSON(ctx context.Context, command string, result any) error
- func (o *Orchestrator) Ping(ctx context.Context) (bool, error)
- func (o *Orchestrator) Provision(ctx context.Context, key string) (map[string]any, error)
- func (o *Orchestrator) Request(ctx context.Context, command string, requestType RequestType, ...) (map[string]any, error)
- func (o *Orchestrator) Update() error
- type RequestType
- type State
- func (s *State) GetControllerStatus() models.ControllerStatus
- func (s *State) GetLastCommandTime() int64
- func (s *State) GetLastGetChangesList() int64
- func (s *State) IsConnected() bool
- func (s *State) IsControllerVerified() bool
- func (s *State) IsInitialization() bool
- func (s *State) SetConnected(connected bool)
- func (s *State) SetControllerStatus(status models.ControllerStatus)
- func (s *State) SetControllerVerified(verified bool)
- func (s *State) SetInitialization(init bool)
- func (s *State) SetLastCommandTime(timestamp int64)
- func (s *State) SetLastGetChangesList(timestamp int64)
- func (s *State) UpdateLastCommandTime()
Constants ¶
const ( DeprovisionScopeAll = "all" DeprovisionScopeLocal = "local" )
const ( ExecTypeStdin byte = 0 ExecTypeStdout byte = 1 ExecTypeStderr byte = 2 ExecTypeControl byte = 3 ExecTypeClose byte = 4 ExecTypeActivation byte = 5 )
ExecMessageType constants
const ( LogTypeLogLine byte = 6 LogTypeLogStart byte = 7 LogTypeLogStop byte = 8 LogTypeLogError byte = 9 )
LogMessageType constants
const ControllerSessionMaxDuration = 24 * time.Hour
ControllerSessionMaxDuration is the hard cap for controller-attached log/exec sessions on the agent.
Variables ¶
This section is empty.
Functions ¶
func ApplyDesiredRuntimeClasses ¶ added in v1.1.0
func ApplyDesiredRuntimeClasses(cfg *config.Config, items []*models.ControllerRuntimeClass) error
ApplyDesiredRuntimeClasses applies fleet RuntimeClasses on the edgelet engine using the local persist path (source=managed). Docker and podman keep the desired snapshot and skip apply so the node stays healthy.
func ConfigureRegisterTestClient ¶
ConfigureRegisterTestClient wires a test HTTP client for controller/register calls.
func ConfigureRegisterTestRuntime ¶
ConfigureRegisterTestRuntime wires field agent state for controller register integration tests.
func IsControllerEndpointMissing ¶ added in v1.1.0
IsControllerEndpointMissing reports a 404 for an unknown controller command path.
func IsControllerNotReady ¶ added in v1.0.2
IsControllerNotReady reports readiness probe 503 responses.
func IsLegacyControllerAuthError ¶ added in v1.0.2
IsLegacyControllerAuthError reports legacy 401 responses without structured codes.
func IsNonRetryableAgentAuthError ¶ added in v1.0.2
IsNonRetryableAgentAuthError reports structured agent 401 auth failures.
func IsRetryableControllerError ¶ added in v1.0.2
IsRetryableControllerError reports whether the error should be retried.
func MarkControllerRegisterSucceededForTest ¶
func MarkControllerRegisterSucceededForTest(uuid string)
MarkControllerRegisterSucceededForTest marks a controller UUID as registered in memory.
func ParseControllerAPIError ¶ added in v1.0.2
ParseControllerAPIError parses a controller error response body.
func ReadFile ¶
func ReadFile(filename string) (json.RawMessage, int64, error)
ReadFile reads data from a cache file and validates checksum
func ReadFileAsArray ¶
ReadFileAsArray reads a cached file as a JSON array
func ResetControllerRegisterStateForTest ¶
func ResetControllerRegisterStateForTest()
ResetControllerRegisterStateForTest clears in-memory register markers.
Types ¶
type APIClient ¶
type APIClient struct {
// contains filtered or unexported fields
}
APIClient handles all HTTP communication with the controller
func NewAPIClient ¶
NewAPIClient creates a new API client for controller communication
type CacheFile ¶
type CacheFile struct {
Checksum string `json:"checksum"`
Timestamp int64 `json:"timestamp"`
Data json.RawMessage `json:"data"`
}
CacheFile represents a cached file with checksum and timestamp
type ConnectionState ¶
type ConnectionState int
ConnectionState represents the WebSocket connection state
const ( StateDisconnected ConnectionState = iota StateConnecting StateConnected StatePending // Connected but waiting for user StateActive // Connected and paired with user )
type ControllerAPIError ¶ added in v1.0.2
type ControllerAPIError struct {
StatusCode int
ErrorKind string // JSON "error" field (e.g. "Unauthorized")
Code string
Message string
Retryable bool
Body string
Legacy bool // true when no code/retryable (name+message only)
}
ControllerAPIError represents a structured error response from the controller.
func (*ControllerAPIError) Error ¶ added in v1.0.2
func (e *ControllerAPIError) Error() string
type ExecSession ¶
type ExecSession struct {
SessionID string `json:"sessionId"`
MicroserviceUUID string `json:"microserviceUuid"`
Status string `json:"status"` // PENDING, ACTIVE
AgentConnected bool `json:"agentConnected"`
}
ExecSession represents a controller exec session row from poll.
type ExecSessionCallback ¶
type ExecSessionCallback struct {
// contains filtered or unexported fields
}
ExecSessionCallback handles Docker exec session I/O and bridges it to WebSocket
func NewExecSessionCallback ¶
func NewExecSessionCallback(microserviceUUID, execID string) *ExecSessionCallback
NewExecSessionCallback creates a new ExecSessionCallback
func (*ExecSessionCallback) Close ¶
func (c *ExecSessionCallback) Close()
Close closes the exec session callback
func (*ExecSessionCallback) GetExecID ¶
func (c *ExecSessionCallback) GetExecID() string
GetExecID returns the exec session ID
func (*ExecSessionCallback) GetStderrWriter ¶
func (c *ExecSessionCallback) GetStderrWriter() io.Writer
GetStderrWriter returns the stderr writer for ProcessManager
func (*ExecSessionCallback) GetStdin ¶
func (c *ExecSessionCallback) GetStdin() io.WriteCloser
GetStdin returns the stdin writer
func (*ExecSessionCallback) GetStdinReader ¶
func (c *ExecSessionCallback) GetStdinReader() io.Reader
GetStdinReader returns the stdin reader for ProcessManager
func (*ExecSessionCallback) GetStdoutWriter ¶
func (c *ExecSessionCallback) GetStdoutWriter() io.Writer
GetStdoutWriter returns the stdout writer for ProcessManager
func (*ExecSessionCallback) IsRunning ¶
func (c *ExecSessionCallback) IsRunning() bool
IsRunning returns whether the callback is running
func (*ExecSessionCallback) OnActivation ¶
func (c *ExecSessionCallback) OnActivation()
OnActivation is called when the exec session is activated
func (*ExecSessionCallback) OnComplete ¶
func (c *ExecSessionCallback) OnComplete()
OnComplete is called when the exec session completes
func (*ExecSessionCallback) OnError ¶
func (c *ExecSessionCallback) OnError(err error)
OnError is called when the exec session encounters an error
func (*ExecSessionCallback) SetExecID ¶
func (c *ExecSessionCallback) SetExecID(execID string)
SetExecID sets the exec session ID
func (*ExecSessionCallback) SetOnCloseHandler ¶
func (c *ExecSessionCallback) SetOnCloseHandler(handler func())
SetOnCloseHandler sets the handler for close events
func (*ExecSessionCallback) SetOnErrorHandler ¶
func (c *ExecSessionCallback) SetOnErrorHandler(handler func([]byte))
SetOnErrorHandler sets the handler for error data
func (*ExecSessionCallback) SetOnInputHandler ¶
func (c *ExecSessionCallback) SetOnInputHandler(handler func([]byte))
SetOnInputHandler sets the handler for input data
func (*ExecSessionCallback) SetOnOutputHandler ¶
func (c *ExecSessionCallback) SetOnOutputHandler(handler func([]byte))
SetOnOutputHandler sets the handler for output data
func (*ExecSessionCallback) WriteInput ¶
func (c *ExecSessionCallback) WriteInput(data []byte) error
WriteInput writes input data to stdin
type ExecSessionInfo ¶
type ExecSessionInfo struct {
Session *ExecSession
Callback *ExecSessionCallback
}
ExecSessionInfo tracks a local controller exec attachment.
type ExecSessionManager ¶
type ExecSessionManager struct {
// contains filtered or unexported fields
}
ExecSessionManager manages controller exec session attachments (log-session parity).
func GetExecSessionManager ¶
func GetExecSessionManager() *ExecSessionManager
GetExecSessionManager returns the singleton ExecSessionManager instance.
func (*ExecSessionManager) FetchExecSessions ¶
func (esm *ExecSessionManager) FetchExecSessions(ctx context.Context) ([]*ExecSession, error)
FetchExecSessions fetches exec sessions from the controller.
func (*ExecSessionManager) GetCallback ¶
func (esm *ExecSessionManager) GetCallback(sessionID string) *ExecSessionCallback
GetCallback returns the exec callback for a session id.
func (*ExecSessionManager) HandleExecSessions ¶
func (esm *ExecSessionManager) HandleExecSessions(fetchedSessions []*ExecSession)
HandleExecSessions reconciles local controller exec attachments with polled rows.
func (*ExecSessionManager) ListActiveControllerSessionIDs ¶
func (esm *ExecSessionManager) ListActiveControllerSessionIDs(msUUID string) []string
ListActiveControllerSessionIDs returns sorted controller attachment session ids for one microservice.
func (*ExecSessionManager) SetProcessManager ¶
func (esm *ExecSessionManager) SetProcessManager(pm *processmanager.ProcessManager)
SetProcessManager sets the ProcessManager instance (called by supervisor).
func (*ExecSessionManager) StopAllInteractiveForMicroservice ¶
func (esm *ExecSessionManager) StopAllInteractiveForMicroservice(msUUID string)
StopAllInteractiveForMicroservice stops all exec attachments and runtime sessions for one MS.
func (*ExecSessionManager) StopExecSession ¶
func (esm *ExecSessionManager) StopExecSession(sessionID string)
StopExecSession stops one controller exec attachment (thread-safe).
type ExecSessionWebSocketHandler ¶
type ExecSessionWebSocketHandler struct {
// contains filtered or unexported fields
}
ExecSessionWebSocketHandler manages the WebSocket connection for exec sessions
func GetExecSessionWebSocketHandler ¶
func GetExecSessionWebSocketHandler(sessionID, microserviceUUID string) *ExecSessionWebSocketHandler
GetExecSessionWebSocketHandler gets or creates an ExecSessionWebSocketHandler for a session.
func (*ExecSessionWebSocketHandler) Connect ¶
func (h *ExecSessionWebSocketHandler) Connect() error
Connect establishes the WebSocket connection to the controller. Call Reset() before Connect() when starting a new exec session. No init pairing frame is sent.
func (*ExecSessionWebSocketHandler) Disconnect ¶
func (h *ExecSessionWebSocketHandler) Disconnect()
Disconnect closes the WebSocket connection and resets handler state for reuse.
func (*ExecSessionWebSocketHandler) GetConnectionState ¶
func (h *ExecSessionWebSocketHandler) GetConnectionState() ConnectionState
GetConnectionState returns the current connection state (for tests and diagnostics).
func (*ExecSessionWebSocketHandler) IsActive ¶
func (h *ExecSessionWebSocketHandler) IsActive() bool
IsActive returns whether the exec session is active
func (*ExecSessionWebSocketHandler) IsConnected ¶
func (h *ExecSessionWebSocketHandler) IsConnected() bool
IsConnected returns whether the WebSocket is connected
func (*ExecSessionWebSocketHandler) Reset ¶
func (h *ExecSessionWebSocketHandler) Reset()
Reset tears down transport state and prepares the handler for a fresh Connect().
func (*ExecSessionWebSocketHandler) SendMessage ¶
func (h *ExecSessionWebSocketHandler) SendMessage(msgType byte, data []byte) error
SendMessage sends a message to the controller with execId = sessionId. Output is buffered while disconnected or pending activation.
func (*ExecSessionWebSocketHandler) SetExecSessionManager ¶
func (h *ExecSessionWebSocketHandler) SetExecSessionManager(esm *ExecSessionManager)
SetExecSessionManager sets the manager reference for session lifecycle callbacks.
type FieldAgent ¶
type FieldAgent struct {
// contains filtered or unexported fields
}
FieldAgent handles all communication with the fog controller
func GetInstance ¶
func GetInstance() *FieldAgent
GetInstance returns the singleton FieldAgent instance
func (*FieldAgent) Deprovision ¶
func (fa *FieldAgent) Deprovision(clearCredentials bool) error
Deprovision deprovisions the agent clearCredentials=true skip controller request
func (*FieldAgent) DeprovisionWithOptions ¶ added in v1.1.0
func (fa *FieldAgent) DeprovisionWithOptions(clearCredentials bool, scope string, purgeVolumes bool) error
DeprovisionWithOptions deprovisions the agent with cleanup scope and optional persistent-volume purge. Automatic callers (delete-node, Edge Guard, status-auth) must pass purgeVolumes=false so volumes/data and volumes/shared remount later.
func (*FieldAgent) DeprovisionWithScope ¶
func (fa *FieldAgent) DeprovisionWithScope(clearCredentials bool, scope string) error
DeprovisionWithScope deprovisions the agent and controls cleanup scope. scope=all removes managed+local workloads; scope=local preserves local workloads. Persistent VOLUME trees are preserved unless purgeVolumes is set via DeprovisionWithOptions.
func (*FieldAgent) FindLatestMicroserviceByUUID ¶
func (fa *FieldAgent) FindLatestMicroserviceByUUID(uuid string) *models.Microservice
FindLatestMicroserviceByUUID finds a microservice by UUID
func (*FieldAgent) FogKnowledgeStatus ¶ added in v1.1.0
func (fa *FieldAgent) FogKnowledgeStatus() (knowledgeStatus string, activeKnowledge int, knowledgeLastUpdate int64)
FogKnowledgeStatus returns additive fog and local knowledge status keys. knowledgeStatus is a JSON string; activeKnowledge is the managed count only.
func (*FieldAgent) GetContainerConfig ¶
func (fa *FieldAgent) GetContainerConfig(microserviceUUID string) (string, bool)
GetContainerConfig returns the container config string for a microservice UUID
func (*FieldAgent) GetCurrentMicroservices ¶
func (fa *FieldAgent) GetCurrentMicroservices() []*models.Microservice
GetCurrentMicroservices returns the current microservices (same as latest for now)
func (*FieldAgent) GetLatestMicroservices ¶
func (fa *FieldAgent) GetLatestMicroservices() []*models.Microservice
GetLatestMicroservices returns the latest microservices from the controller
func (*FieldAgent) GetModuleIndex ¶
func (fa *FieldAgent) GetModuleIndex() int
GetModuleIndex returns the module index
func (*FieldAgent) GetRegistry ¶
func (fa *FieldAgent) GetRegistry(id int) *models.Registry
GetRegistry returns a registry by ID
func (*FieldAgent) InstanceGPSConfigUpdated ¶
func (fa *FieldAgent) InstanceGPSConfigUpdated() error
InstanceGPSConfigUpdated sends dedicated GPS config updates to the controller.
func (*FieldAgent) IsControllerConnected ¶
func (fa *FieldAgent) IsControllerConnected(fromFile bool) bool
IsControllerConnected reports whether live controller I/O should proceed. Cache reads pass fromFile=true; live paths use cached reachability from ping workers.
func (*FieldAgent) NotProvisioned ¶
func (fa *FieldAgent) NotProvisioned() bool
NotProvisioned checks if the agent is not provisioned
func (*FieldAgent) OnProcessManagerReady ¶
func (fa *FieldAgent) OnProcessManagerReady()
OnProcessManagerReady notifies the process manager after cache bootstrap when PM is wired later in supervisor startup.
func (*FieldAgent) PostStatusHelper ¶
func (fa *FieldAgent) PostStatusHelper()
PostStatusHelper posts the fog status to the controller Exported for use by Edge Guard to immediately notify controller of hardware changes
func (*FieldAgent) Provision ¶
func (fa *FieldAgent) Provision(key string) error
Provision provisions the agent with the controller
func (*FieldAgent) SetControllerStatus ¶
func (fa *FieldAgent) SetControllerStatus(status models.ControllerStatus)
SetControllerStatus updates the agent controller connection status.
func (*FieldAgent) SetCurrentMicroservices ¶
func (fa *FieldAgent) SetCurrentMicroservices(microservices []*models.Microservice)
SetCurrentMicroservices sets the current microservices
func (*FieldAgent) SetKnowledgeManager ¶ added in v1.1.0
func (fa *FieldAgent) SetKnowledgeManager(m *knowledgemanager.Manager)
SetKnowledgeManager sets the Knowledge manager used for fleet-desired Knowledge ingest.
func (*FieldAgent) SetModelManager ¶ added in v1.1.0
func (fa *FieldAgent) SetModelManager(m *modelmanager.Manager)
SetModelManager sets the Model manager used for fleet-desired Model ingest.
func (*FieldAgent) SetOnConfigsUpdate ¶
func (fa *FieldAgent) SetOnConfigsUpdate(callback func(changedUUIDs []string) error)
SetOnConfigsUpdate sets the callback when microservice config content changes.
func (*FieldAgent) SetOnMicroservicesUpdate ¶
func (fa *FieldAgent) SetOnMicroservicesUpdate(callback func([]*models.Microservice) error)
SetOnMicroservicesUpdate sets the callback for microservices updates
func (*FieldAgent) SetOnRegistriesUpdate ¶
func (fa *FieldAgent) SetOnRegistriesUpdate(callback func([]*models.Registry) error)
SetOnRegistriesUpdate sets the callback for registries updates
func (*FieldAgent) SetProcessManager ¶
func (fa *FieldAgent) SetProcessManager(pm *processmanager.ProcessManager)
SetProcessManager sets the ProcessManager reference
func (*FieldAgent) Start ¶
func (fa *FieldAgent) Start() error
Start starts the FieldAgent and all background workers
func (*FieldAgent) Stop ¶
func (fa *FieldAgent) Stop() error
Stop stops the FieldAgent and all background workers
func (*FieldAgent) SyncControllerRegister ¶
func (fa *FieldAgent) SyncControllerRegister(force bool) bool
SyncControllerRegister upserts the controller microservice. When force is false, skips if register already succeeded for this UUID. When force is true, always attempts upsert when preconditions are met (e.g. after CP patch apply).
func (*FieldAgent) Update ¶
func (fa *FieldAgent) Update() error
Update updates the FieldAgent when configuration changes. Most workers re-read config on every tick; upgradeScanWorker is notified explicitly when upgradeScanFrequency changes so its timer is reset immediately. NewAPIClient() is moved into the background goroutine so the SIGHUP handler goroutine is never blocked by DNS resolution for the new controller URL.
type LogConnectionState ¶
type LogConnectionState int
LogConnectionState represents the WebSocket connection state
const ( LogStateDisconnected LogConnectionState = iota LogStateConnecting LogStateConnected LogStatePending // Connected but waiting for LOG_START LogStateActive // Connected and streaming logs )
type LogSession ¶
type LogSession struct {
SessionID string `json:"sessionId"`
MicroserviceUUID string `json:"microserviceUuid,omitempty"`
IofogUUID string `json:"iofogUuid,omitempty"`
Status string `json:"status"` // ACTIVE, PENDING, etc.
}
LogSession represents a log session from the controller
type LogSessionInfo ¶
type LogSessionInfo struct {
Session *LogSession
ContainerID string
IsStreaming bool
// contains filtered or unexported fields
}
LogSessionInfo tracks information about an active log session
type LogSessionManager ¶
type LogSessionManager struct {
// contains filtered or unexported fields
}
LogSessionManager manages active log sessions
func GetLogSessionManager ¶
func GetLogSessionManager() *LogSessionManager
GetLogSessionManager returns the singleton LogSessionManager instance.
func (*LogSessionManager) FetchLogSessions ¶
func (lsm *LogSessionManager) FetchLogSessions(ctx context.Context) ([]*LogSession, error)
FetchLogSessions fetches log sessions from the controller
func (*LogSessionManager) HandleLogSessions ¶
func (lsm *LogSessionManager) HandleLogSessions(fetchedSessions []*LogSession)
HandleLogSessions handles fetched log sessions from controller
func (*LogSessionManager) HandleWebSocketTransportClose ¶
func (lsm *LogSessionManager) HandleWebSocketTransportClose(sessionID string)
HandleWebSocketTransportClose stops log tailing when the controller WebSocket drops. The session row is retained so HandleLogSessions can reconnect on the next poll.
func (*LogSessionManager) SetEngine ¶
func (lsm *LogSessionManager) SetEngine(e engine.ContainerEngine)
SetEngine sets the ContainerEngine used to look up containers and tail their logs. Must be called before log session streaming starts (from supervisor after engine init).
func (*LogSessionManager) SetProcessManager ¶
func (lsm *LogSessionManager) SetProcessManager(pm *processmanager.ProcessManager)
SetProcessManager sets the ProcessManager instance (called by supervisor).
func (*LogSessionManager) StartLogStreamingOnActivation ¶
func (lsm *LogSessionManager) StartLogStreamingOnActivation(sessionID string, tailConfigMap map[string]any)
StartLogStreamingOnActivation starts log streaming when WebSocket becomes active This method is called from LogSessionWebSocketHandler when it receives LOG_START
func (*LogSessionManager) StartWorker ¶
func (lsm *LogSessionManager) StartWorker(ctx context.Context)
StartWorker starts the background worker that periodically fetches and handles log sessions
func (*LogSessionManager) StopLogSession ¶
func (lsm *LogSessionManager) StopLogSession(sessionID string)
StopLogSession stops a log session (thread-safe)
type LogSessionWebSocketHandler ¶
type LogSessionWebSocketHandler struct {
// contains filtered or unexported fields
}
LogSessionWebSocketHandler manages the WebSocket connection for log sessions
func GetLogSessionWebSocketHandler ¶
func GetLogSessionWebSocketHandler(sessionID, microserviceUUID, iofogUUID string, isMicroserviceLog bool) *LogSessionWebSocketHandler
GetLogSessionWebSocketHandler gets or creates a LogSessionWebSocketHandler for a session
func (*LogSessionWebSocketHandler) Connect ¶
func (h *LogSessionWebSocketHandler) Connect() error
Connect establishes the WebSocket connection to the controller. Call Reset() before Connect() when reusing a handler for a new session.
func (*LogSessionWebSocketHandler) Disconnect ¶
func (h *LogSessionWebSocketHandler) Disconnect()
Disconnect closes the WebSocket connection and resets handler state for reuse.
func (*LogSessionWebSocketHandler) DisconnectWithReason ¶
func (h *LogSessionWebSocketHandler) DisconnectWithReason(reason string)
DisconnectWithReason closes the WebSocket with a specific close reason before reset.
func (*LogSessionWebSocketHandler) GetConnectionState ¶
func (h *LogSessionWebSocketHandler) GetConnectionState() LogConnectionState
GetConnectionState returns the current connection state (for tests and diagnostics).
func (*LogSessionWebSocketHandler) IsActive ¶
func (h *LogSessionWebSocketHandler) IsActive() bool
IsActive returns whether the log session is active
func (*LogSessionWebSocketHandler) IsConnected ¶
func (h *LogSessionWebSocketHandler) IsConnected() bool
IsConnected returns whether the WebSocket is connected
func (*LogSessionWebSocketHandler) Reset ¶
func (h *LogSessionWebSocketHandler) Reset()
Reset tears down transport state and prepares the handler for a fresh Connect().
func (*LogSessionWebSocketHandler) SendMessage ¶
func (h *LogSessionWebSocketHandler) SendMessage(msgType byte, data []byte) error
SendMessage sends a log message to the controller. Output is buffered while disconnected or pending activation (exec-session parity).
func (*LogSessionWebSocketHandler) SetLogSessionManager ¶
func (h *LogSessionWebSocketHandler) SetLogSessionManager(lsm *LogSessionManager)
SetLogSessionManager sets the LogSessionManager reference
type Orchestrator ¶
type Orchestrator struct {
// contains filtered or unexported fields
}
Orchestrator wraps APIClient with additional methods
func NewOrchestrator ¶
func NewOrchestrator(apiClient *APIClient) *Orchestrator
NewOrchestrator creates a new Orchestrator instance
func (*Orchestrator) GetControllerCert ¶
func (o *Orchestrator) GetControllerCert(ctx context.Context) (string, error)
GetControllerCert gets the controller certificate from the controller Note: This uses an insecure connection to get the certificate when current cert is invalid
func (*Orchestrator) Ping ¶
func (o *Orchestrator) Ping(ctx context.Context) (bool, error)
Ping pings the IOFog controller
func (*Orchestrator) Request ¶
func (o *Orchestrator) Request(ctx context.Context, command string, requestType RequestType, queryParams map[string]string, body any) (map[string]any, error)
Request performs an HTTP request (wrapper around APIClient.Request)
func (*Orchestrator) Update ¶
func (o *Orchestrator) Update() error
Update updates the orchestrator configuration
type RequestType ¶
type RequestType string
RequestType represents HTTP request types
const ( GET RequestType = "GET" POST RequestType = "POST" PUT RequestType = "PUT" PATCH RequestType = "PATCH" DELETE RequestType = "DELETE" )
type State ¶
type State struct {
// contains filtered or unexported fields
}
State represents the current state of the FieldAgent
func (*State) GetControllerStatus ¶
func (s *State) GetControllerStatus() models.ControllerStatus
GetControllerStatus returns the controller status
func (*State) GetLastCommandTime ¶
GetLastCommandTime returns the last command time
func (*State) GetLastGetChangesList ¶
GetLastGetChangesList returns the last time changes were retrieved
func (*State) IsConnected ¶
IsConnected returns whether we're connected to the controller
func (*State) IsControllerVerified ¶
IsControllerVerified returns whether the controller is verified
func (*State) IsInitialization ¶
IsInitialization returns whether we're in initialization phase
func (*State) SetConnected ¶
SetConnected sets the connected status
func (*State) SetControllerStatus ¶
func (s *State) SetControllerStatus(status models.ControllerStatus)
SetControllerStatus sets the controller status
func (*State) SetControllerVerified ¶
SetControllerVerified sets the controller verified flag
func (*State) SetInitialization ¶
SetInitialization sets the initialization flag
func (*State) SetLastCommandTime ¶
SetLastCommandTime sets the last command time
func (*State) SetLastGetChangesList ¶
SetLastGetChangesList sets the last time changes were retrieved
func (*State) UpdateLastCommandTime ¶
func (s *State) UpdateLastCommandTime()
UpdateLastCommandTime updates the last command time to current time
Source Files
¶
- agent.go
- api_client.go
- bootstrap_sync.go
- cache.go
- changes.go
- controller_api_error.go
- controller_cert.go
- controller_reconcile.go
- controller_register.go
- deprovision_volumes.go
- exec_callback.go
- exec_session_manager.go
- exec_websocket.go
- log_session_manager.go
- log_websocket.go
- microservice_desired.go
- microservice_manager.go
- orchestrator.go
- ota_reprovision.go
- provision_body.go
- reconnect_reconcile.go
- state.go
- status_auth_gate.go
- status_exec.go
- store_adapter.go
- sync.go
- sync_knowledge.go
- sync_models.go
- sync_parse.go
- sync_runtimeclasses.go
- test_hooks.go
- workers.go
- ws_session.go