dpcmanager

package
v0.0.0-...-a2e9de6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 5, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const LastResortKey = "lastresort"

LastResortKey : key used for DPC used as a last-resort.

Variables

This section is empty.

Functions

This section is empty.

Types

type DpcManager

type DpcManager struct {
	Log       *base.LogObject
	Watchdog  Watchdog
	AgentName string

	// Keep nil values to let DpcManager to use default implementations.
	// It is useful to override for unit testing purposes.
	GeoService GeolocationService

	// Minimum time that should pass after a DPC verification failure
	// until the DPC is eligible for another round of verification.
	// By default it is 5 minutes.
	// It is useful to override for unit testing purposes.
	// XXX Should we make this a global config parameter?
	DpcMinTimeSinceFailure time.Duration

	// NIM components that the manager interacts with
	NetworkMonitor netmonitor.NetworkMonitor
	DpcReconciler  dpcreconciler.DpcReconciler
	ConnTester     conntester.ConnectivityTester

	// Publications
	PubDummyDevicePortConfig pubsub.Publication // for logging
	PubDevicePortConfigList  pubsub.Publication
	PubDeviceNetworkStatus   pubsub.Publication

	// Metrics
	ZedcloudMetrics *zedcloud.AgentMetrics
	// contains filtered or unexported fields
}

DpcManager manages a list of received device port configurations. Note that device port configuration (DevicePortConfig struct; abbreviated to DPC) represents configuration for all (physical) network interfaces to be used for device management or to be shared by applications (i.e. excluding NIC pass-through). The goal is to select and apply DPC with a working external connectivity, so that EVE is able to access the controller, and among the working DPCs prefer the one with the highest assigned priority (typically the last received). The manager uses ConnectivityTester to probe the connectivity status of the currently applied DPC. Based on the probing result, it may keep DPC unchanged or it may fallback to a lower-priority but working configuration. Whenever there is a higher-priority DPC available, the manager will test it periodically and switch to it as soon as the probing succeeds. DPC is applied into the device state using DpcReconciler (see pillar/dpcreconciler). The reconciler is able to switch from one DPC to another. Lastly, NetworkMonitor is used to monitor network stack for interesting events, such as link state changes, and to collect state information. Manager publishes device network status (DeviceNetworkStatus struct; abbreviated to DNS), updated on every state change, including a switch to another DPC. DpcManager is a generic state machine, not tied to any particular network stack. Instead, the injected components NetworkMonitor, DpcReconciler and ConnTester make all the probing, monitoring and network configuration operations.

func (*DpcManager) AddDPC

func (m *DpcManager) AddDPC(dpc types.DevicePortConfig)

AddDPC : add a new DPC into the list of configurations to work with. It will be added into the list at a position determined by the TimePriority attribute. The higher the timestamp is, the higher the priority is.

func (*DpcManager) DelDPC

func (m *DpcManager) DelDPC(dpc types.DevicePortConfig)

DelDPC : remove DPC from the list of configurations to work with.

func (*DpcManager) GetDNS

func (m *DpcManager) GetDNS() types.DeviceNetworkStatus

GetDNS returns device network state information.

func (*DpcManager) Init

func (m *DpcManager) Init(ctx context.Context) error

Init DpcManager

func (*DpcManager) ProcessWwanStatus

func (m *DpcManager) ProcessWwanStatus(wwanStatus types.WwanStatus)

ProcessWwanStatus : process an update of cellular connectivity status.

func (*DpcManager) Run

func (m *DpcManager) Run(ctx context.Context) (err error)

Run DpcManager as a separate task with its own loop and a watchdog file.

func (*DpcManager) UpdateAA

func (m *DpcManager) UpdateAA(aa types.AssignableAdapters)

UpdateAA : apply an updated set of assignable adapters. This list contains low-level information about all the physical adapters, such as their names in the kernel, PCI addresses, etc.

func (*DpcManager) UpdateDevUUID

func (m *DpcManager) UpdateDevUUID(devUUID uuid.UUID)

UpdateDevUUID : apply an update of the UUID assigned to the device by the controller.

func (*DpcManager) UpdateGCP

func (m *DpcManager) UpdateGCP(gcp types.ConfigItemValueMap)

UpdateGCP : apply an updated set of global configuration properties. These properties decides for example how often to probe connectivity status, whether to allow SSH access, etc.

func (*DpcManager) UpdateRadioSilence

func (m *DpcManager) UpdateRadioSilence(rs types.RadioSilence)

UpdateRadioSilence : apply an update radio silence configuration. When radio silence is set to ON, all wireless ports should be configured with radio transmission disabled.

type GeolocationService

type GeolocationService interface {
	// GetGeolocationInfo tries to obtain geolocation information
	// corresponding to the given IP address.
	GetGeolocationInfo(ipAddr net.IP) (*ipinfo.IPInfo, error)
}

GeolocationService allows to obtain geolocation information based on assigned IP address.

type Watchdog

type Watchdog interface {
	// RegisterFileWatchdog tells the watchdog about the touch file.
	RegisterFileWatchdog(agentName string)
	// StillRunning touches a file per agentName to signal the event loop is still running
	// Those files are observed by the watchdog
	StillRunning(agentName string, warnTime, errTime time.Duration)
	// CheckMaxTimeTopic verifies if the time for a call has exceeded a reasonable number.
	CheckMaxTimeTopic(agentName, topic string, start time.Time,
		warnTime, errTime time.Duration)
}

Watchdog : methods used by DpcManager to interact with Watchdog.

type WwanEvent

type WwanEvent uint8

WwanEvent is sent by WwanWatcher whenever there is new output coming from wwan microservice.

const (
	// WwanEventUndefined : undefined event, will be ignored.
	WwanEventUndefined WwanEvent = iota
	// WwanEventNewStatus : new wwan status data are available,
	// reload with WwanWatcher.LoadStatus()
	WwanEventNewStatus
	// WwanEventNewMetrics : new wwan metrics are available,
	// reload with WwanWatcher.LoadMetrics()
	WwanEventNewMetrics
	// WwanEventNewLocationInfo : new location info published by wwan microservice,
	// reload with WwanWatcher.LoadLocationInfo()
	WwanEventNewLocationInfo
)

type WwanWatcher

type WwanWatcher interface {
	Watch(ctx context.Context) (<-chan WwanEvent, error)
	LoadStatus() (types.WwanStatus, error)
	LoadMetrics() (types.WwanMetrics, error)
	LoadLocationInfo() (types.WwanLocationInfo, error)
}

WwanWatcher allows to watch for output coming from wwan microservice. wwan microservice is a shell script and uses files for input/output instead of pubsub.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL