daemon

package
v0.0.0-...-f59ac11 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2024 License: Apache-2.0 Imports: 38 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"
	// HOLDOVER
	HOLDOVER = "HOLDOVER"
)
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"})

	// SynceClockQL  metrics to show current synce Clock Qulity
	SynceClockQL = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: PTPNamespace,
			Subsystem: PTPSubsystem,
			Name:      "synce_clock_quality",
			Help:      "Help: network_option1: ePRTC = 32 PRTC = 34 PRC =257  SSU-A = 259 SSU-B = 263 EEC1 = 266 QL-DNU =270 network_option2: ePRTC = 34 PRTC = 33 PRS =256 STU = 255 ST2 = 262 TNC = 259 ST3E =268 EEC2 =265 PROV =269 QL-DUS =270",
		}, []string{"process", "node", "profile", "network_option", "iface", "device"})

	// SynceQLInfo metrics to show current QL values
	SynceQLInfo = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: PTPNamespace,
			Subsystem: PTPSubsystem,
			Name:      "synce_ssm_ql",
			Help: "network_option1: ePRTC: {0, 0x2, 0x21}, PRTC:  {1, 0x2, 0x20}, PRC:   {2, 0x2, 0xFF}, SSUA:  {3, 0x4, 0xFF}, SSUB:  {4, 0x8, 0xFF}, EEC1:  {5, 0xB, 0xFF},QL-DNU: {6,0xF,0xFF}\n " +
				"   network_option2 ePRTC: {0, 0x1, 0x21}, PRTC:  {1, 0x1, 0x20}, PRS:   {2, 0x1, 0xFF}, STU:   {3, 0x0, 0xFF}, ST2:   {4, 0x7, 0xFF}, TNC:   {5, 0x4, 0xFF}, ST3E:  {6, 0xD, 0xFF}, EEC2:  {7, 0xA, 0xFF}, PROV:  {8, 0xE, 0xFF}, QL-DUS: {9,0xF,0xFF}",
		}, []string{"process", "node", "profile", "network_option", "iface", "device", "ql_type"})
)

Functions

func GetDevStatusUpdate

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

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)

func UpdateSynceClockQlMetrics

func UpdateSynceClockQlMetrics(process, cfgName string, iface string, network_option int, device string, value int)

func UpdateSynceQLMetrics

func UpdateSynceQLMetrics(process, cfgName string, iface string, network_option int, device string, qlType string, value byte)

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) RunSynceParser

func (p *ProcessManager) RunSynceParser(log string)

RunSynceParser 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)

SetTestProfileProcess ...

func (*ProcessManager) UpdateSynceConfig

func (p *ProcessManager) UpdateSynceConfig(config *synce.Relations)

UpdateSynceConfig is used by unit tests

Jump to

Keyboard shortcuts

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