Documentation
¶
Index ¶
- Constants
- Variables
- func IsConfigMalformed(err error) bool
- func IsConfigNotFound(err error) bool
- func WriteDaemonConfig(path string, cfg DaemonConfig) error
- type BlockNodeComponentConfig
- type BlockNodeMonitors
- type ComponentStatus
- type ConsensusNodeComponentConfig
- type ConsensusNodeMonitors
- type Daemon
- type DaemonComponents
- type DaemonConfig
- type ErrorResponse
- type HealthResponse
- type StatusResponse
Constants ¶
const ( DefaultDaemonConfigPath = "/opt/solo/weaver/config/daemon.yaml" // CurrentSchemaVersion is the schema version written by this build. // Increment this constant whenever a breaking structural change is made to // DaemonConfig so that LoadDaemonConfig can detect and migrate old files. CurrentSchemaVersion = 1 )
Variables ¶
var ( ErrNamespace = errorx.NewNamespace("daemon") // ErrConfig is the base type for daemon configuration errors. ErrConfig = ErrNamespace.NewType("config") // ErrConfigNotFound is returned when daemon.yaml does not exist at the expected path. ErrConfigNotFound = ErrConfig.NewSubtype("not_found", errorx.NotFound()) // ErrConfigMalformed is returned when daemon.yaml exists but cannot be parsed or has missing required fields. ErrConfigMalformed = ErrConfig.NewSubtype("malformed") )
Functions ¶
func IsConfigMalformed ¶
IsConfigMalformed reports whether err is (or wraps) an ErrConfigMalformed error.
func IsConfigNotFound ¶
IsConfigNotFound reports whether err is (or wraps) an ErrConfigNotFound error.
func WriteDaemonConfig ¶
func WriteDaemonConfig(path string, cfg DaemonConfig) error
WriteDaemonConfig serialises cfg to YAML and writes it to path, creating any missing parent directories. It stamps SchemaVersion = CurrentSchemaVersion before writing. Callers should call cfg.Validate() before writing.
Types ¶
type BlockNodeComponentConfig ¶
type BlockNodeComponentConfig struct {
// Enabled controls whether this component and its monitors are started.
Enabled bool `yaml:"enabled"`
// Kubeconfig is the path to the scoped kubeconfig for this component's SA.
// Written by solo-provisioner during daemon install.
Kubeconfig string `yaml:"kubeconfig"`
// Orbit is the Kubernetes namespace where block-node CRs are watched.
Orbit string `yaml:"orbit"`
Monitors BlockNodeMonitors `yaml:"monitors"`
}
BlockNodeComponentConfig is the configuration block for the block-node component. It carries its own kubeconfig so its RBAC is independent of the consensus-node.
func (BlockNodeComponentConfig) Validate ¶
func (bn BlockNodeComponentConfig) Validate() error
Validate checks that all required fields within the block-node block are present. Kubeconfig and Orbit are optional while the traffic-shaper monitor is stubbed (it polls a remote API and does not watch K8s resources).
type BlockNodeMonitors ¶
type BlockNodeMonitors struct {
TrafficShaper bool `yaml:"traffic_shaper"`
}
BlockNodeMonitors toggles individual monitors for the block-node component.
type ComponentStatus ¶
type ComponentStatus struct {
Monitors map[string]daemonkit.MonitorState `json:"monitors"`
}
ComponentStatus holds the per-monitor states for one component.
type ConsensusNodeComponentConfig ¶
type ConsensusNodeComponentConfig struct {
// Enabled controls whether this component and its monitors are started.
Enabled bool `yaml:"enabled"`
// Kubeconfig is the path to the scoped kubeconfig for this component's SA.
// Written by solo-provisioner during daemon install (WriteConsensusNodeKubeconfigStep).
Kubeconfig string `yaml:"kubeconfig"`
// NodeID is the numeric node identifier (e.g. "0", "1", "2"). Used as nodeId in
// all JSONL event log entries.
NodeID string `yaml:"node_id"`
// Orbit is the Kubernetes namespace where NetworkUpgradeExecute CRs are watched.
Orbit string `yaml:"orbit"`
// UpgradeDir is the path to the CN's upgrade staging directory.
// Defaults to /opt/hgcapp/services-hedera/HapiApp2.0/data/upgrade/current.
UpgradeDir string `yaml:"upgrade_dir,omitempty"`
Monitors ConsensusNodeMonitors `yaml:"monitors"`
}
ConsensusNodeComponentConfig is the configuration block for the consensus-node component. It carries its own kubeconfig so its RBAC is independent of any future block-node or host-only component.
func (ConsensusNodeComponentConfig) EffectiveUpgradeDir ¶
func (cn ConsensusNodeComponentConfig) EffectiveUpgradeDir() string
EffectiveUpgradeDir returns UpgradeDir if set, otherwise the CN default path.
func (ConsensusNodeComponentConfig) Validate ¶
func (cn ConsensusNodeComponentConfig) Validate() error
Validate checks that all required fields within the consensus-node block are present.
type ConsensusNodeMonitors ¶
type ConsensusNodeMonitors struct {
Upgrade bool `yaml:"upgrade"`
Migration bool `yaml:"migration"`
}
ConsensusNodeMonitors toggles individual monitors for the consensus-node component.
type Daemon ¶
type Daemon struct {
// contains filtered or unexported fields
}
Daemon is the controller for solo-provisioner-daemon. It composes the sub-systems and owns their lifecycle via Run.
Goroutine map:
- Socket server — always on; HTTP control plane on daemon.sock
- componentSupervisor — one supervised goroutine per enabled monitor; crashes are absorbed per-monitor with exponential back-off (#662/#663)
- runComponentProbes — background loop; retries disk probes until all prerequisites are satisfied; results visible via GET /status
func New ¶
func New(paths models.WeaverPaths) (*Daemon, error)
New constructs a Daemon from WeaverPaths. It reads daemon.yaml from paths.DaemonConfigPath and fails fast if the config is missing or invalid.
func NewFromConfig ¶
func NewFromConfig(paths models.WeaverPaths, cfg DaemonConfig) (*Daemon, error)
NewFromConfig constructs a Daemon from a pre-resolved DaemonConfig. Components are skipped when their Enabled flag is false. Individual monitors within a component are skipped when their toggle is false.
type DaemonComponents ¶
type DaemonComponents struct {
ConsensusNode *ConsensusNodeComponentConfig `yaml:"consensus_node,omitempty"`
BlockNode *BlockNodeComponentConfig `yaml:"block_node,omitempty"`
}
DaemonComponents holds the per-component configuration blocks.
type DaemonConfig ¶
type DaemonConfig struct {
// SchemaVersion identifies the config file format. Always written as
// CurrentSchemaVersion by WriteDaemonConfig. A value of 0 means the file
// predates schema versioning and is treated as version 1 for compatibility.
SchemaVersion int `yaml:"schemaVersion"`
Components DaemonComponents `yaml:"components"`
}
DaemonConfig is parsed from daemon.yaml at startup.
Example daemon.yaml:
schemaVersion: 1
components:
consensus_node:
enabled: true
kubeconfig: /opt/solo/weaver/config/daemon-cn.kubeconfig
node_id: 0
orbit: hedera-network
upgrade_dir: /opt/hgcapp/services-hedera/HapiApp2.0/data/upgrade/current
monitors:
upgrade: true
migration: true
block_node:
enabled: true
kubeconfig: /opt/solo/weaver/config/daemon-bn.kubeconfig
orbit: hedera-block-node
monitors:
upgrade: true
func LoadDaemonConfig ¶
func LoadDaemonConfig(path string) (DaemonConfig, error)
LoadDaemonConfig reads and parses the daemon config file at path. Returns an error if the file is missing or malformed — the daemon must not start without a valid config. CLI flag overrides are applied after this call in cmd/daemon/main.go; call Validate() again after overrides are applied.
Loading uses a two-phase approach:
- Probe: unmarshal only schemaVersion to determine the on-disk format.
- Parse + migrate: unmarshal into the versioned struct for that version, then walk the migration chain (vN.migrateToLatest()) to produce the current DaemonConfig. Each step in the chain is a pure field transform that knows only about one version transition.
Version rules:
- 0 (absent): pre-versioning file; treated as version 1.
- 1..CurrentSchemaVersion: accepted; migrated to current if needed.
- > CurrentSchemaVersion: rejected — written by a newer binary.
func (DaemonConfig) Validate ¶
func (c DaemonConfig) Validate() error
Validate checks that the config is structurally valid. Called by LoadDaemonConfig and by cmd/daemon/main.go after applying CLI flag overrides. At least one component (consensus_node or block_node) must be present.
type ErrorResponse ¶
type ErrorResponse struct {
Error string `json:"error"`
}
ErrorResponse is the standard JSON error envelope returned on 4xx/5xx.
type HealthResponse ¶
type HealthResponse struct {
Status string `json:"status"`
}
HealthResponse is returned by GET /health.
type StatusResponse ¶
type StatusResponse struct {
Components map[string]ComponentStatus `json:"components"`
// ProbeErrors maps component name → rich error descriptor for any component
// whose disk prerequisites are not yet satisfied. Empty when all probes pass.
// Each entry includes a Reason code, the error Message, an operator-actionable
// Resolution hint, and the Since timestamp of when the failure was first seen.
ProbeErrors map[string]daemonkit.StatusError `json:"probe_errors,omitempty"`
}
StatusResponse is returned by GET /status. It reports the runtime state of every enabled component and their individual monitors, plus any unmet startup prerequisites detected by the background probe loop.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package probes holds the Kubernetes-specific leaf probe(s) that cannot live in the lightweight pkg/daemonkit because they pull in k8s.io/client-go.
|
Package probes holds the Kubernetes-specific leaf probe(s) that cannot live in the lightweight pkg/daemonkit because they pull in k8s.io/client-go. |