Bug 2106476

Summary: Order of config attributes are not maintained during conversion of PT4l from ptpconfig to ptp4l.0.config file
Product: OpenShift Container Platform Reporter: Aneesh Puttur <aputtur>
Component: NetworkingAssignee: Joseph Richard <josricha>
Networking sub component: ptp QA Contact: obochan <obochan>
Status: CLOSED ERRATA Docs Contact:
Severity: high    
Priority: high CC: bzvonar, keyoung, yliu1
Version: 4.11   
Target Milestone: ---   
Target Release: 4.12.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-01-17 19:52:29 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 2116557    
Attachments:
Description Flags
Expected result none

Description Aneesh Puttur 2022-07-12 18:47:04 UTC
Created attachment 1896462 [details]
Expected result

Description of problem:
ptp operator reads ptp4lconfig files and writes ptp4l section of data to /var/run/ptp4l.0.config file.

During this process the attributes are read to dictionary object and written back to a ptp4l.{0..n}.config file.

Since golang dictionary object doesn't guarantee the order of key value pair .The generated file content will not be in correct order.
The ordering of interface is important for boundary clock configuration, since Port ID are mapped  to the interface using the ordering of the interface names.


Version-Release number of selected component (if applicable):

OCP 4.11,4.10 (Boundary clock , dual nic)
Applied ptpconfig 
```
apiVersion: ptp.openshift.io/v1
kind: PtpConfig
metadata:
  name: du-ptp-bc1
  namespace: openshift-ptp
spec:
  profile:
  - name: bc1
    ptp4lConf: 
      [ens4f0]
      masterOnly 0
      [ens4f1]
      masterOnly 1
      [ens4f2]
      masterOnly 1
      [ens4f3]
      masterOnly 1
      [global]
      priority1   128
      priority2   128
      domainNumber 24
      clockAccuracy 0xFE
      offsetScaledLogVariance 0xFFFF
      free_running  0
      freq_est_interval 1
      dscp_event  0
      dscp_general 0 
      dataset_comparison ieee1588
      G.8275.defaultDS.localPriority 128
      logAnnounceInterval     -3
      logSyncInterval -4
      logMinDelayReqInterval -4
      logMinPdelayReqInterval -4
      nannounceReceiptTimeout   3
      syncReceiptTimeout 0
      delayAsymmetry 0
      fault_reset_interval 4
      neighborPropDelayThresh 20000000
      masterOnly 0
      G.8275.portDS.localPriority 128
      assume_two_step 0
      logging_level  6
      path_trace_enabled 0
      follow_up_info 0
      hybrid_e2e 0
      inhibit_multicast_service 0
      net_sync_monitor 0
      tc_spanning_tree 0
      tx_timestamp_timeout 100
      unicast_listen 0
      unicast_master_table 0
      unicast_req_duration 3600
      use_syslog 1
      verbose 0
      summary_interval  4
      kernel_leap 1
      check_fup_sync 0
      pi_proportional_const 0.0
      pi_integral_const 0.0
      pi_proportional_scale   0.0
      pi_proportional_exponent -0.3
      pi_proportional_norm_max 0.7
      pi_integral_scale  0.0
      pi_integral_exponent 0.4
      pi_integral_norm_max 0.3
      step_threshold  30.0
      first_step_threshold 0.00002
      max_frequency 900000000
      clock_servo  pi
      sanity_freq_limit 0
      ntpshm_segment 0
      transportSpecific 0x0
      ptp_dst_mac 01:1B:19:00:00:00
      p2p_dst_mac 01:80:C2:00:00:0E
      udp_ttl t1
      udp6_scope  0x0E
      uds_address /var/run/ptp4l
      clock_type BC
      network_transport  L2
      delay_mechanism E2E
      time_stamping hardware
      tsproc_mode filter
      delay_filter moving_median
      delay_filter_length 10
      egressLatency 0
      ingressLatency 0
      boundary_clock_jbod 0 
      productDescription ;;
      revisionData ;;
      manufacturerIdentity 00:00:00
      userDescription         ;
      timeSource 0xA0
    ptp4lOpts: -2 --summary_interval -4
    ptpClockThreshold:
      holdOverTimeout: 60
      maxOffsetThreshold: 100
      minOffsetThreshold: -100
    ptpSchedulingPolicy: SCHED_FIFO
    ptpSchedulingPriority: 65
  recommend:
  - match:
    - nodeLabel: node-role.kubernetes.io/master
    priority: 4
    profile: bc1
```

What is expected
--------------------
 [ens4f0]
 masterOnly 0
 [ens4f1]
 masterOnly 1
 [ens4f2]
 masterOnly 1
 [ens4f3]
 
 
 Actuall Result
 -----------------------
 [ens4f2]
 masterOnly  1
 [ens4f3]
 masterOnly  1
 [global]
 ...
 ...
 [ens4f0]
 masterOnly  0
 [ens4f1]
 masterOnly  1



Additional info:

Comment 3 Joseph Richard 2022-08-04 19:22:28 UTC
Testing confirmed that iface order is persisted in config file now, with switching orders of ens2f0 and ens2f1 in ptpconfig being reflected in config file for ptp4l in linuxptp-daemon pod.

Comment 7 errata-xmlrpc 2023-01-17 19:52:29 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: OpenShift Container Platform 4.12.0 bug fix and security update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2022:7399