Documentation
¶
Index ¶
- Constants
- Variables
- func ArchitectureCode(value string) int
- func DefaultContainerEngineURLForEngine(engine string) string
- func DefaultShutdownPolicy(containerEngine string) string
- func DisplayArch(value string) string
- func FullReload(hooks ReloadHooks) error
- func InitConfig(configPath string) (created bool, err error)
- func IsLastReloadSuccessful() bool
- func IsReloadSuppressedForDeprovision() bool
- func IsReloadSuppressedForInProcessMutation() bool
- func LoadConfig(configPath string) error
- func ParseSecureMode(value string) bool
- func PatchKeysFromMap(configMap map[string]any) map[string]struct{}
- func ResolveArch(value string) string
- func RestoreReloadAfterDeprovision()
- func RestoreReloadAfterInProcessMutation()
- func RunInProcessConfigMutation(fn func() error) error
- func SaveConfig(configPath string) error
- func SaveConfigWithYaml(configPath string, yamlConfig *models.YamlConfig) error
- func SetLastReloadSuccessful(ok bool)
- func SnapshotYAML(path string) ([]byte, error)
- func SuppressReloadForDeprovision()
- func SuppressReloadForInProcessMutation()
- func ValidateArch(value string) error
- func ValidateConfig(cfg *Config) error
- func ValidateProperty(key, value string) error
- type ChangeClass
- type Config
- func (c *Config) ApplyEngineDefaults(engine string) error
- func (c *Config) ConsumeReloadPriorContainerEngineURL() (string, bool)
- func (c *Config) GetConfigPath() string
- func (c *Config) GetConfigReport() string
- func (c *Config) GetConfigReportWithIP(ipAddress string) string
- func (c *Config) GetCurrentProfile() utils.ConfigSwitcherState
- func (c *Config) GetProperty(key string) string
- func (c *Config) GetYamlConfig() *models.YamlConfig
- func (c *Config) LeaveRunningOnControlStop() bool
- func (c *Config) NotifyModulesOfConfigChange() error
- func (c *Config) RevertContainerEngineURL(containerEngineURL string) error
- func (c *Config) SetConfig(configMap map[string]any) map[string]string
- func (c *Config) SetConfigPath(path string)
- func (c *Config) SetCurrentProfile(profile utils.ConfigSwitcherState)
- func (c *Config) SetGPSConfigCallback(cb func() error)
- func (c *Config) SetProperty(key, value string) error
- func (c *Config) SetReloadCallback(cb func() error)
- func (c *Config) SetRouterInterior(v bool)
- func (c *Config) SetRouterUUID(uuid string)
- func (c *Config) SetYamlConfig(yc *models.YamlConfig)
- func (c *Config) ShutdownDrainTimeout() int
- func (c *Config) SnapshotForReload()
- func (c *Config) SwitchProfile(profile utils.ConfigSwitcherState) error
- func (c *Config) TriggerGPSConfigCallback() error
- func (c *Config) TriggerReloadCallback() error
- type ReloadHooks
- type Watcher
Constants ¶
const ( // ShutdownPolicyLeaveRunning skips runtime drain on control-plane stop; MS reattach on start. ShutdownPolicyLeaveRunning = "leave-running" // ShutdownPolicyDrainAll stops managed MS containers during shutdown (embedded monolith / data-plane stop). ShutdownPolicyDrainAll = "drain-all" )
Variables ¶
var ( ErrConfigNotLoaded = errors.New("configuration not loaded") ErrProfileNotFound = errors.New("profile not found") ErrInvalidConfig = errors.New("invalid configuration") ErrConfigFileNotFound = errors.New("config file not found") )
var AllowedArchValues = []string{"auto", "amd64", "arm64", "arm", "riscv64"}
AllowedArchValues are valid config arch settings (FogType source).
var ConfigParamMap = map[string]string{
"d": "diskLimit",
"dl": "diskDirectory",
"m": "memoryLimit",
"p": "cpuLimit",
"a": "controllerURL",
"ac": "controllerCert",
"cu": "containerEngineURL",
"ce": "containerEngine",
"n": "networkInterface",
"l": "logDiskLimit",
"ld": "logDiskDirectory",
"lc": "logFileCount",
"ll": "logLevel",
"sf": "statusFrequency",
"cf": "changeFrequency",
"sd": "deviceScanFrequency",
"wd": "watchdogEnabled",
"egf": "edgeGuardFrequency",
"gps": "gpsMode",
"gpsc": "gpsCoordinates",
"gpsd": "gpsDevice",
"gpsf": "gpsScanFrequency",
"ft": "arch",
"sec": "secureMode",
"pf": "pruningFrequency",
"dt": "availableDiskThreshold",
"uf": "upgradeScanFrequency",
"dev": "devMode",
"tz": "timeZone",
}
ConfigParamMap maps command line parameter names to config fields
Functions ¶
func ArchitectureCode ¶
ArchitectureCode maps arch config to Pot provision FogType (1=amd64, 2=arm64, 3=riscv64, 4=arm).
func DefaultContainerEngineURLForEngine ¶
DefaultContainerEngineURLForEngine returns the platform default socket URL for an engine family.
func DefaultShutdownPolicy ¶
DefaultShutdownPolicy returns the engine-appropriate default when shutdownPolicy is unset.
func DisplayArch ¶
DisplayArch returns the architecture name shown in status/info (never "auto").
func FullReload ¶
func FullReload(hooks ReloadHooks) error
FullReload reads config from disk, validates it, updates the logger, and notifies modules.
func InitConfig ¶
InitConfig writes the default config template when the target path is missing. If the file already exists, it is left unchanged and created is false.
func IsLastReloadSuccessful ¶
func IsLastReloadSuccessful() bool
IsLastReloadSuccessful indicates if the most recent config reload succeeded.
func IsReloadSuppressedForDeprovision ¶
func IsReloadSuppressedForDeprovision() bool
IsReloadSuppressedForDeprovision returns whether SIGHUP should be skipped.
func IsReloadSuppressedForInProcessMutation ¶
func IsReloadSuppressedForInProcessMutation() bool
IsReloadSuppressedForInProcessMutation returns whether watcher SIGHUP should be skipped.
func LoadConfig ¶
LoadConfig loads configuration from YAML file
func ParseSecureMode ¶
ParseSecureMode interprets secureMode config values. Only explicit off/false synonyms disable TLS verification; everything else enables secure mode.
func PatchKeysFromMap ¶
PatchKeysFromMap converts a SetConfig map to short-code keys for classification.
func ResolveArch ¶
ResolveArch maps config arch to a concrete architecture name (auto → runtime GOARCH).
func RestoreReloadAfterDeprovision ¶
func RestoreReloadAfterDeprovision()
RestoreReloadAfterDeprovision clears the suppression flag.
func RestoreReloadAfterInProcessMutation ¶
func RestoreReloadAfterInProcessMutation()
RestoreReloadAfterInProcessMutation clears in-process reload suppression.
func RunInProcessConfigMutation ¶
RunInProcessConfigMutation suppresses file-watcher SIGHUP for fn (config save + reload).
func SaveConfig ¶
SaveConfig saves the configuration to YAML file
func SaveConfigWithYaml ¶
func SaveConfigWithYaml(configPath string, yamlConfig *models.YamlConfig) error
SaveConfigWithYaml saves the provided YAML config to file (avoids lock acquisition)
func SetLastReloadSuccessful ¶
func SetLastReloadSuccessful(ok bool)
SetLastReloadSuccessful updates the last reload result.
func SnapshotYAML ¶
SnapshotYAML returns a copy of the on-disk YAML bytes for revert on failed warm reload.
func SuppressReloadForDeprovision ¶
func SuppressReloadForDeprovision()
SuppressReloadForDeprovision sets a flag so the config watcher skips SIGHUP when the config file is written during deprovision. Prevents CLI timeout.
func SuppressReloadForInProcessMutation ¶
func SuppressReloadForInProcessMutation()
SuppressReloadForInProcessMutation sets a flag so the config watcher skips SIGHUP while the daemon writes config and applies TriggerReloadCallback in-process (API PATCH).
func ValidateArch ¶
ValidateArch reports whether value is an allowed arch config setting.
func ValidateConfig ¶
ValidateConfig validates the configuration
func ValidateProperty ¶
ValidateProperty validates a single property value
Types ¶
type ChangeClass ¶
type ChangeClass int
ChangeClass describes how a config mutation affects the daemon.
const ( ChangeClassHot ChangeClass = iota ChangeClassWarm ChangeClassCold )
func ClassifyEngineConfigChange ¶
func ClassifyEngineConfigChange(startupEngine, newEngine, startupURL, newURL string, _ map[string]struct{}) ChangeClass
ClassifyEngineConfigChange compares startup vs reloaded config.
type Config ¶
type Config struct {
// Directly configurable params
IOFogUUID string
PrivateKey string
ControllerURL string
ContainerEngine string
ControllerCert string
NetworkInterface string
ContainerEngineURL string
DiskLimit float64
MemoryLimit float64
DiskDirectory string
CPULimit float64
LogDiskLimit float64
LogDiskDirectory string
LogFileCount int
LogLevel string
StatusFrequency int
ChangeFrequency int
DeviceScanFrequency int
WatchdogEnabled bool
EdgeGuardFrequency int64
GPSDevice string
GPSScanFrequency int64
GPSCoordinates string
GPSMode string
Arch string
SecureMode bool
IPAddressExternal string
RouterUUID string
IsRouterInterior bool
PruningFrequency int64
AvailableDiskThreshold int64
UpgradeScanFrequency int
DevMode bool
TimeZone string
Namespace string
ShutdownGracePeriodSeconds int
ShutdownPolicy string
ControllerRequestTimeoutSeconds int
ControllerPingTimeoutSeconds int
// Automatic configurable params (calculated)
StatusReportFreqSeconds int
PingControllerFreqSeconds int
MonitorContainersStatusFreqSeconds int
// LogReconcileCycleEveryNTicks emits reconcile.cycle at Info when idle (no scheduling) every N monitor ticks.
LogReconcileCycleEveryNTicks int
MonitorRegistriesStatusFreqSeconds int
HealthcheckIntervalSeconds int // Interval for exec-based healthcheck (iofog engine only)
GetUsageDataFreqSeconds int64
DockerAPIVersion string
SetSystemTimeFreqSeconds int
MonitorSSHTunnelStatusFreqSeconds int
// Debugging flag
Debugging bool
// contains filtered or unexported fields
}
Config represents the runtime configuration
func (*Config) ApplyEngineDefaults ¶
ApplyEngineDefaults updates containerEngineUrl when containerEngine changes in-memory and YAML.
func (*Config) ConsumeReloadPriorContainerEngineURL ¶
ConsumeReloadPriorContainerEngineURL returns and clears a reload snapshot if present.
func (*Config) GetConfigPath ¶
GetConfigPath returns the config file path (thread-safe)
func (*Config) GetConfigReport ¶
GetConfigReport returns a formatted config report string (for info endpoint) Uses IPAddressExternal from config
func (*Config) GetConfigReportWithIP ¶
GetConfigReportWithIP returns a formatted config report string with provided IP address
func (*Config) GetCurrentProfile ¶
func (c *Config) GetCurrentProfile() utils.ConfigSwitcherState
GetCurrentProfile returns the current profile (thread-safe)
func (*Config) GetProperty ¶
GetProperty gets a property from the current profile
func (*Config) GetYamlConfig ¶
func (c *Config) GetYamlConfig() *models.YamlConfig
GetYamlConfig returns the YAML config (thread-safe)
func (*Config) LeaveRunningOnControlStop ¶
LeaveRunningOnControlStop reports whether control-plane stop should skip runtime drain.
func (*Config) NotifyModulesOfConfigChange ¶
NotifyModulesOfConfigChange notifies modules when configuration changes This should be called after SetConfig to update modules like FieldAgent
func (*Config) RevertContainerEngineURL ¶
RevertContainerEngineURL restores containerEngineUrl in memory and YAML after a failed warm reload.
func (*Config) SetConfig ¶
SetConfig sets configuration values from a map of command line parameters Returns a map of errors keyed by parameter name
func (*Config) SetConfigPath ¶
SetConfigPath sets the config file path (thread-safe)
func (*Config) SetCurrentProfile ¶
func (c *Config) SetCurrentProfile(profile utils.ConfigSwitcherState)
SetCurrentProfile sets the current profile (thread-safe)
func (*Config) SetGPSConfigCallback ¶
SetGPSConfigCallback sets the callback for GPS configuration updates.
func (*Config) SetProperty ¶
SetProperty sets a property in the current profile
func (*Config) SetReloadCallback ¶
SetReloadCallback sets the callback for configuration reload
func (*Config) SetRouterInterior ¶
func (*Config) SetRouterUUID ¶
func (*Config) SetYamlConfig ¶
func (c *Config) SetYamlConfig(yc *models.YamlConfig)
SetYamlConfig sets the YAML config (thread-safe)
func (*Config) ShutdownDrainTimeout ¶
ShutdownDrainTimeout returns the configured runtime drain deadline for maintenance/data-plane stops.
func (*Config) SnapshotForReload ¶
func (c *Config) SnapshotForReload()
SnapshotForReload records containerEngineUrl before an in-process config mutation (API PATCH).
func (*Config) SwitchProfile ¶
func (c *Config) SwitchProfile(profile utils.ConfigSwitcherState) error
SwitchProfile sets active configuration profile and persists currentProfile.
func (*Config) TriggerGPSConfigCallback ¶
TriggerGPSConfigCallback triggers the GPS configuration update callback.
func (*Config) TriggerReloadCallback ¶
TriggerReloadCallback triggers the configuration reload callback
type ReloadHooks ¶
ReloadHooks supplies supervisor-specific steps for a full config reload.