Skip to content

Commit df5a320

Browse files
committed
Add ptpconfig status condition
Signed-off-by: Aneesh Puttur <[email protected]>
1 parent 4fc7e9f commit df5a320

File tree

10 files changed

+419
-2
lines changed

10 files changed

+419
-2
lines changed

README.md

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- [PTP Operator](#ptp-operator)
55
- [PtpOperatorConfig](#ptpoperatorconfig)
66
- [PtpConfig](#ptpconfig)
7+
- [PtpConfig Status](#ptpconfig-status)
78
- [Quick Start](#quick-start)
89

910
## PTP Operator
@@ -314,6 +315,146 @@ Two ptp4l configurations must exist with the phc2sysOPts field set to an empty s
314315
The names of these ptp4l configurations will be used and listed under the ptpSettings/haProfiles key in the phc2sys-only enabled ptpConfig.
315316

316317

318+
## PtpConfig Status
319+
PtpConfig includes a status subresource with `ptpStatus.conditions[]` that operands (linuxptp-daemon, cloud-event-proxy) can update. Each condition includes `type`, `profile` (logical profile), `filename` (active config file), `status`, `reason`, `message`, and `lastUpdateTime`.
320+
321+
Example populated status (GM):
322+
```yaml
323+
status:
324+
matchList:
325+
- nodeName: worker-0
326+
profile: GM-Profile-A
327+
ptpStatus:
328+
conditions:
329+
- type: PTP4lRunning
330+
profile: GM-Profile-A
331+
filename: ptp4l.0.config
332+
status: "True"
333+
reason: Started
334+
message: "ptp4l is running (pid 3124)"
335+
lastUpdateTime: "2025-06-27T10:13:10Z"
336+
- type: LockState
337+
profile: GM-Profile-A
338+
filename: ptp4l.0.config
339+
status: "True"
340+
reason: LOCKED
341+
message: "clock state is LOCKED"
342+
lastUpdateTime: "2025-06-27T10:15:00Z"
343+
- type: ClockClass
344+
profile: GM-Profile-A
345+
filename: ptp4l.0.config
346+
status: "True"
347+
reason: Class6
348+
message: "clock class is 6"
349+
lastUpdateTime: "2025-06-27T10:15:00Z"
350+
- type: PortState
351+
profile: GM-Profile-A
352+
filename: ptp4l.0.config
353+
status: "True"
354+
reason: MASTER
355+
message: "interface ens5f0 state MASTER"
356+
lastUpdateTime: "2025-06-27T10:13:50Z"
357+
- type: ClockType
358+
profile: GM-Profile-A
359+
filename: ptp4l.0.config
360+
status: "True"
361+
reason: T-GM
362+
message: "profile reports T-GM Clock"
363+
lastUpdateTime: "2025-06-27T10:13:00Z"
364+
365+
Example populated status (OC):
366+
```yaml
367+
status:
368+
ptpStatus:
369+
conditions:
370+
- type: PTP4lRunning
371+
profile: OC-Profile-A
372+
filename: ptp4l.0.config
373+
status: "True"
374+
reason: Started
375+
message: "ptp4l is running"
376+
lastUpdateTime: "2025-06-27T11:05:00Z"
377+
- type: LockState
378+
profile: OC-Profile-A
379+
filename: ptp4l.0.config
380+
status: "True"
381+
reason: LOCKED
382+
message: "OC locked to GM"
383+
lastUpdateTime: "2025-06-27T11:06:10Z"
384+
- type: ClockClass
385+
profile: OC-Profile-A
386+
filename: ptp4l.0.config
387+
status: "True"
388+
reason: Class6
389+
message: "clock class is 6"
390+
lastUpdateTime: "2025-06-27T11:06:10Z"
391+
- type: PortState
392+
profile: OC-Profile-A
393+
filename: ptp4l.0.config
394+
status: "True"
395+
reason: SLAVE
396+
message: "interface ens5f1 state SLAVE (receiving time)"
397+
lastUpdateTime: "2025-06-27T11:05:20Z"
398+
- type: ClockType
399+
profile: OC-Profile-A
400+
filename: ptp4l.0.config
401+
status: "True"
402+
reason: OC
403+
message: "profile reports Ordinary Clock"
404+
lastUpdateTime: "2025-06-27T11:05:00Z"
405+
```
406+
407+
Example populated status (BC):
408+
```yaml
409+
status:
410+
ptpStatus:
411+
conditions:
412+
- type: PTP4lRunning
413+
profile: BC-Profile-A
414+
filename: ptp4l.0.config
415+
status: "True"
416+
reason: Started
417+
message: "ptp4l is running"
418+
lastUpdateTime: "2025-06-27T12:00:00Z"
419+
- type: LockState
420+
profile: BC-Profile-A
421+
filename: ptp4l.0.config
422+
status: "True"
423+
reason: HOLDOVER
424+
message: "BC in holdover"
425+
lastUpdateTime: "2025-06-27T12:01:00Z"
426+
- type: ClockClass
427+
profile: BC-Profile-A
428+
filename: ptp4l.0.config
429+
status: "True"
430+
reason: Class7
431+
message: "clock class is 7"
432+
lastUpdateTime: "2025-06-27T12:01:00Z"
433+
- type: PortState
434+
profile: BC-Profile-A
435+
filename: ptp4l.0.config
436+
status: "True"
437+
reason: SLAVE
438+
message: "ingress port ens5f1 state SLAVE (receiving time)"
439+
lastUpdateTime: "2025-06-27T12:00:20Z"
440+
- type: PortState
441+
profile: BC-Profile-A
442+
filename: ptp4l.0.config
443+
status: "True"
444+
reason: MASTER
445+
message: "egress port ens5f0 state MASTER (transmitting time)"
446+
lastUpdateTime: "2025-06-27T12:00:25Z"
447+
- type: ClockType
448+
profile: BC-Profile-A
449+
filename: ptp4l.0.config
450+
status: "True"
451+
reason: BC
452+
message: "profile reports Boundary Clock"
453+
lastUpdateTime: "2025-06-27T12:00:00Z"
454+
```
455+
456+
RBAC for linuxptp-daemon to update `ptpconfigs/status` is included in `bindata/linuxptp/ptp-daemon.yaml`.
457+
317458
## Quick Start
318459

319460
To install PTP Operator:

api/v1/ptpconfig_types.go

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package v1
1818

1919
import (
20+
corev1 "k8s.io/api/core/v1"
2021
apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
2122
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2223
)
@@ -38,6 +39,7 @@ type PtpConfigStatus struct {
3839
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
3940
// Important: Run "make" to regenerate code after modifying this file
4041
MatchList []NodeMatchList `json:"matchList,omitempty"`
42+
PtpStatus PtpStatus `json:"ptpStatus,omitempty"`
4143
}
4244

4345
//+kubebuilder:object:root=true
@@ -112,6 +114,60 @@ type NodeMatchList struct {
112114
Profile *string `json:"profile"`
113115
}
114116

117+
// PtpConditionType represents categories of PTP conditions reported by operands
118+
type PtpConditionType string
119+
120+
const (
121+
// Process lifecycle
122+
ConditionPodRestarted PtpConditionType = "PodRestarted"
123+
ConditionPTP4lRunning PtpConditionType = "PTP4lRunning"
124+
ConditionPhc2sysRunning PtpConditionType = "Phc2sysRunning"
125+
ConditionTs2phcRunning PtpConditionType = "Ts2phcRunning"
126+
ConditionSynce4lRunning PtpConditionType = "Synce4lRunning"
127+
ConditionChronydRunning PtpConditionType = "ChronydRunning"
128+
ConditionGPSPipeRunning PtpConditionType = "GPSPipeRunning"
129+
ConditionGPSDRunning PtpConditionType = "GPSDRunning"
130+
131+
// Profile/apply
132+
ConditionProfileApplied PtpConditionType = "ProfileApplied"
133+
134+
// NIC/PHC capabilities
135+
ConditionNICCapabilities PtpConditionType = "NICCapabilities"
136+
137+
// State and class (values reflected in Reason/Message)
138+
ConditionLockState PtpConditionType = "LockState" // LOCKED/HOLDOVER/FREERUN
139+
ConditionClockClass PtpConditionType = "ClockClass" // 6/7/248
140+
ConditionPortState PtpConditionType = "PortState" // INITIALIZING/LISTENING/SLAVE/MASTER/FAULTY
141+
ConditionClockType PtpConditionType = "ClockType" // OC/BC
142+
143+
// Event/CEP
144+
ConditionEventFramework PtpConditionType = "EventFramework"
145+
146+
// GNSS/DPLL (when applicable)
147+
ConditionGNSSState PtpConditionType = "GNSSState"
148+
ConditionDPLLStatus PtpConditionType = "DPLLStatus"
149+
150+
// Overall service readiness
151+
ConditionPTPServiceReady PtpConditionType = "PTPServiceReady"
152+
)
153+
154+
// PtpCondition mirrors standard Kubernetes condition patterns
155+
type PtpCondition struct {
156+
Type PtpConditionType `json:"type"`
157+
Profile string `json:"profile,omitempty"`
158+
Filename string `json:"filename,omitempty"`
159+
Process string `json:"process,omitempty"`
160+
Status corev1.ConditionStatus `json:"status"`
161+
Reason string `json:"reason,omitempty"`
162+
Message string `json:"message,omitempty"`
163+
LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty"`
164+
}
165+
166+
// PtpStatus aggregates conditions emitted by operands for this PtpConfig
167+
type PtpStatus struct {
168+
Conditions []PtpCondition `json:"conditions,omitempty"`
169+
}
170+
115171
func init() {
116172
SchemeBuilder.Register(&PtpConfig{}, &PtpConfigList{})
117173
}

api/v1/zz_generated.deepcopy.go

Lines changed: 39 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindata/linuxptp/ptp-daemon.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,35 @@ subjects:
227227
name: prometheus-k8s
228228
namespace: openshift-monitoring
229229
---
230+
apiVersion: rbac.authorization.k8s.io/v1
231+
kind: Role
232+
metadata:
233+
name: ptpconfig-status-writer
234+
namespace: openshift-ptp
235+
rules:
236+
- apiGroups:
237+
- ptp.openshift.io
238+
resources:
239+
- ptpconfigs/status
240+
verbs:
241+
- get
242+
- update
243+
- patch
244+
---
245+
apiVersion: rbac.authorization.k8s.io/v1
246+
kind: RoleBinding
247+
metadata:
248+
name: ptpconfig-status-writer-linuxptp
249+
namespace: openshift-ptp
250+
subjects:
251+
- kind: ServiceAccount
252+
name: linuxptp-daemon
253+
namespace: openshift-ptp
254+
roleRef:
255+
apiGroup: rbac.authorization.k8s.io
256+
kind: Role
257+
name: ptpconfig-status-writer
258+
---
230259
apiVersion: monitoring.coreos.com/v1
231260
kind: PrometheusRule
232261
metadata:

bundle/manifests/ptp-operator.clusterserviceversion.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ metadata:
6161
categories: Networking
6262
certified: "false"
6363
containerImage: quay.io/openshift/origin-ptp-operator:4.21
64-
createdAt: "2025-09-25T09:20:14Z"
64+
createdAt: "2025-10-03T17:05:44Z"
6565
description: This software enables configuration of Precision Time Protocol(PTP)
6666
on Kubernetes. It detects hardware capable PTP devices on each node, and configures
6767
linuxptp processes such as ptp4l, phc2sys and timemaster.

bundle/manifests/ptp.openshift.io_ptpconfigs.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,40 @@ spec:
150150
- profile
151151
type: object
152152
type: array
153+
ptpStatus:
154+
description: PtpStatus aggregates conditions emitted by operands for
155+
this PtpConfig
156+
properties:
157+
conditions:
158+
items:
159+
description: PtpCondition mirrors standard Kubernetes condition
160+
patterns
161+
properties:
162+
filename:
163+
type: string
164+
lastUpdateTime:
165+
format: date-time
166+
type: string
167+
message:
168+
type: string
169+
process:
170+
type: string
171+
profile:
172+
type: string
173+
reason:
174+
type: string
175+
status:
176+
type: string
177+
type:
178+
description: PtpConditionType represents categories of PTP
179+
conditions reported by operands
180+
type: string
181+
required:
182+
- status
183+
- type
184+
type: object
185+
type: array
186+
type: object
153187
type: object
154188
type: object
155189
served: true

0 commit comments

Comments
 (0)