daemon

package
v0.0.0-...-a74e115 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2023 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

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

	ClockClassChangeIndicator = "selected best master clock"
)
View Source
const (
	PTPNamespace = "openshift"
	PTPSubsystem = "ptp"
)
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"})

	// Threshold metrics to show current ptp threshold
	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"})
)

Functions

func GetDevStatusUpdate

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

func HelloWorld

func HelloWorld()

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 UpdateInterfaceRoleMetrics

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

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,
	kubeClient *kubernetes.Clientset,
	ptpUpdate *LinuxPTPConfUpdate,
	stopCh <-chan struct{},
	plugins []string,
	hwconfigs *[]ptpv1.HwConfig,
) *Daemon

New LinuxPTP is called by daemon to generate new linuxptp instance

func (*Daemon) Run

func (dn *Daemon) Run()

Run in a for loop to listen for any LinuxPTPConfUpdate changes

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

Jump to

Keyboard shortcuts

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