daemon

package
v0.0.0-...-df8a651 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	PtpNamespace         = "openshift-ptp"
	PTP4L_CONF_FILE_PATH = "/etc/ptp4l.conf"
	PTP4L_CONF_DIR       = "/ptp4l-conf"

	ClockClassChangeIndicator       = "selected best master clock"
	GPSDDefaultGNSSSerialPort       = "/dev/gnss0"
	NMEASourceDisabledIndicator     = "nmea source timed out"
	NMEASourceDisabledIndicator2    = "source ts not valid"
	InvalidMasterTimestampIndicator = "ignoring invalid master time stamp"
	PTP_HA_IDENTIFIER               = "haProfiles"
	HAInDomainIndicator             = "as domain source clock"
	HAOutOfDomainIndicator          = "as out-of-domain source"
	MessageTagSuffixSeperator       = ":"
)
View Source
const (
	GPSD_PROCESSNAME     = "gpsd"
	GNSSMONITOR_INTERVAL = 1 * time.Second
)
View Source
const (
	// GPSPIPE_PROCESSNAME ... gpspipe process name
	GPSPIPE_PROCESSNAME = "gpspipe"
	// GPSPIPE_SERIALPORT ... gpspipe serial port
	GPSPIPE_SERIALPORT = "/gpsd/data"
	// GPSD_DIR ... gpsd directory
	GPSD_DIR = "/gpsd"
)
View Source
const (
	PTPNamespace = "openshift"
	PTPSubsystem = "ptp"
	GNSS         = "gnss"
	DPLL         = "dpll"
)
View Source
const (
	//LOCKED ...
	LOCKED string = "LOCKED"
	//FREERUN ...
	FREERUN = "FREERUN"
)
View Source
const (
	PtpProcessDown int64 = 0
	PtpProcessUp   int64 = 1
)
View Source
const (
	PASSIVE ptpPortRole = iota
	SLAVE
	MASTER
	FAULTY
	UNKNOWN
)

Variables

View Source
var (
	NodeName = ""

	Offset = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: PTPNamespace,
			Subsystem: PTPSubsystem,
			Name:      "offset_ns",
			Help:      "",
		}, []string{"from", "process", "node", "iface"})

	MaxOffset = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: PTPNamespace,
			Subsystem: PTPSubsystem,
			Name:      "max_offset_ns",
			Help:      "",
		}, []string{"from", "process", "node", "iface"})

	FrequencyAdjustment = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: PTPNamespace,
			Subsystem: PTPSubsystem,
			Name:      "frequency_adjustment_ns",
			Help:      "",
		}, []string{"from", "process", "node", "iface"})

	Delay = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: PTPNamespace,
			Subsystem: PTPSubsystem,
			Name:      "delay_ns",
			Help:      "",
		}, []string{"from", "process", "node", "iface"})

	// ClockState metrics to show current clock state
	ClockState = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: PTPNamespace,
			Subsystem: PTPSubsystem,
			Name:      "clock_state",
			Help:      "0 = FREERUN, 1 = LOCKED, 2 = HOLDOVER",
		}, []string{"process", "node", "iface"})

	// ClockClassMetrics metrics to show current clock class
	ClockClassMetrics = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: PTPNamespace,
			Subsystem: PTPSubsystem,
			Name:      "clock_class",
			Help:      "6 = Locked, 7 = PRC unlocked in-spec, 52/187 = PRC unlocked out-of-spec, 135 = T-BC holdover in-spec, 165 = T-BC holdover out-of-spec, 248 = Default, 255 = Slave Only Clock",
		}, []string{"process", "node"})

	// InterfaceRole metrics to show current interface role
	InterfaceRole = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: PTPNamespace,
			Subsystem: PTPSubsystem,
			Name:      "interface_role",
			Help:      "0 = PASSIVE, 1 = SLAVE, 2 = MASTER, 3 = FAULTY, 4 = UNKNOWN",
		}, []string{"process", "node", "iface"})

	ProcessStatus = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: PTPNamespace,
			Subsystem: PTPSubsystem,
			Name:      "process_status",
			Help:      "0 = DOWN, 1 = UP",
		}, []string{"process", "node", "config"})

	ProcessRestartCount = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: PTPNamespace,
			Subsystem: PTPSubsystem,
			Name:      "process_restart_count",
			Help:      "",
		}, []string{"process", "node", "config"})

	// PTPHAMetrics metrics to show current ha profiles
	PTPHAMetrics = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: PTPNamespace,
			Subsystem: PTPSubsystem,
			Name:      "ha_profile_status",
			Help:      "0 = INACTIVE 1 = ACTIVE",
		}, []string{"process", "node", "profile"})
)

Functions

func GetDevStatusUpdate

func GetDevStatusUpdate(nodePTPDev *ptpv1.NodePtpDevice) (*ptpv1.NodePtpDevice, error)

func HelloWorld

func HelloWorld()

func InitializeOffsetMaps

func InitializeOffsetMaps()

InitializeOffsetMaps ... initialize maps

func RegisterMetrics

func RegisterMetrics(nodeName string)

func RunDeviceStatusUpdate

func RunDeviceStatusUpdate(ptpClient *ptpclient.Clientset, nodeName string, hwconfigs *[]ptpv1.HwConfig)

func StartMetricsServer

func StartMetricsServer(bindAddress string)

StartMetricsServer runs the prometheus listner so that metrics can be collected

func UpdateClockClassMetrics

func UpdateClockClassMetrics(clockClass float64)

UpdateClockClassMetrics ... update clock class metrics

func UpdateInterfaceRoleMetrics

func UpdateInterfaceRoleMetrics(process string, iface string, role ptpPortRole)

func UpdatePTPHAMetrics

func UpdatePTPHAMetrics(profile string, inActiveProfiles []string, state int64)

UpdatePTPHAMetrics ... update ptp ha metrics

func UpdateProcessStatusMetrics

func UpdateProcessStatusMetrics(process, cfgName string, status int64)

Types

type Daemon

type Daemon struct {
	// contains filtered or unexported fields
}

Daemon is the main structure for linuxptp instance. It contains all the necessary data to run linuxptp instance.

func New

func New(
	nodeName string,
	namespace string,
	stdoutToSocket bool,
	kubeClient *kubernetes.Clientset,
	ptpUpdate *LinuxPTPConfUpdate,
	stopCh <-chan struct{},
	plugins []string,
	hwconfigs *[]ptpv1.HwConfig,
	refreshNodePtpDevice *bool,
	closeManager chan bool,
	pmcPollInterval int,
) *Daemon

New LinuxPTP is called by daemon to generate new linuxptp instance

func (*Daemon) ApplyHaProfiles

func (dn *Daemon) ApplyHaProfiles(nodeProfile *ptpv1.PtpProfile, cmdLine string) (map[string][]string, string)

func (*Daemon) GetPhaseOffsetPinFilter

func (dn *Daemon) GetPhaseOffsetPinFilter(nodeProfile *ptpv1.PtpProfile) map[string]map[string]string

func (*Daemon) HandlePmcTicker

func (dn *Daemon) HandlePmcTicker()

HandlePmcTicker ....

func (*Daemon) Run

func (dn *Daemon) Run()

Run in a for loop to listen for any LinuxPTPConfUpdate changes

func (*Daemon) SetProcessManager

func (dn *Daemon) SetProcessManager(p *ProcessManager)

SetProcessManager ...

type GPSD

type GPSD struct {
	// contains filtered or unexported fields
}

func (*GPSD) CmdInit

func (g *GPSD) CmdInit()

CmdInit ... initialize GPSD

func (*GPSD) CmdRun

func (g *GPSD) CmdRun(stdoutToSocket bool)

CmdRun ... run GPSD

func (*GPSD) CmdStop

func (g *GPSD) CmdStop()

CmdStop .... stop

func (*GPSD) ExitCh

func (g *GPSD) ExitCh() chan struct{}

ExitCh ... exit channel

func (*GPSD) MonitorGNSSEventsWithUblox

func (g *GPSD) MonitorGNSSEventsWithUblox()

MonitorGNSSEventsWithUblox ... monitor GNSS events with ublox

func (*GPSD) MonitorProcess

func (g *GPSD) MonitorProcess(p config.ProcessConfig)

MonitorProcess ... Monitor GPSD process

func (*GPSD) Name

func (g *GPSD) Name() string

Name ... Process name

func (*GPSD) SerialPort

func (g *GPSD) SerialPort() string

SerialPort ... get SerialPort

func (*GPSD) Stopped

func (g *GPSD) Stopped() bool

Stopped ...

type GPSDSubscriber

type GPSDSubscriber struct {
	// contains filtered or unexported fields
}

GPSDSubscriber ... event subscriber

func (GPSDSubscriber) ID

func (s GPSDSubscriber) ID() string

func (GPSDSubscriber) Monitor

func (s GPSDSubscriber) Monitor()

Monitor ...

func (GPSDSubscriber) Notify

func (s GPSDSubscriber) Notify(source event.EventSource, state event.PTPState)

Notify ... event notification

func (GPSDSubscriber) Topic

func (s GPSDSubscriber) Topic() event.EventSource

Topic ... event topic

type LinuxPTPConfUpdate

type LinuxPTPConfUpdate struct {
	UpdateCh     chan bool
	NodeProfiles []ptpv1.PtpProfile
	// contains filtered or unexported fields
}

LinuxPTPUpdate controls whether to update linuxPTP conf and contains linuxPTP conf to be updated. It's rendered and passed to linuxptp instance by daemon.

func NewLinuxPTPConfUpdate

func NewLinuxPTPConfUpdate() (*LinuxPTPConfUpdate, error)

func (*LinuxPTPConfUpdate) UpdateConfig

func (l *LinuxPTPConfUpdate) UpdateConfig(nodeProfilesJson []byte) error

type PluginManager

type PluginManager struct {
	// contains filtered or unexported fields
}

func (*PluginManager) AfterRunPTPCommand

func (pm *PluginManager) AfterRunPTPCommand(nodeProfile *ptpv1.PtpProfile, command string)

func (*PluginManager) OnPTPConfigChange

func (pm *PluginManager) OnPTPConfigChange(nodeProfile *ptpv1.PtpProfile)

func (*PluginManager) PopulateHwConfig

func (pm *PluginManager) PopulateHwConfig(hwconfigs *[]ptpv1.HwConfig)

type ProcessManager

type ProcessManager struct {
	// contains filtered or unexported fields
}

ProcessManager manages a set of ptpProcess which could be ptp4l, phc2sys or timemaster. Processes in ProcessManager will be started or stopped simultaneously.

func NewProcessManager

func NewProcessManager() *ProcessManager

NewProcessManager is used by unit tests

func (*ProcessManager) RunProcessPTPMetrics

func (p *ProcessManager) RunProcessPTPMetrics(log string)

RunProcessPTPMetrics is used by unit tests

func (*ProcessManager) SetTestData

func (p *ProcessManager) SetTestData(name, msgTag string, ifaces config.IFaces)

SetTestData is used by unit tests

func (*ProcessManager) SetTestProfileProcess

func (p *ProcessManager) SetTestProfileProcess(name string, ifaces config.IFaces, socketPath,
	ptp4lConfigPath string, nodeProfile ptpv1.PtpProfile)

SetTestProfile ...

Jump to

Keyboard shortcuts

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