-
Notifications
You must be signed in to change notification settings - Fork 60
Sync from upstream (22-Jul-2026) #718
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -176,6 +176,33 @@ func GetClockIfRoles(Ifs []string, nodeName *string) (roleInt []MetricRole, err | |
| return roleInt, nil | ||
| } | ||
|
|
||
| // getIfaceAlias generates the PHC iface alias used in openshift_ptp_* metrics. | ||
| // Must stay aligned with linuxptp-daemon/cloud-event-proxy GetAlias: | ||
| // | ||
| // ens2f0 -> ens2fx, ens2f0np0 -> ens2fx, ens1f0.100 -> ens1fx.100 | ||
| func getIfaceAlias(ifname string) string { | ||
| if ifname == "" { | ||
| return "" | ||
| } | ||
| if alreadyAliasedPattern.MatchString(ifname) { | ||
| return ifname | ||
| } | ||
| matches := ifaceAliasPattern.FindStringSubmatch(ifname) | ||
| if len(matches) < 3 { | ||
| return ifname | ||
| } | ||
| alias := matches[1] + "x" | ||
| if len(matches) > 3 && matches[3] != "" { | ||
| alias += matches[3] | ||
| } | ||
| return alias | ||
| } | ||
|
|
||
| var ( | ||
| alreadyAliasedPattern = regexp.MustCompile(`^(.+?)x(\..+)?$`) | ||
| ifaceAliasPattern = regexp.MustCompile(`^(.+?)(\d+)(?:np\d+)?(\..+)?$`) | ||
| ) | ||
|
|
||
| // gets a metric value string for a given node and interface | ||
| func getMetric(nodeName, aIf, metricName string) (metric string, err error) { | ||
| const ( | ||
|
|
@@ -201,11 +228,12 @@ func getMetric(nodeName, aIf, metricName string) (metric string, err error) { | |
| metrics := buf.String() | ||
| node := ptpPods.Items[index].Spec.NodeName | ||
|
|
||
| // Build a list of interface names to try: first the original, then the aliased (masked) version. | ||
| // Cards with a PHC per port keep the original name; cards sharing a PHC use the masked alias. | ||
| // Build a list of interface names to try: first the original, then the PHC alias. | ||
| // Cards with a PHC per port keep the original name; cards sharing a PHC use the masked alias | ||
| // (e.g. ens2f0 -> ens2fx, ens2f0np0 -> ens2fx). | ||
| ifCandidates := []string{aIf} | ||
| aliasedIf := aIf[:len(aIf)-1] + "x" | ||
| if aliasedIf != aIf { | ||
| aliasedIf := getIfaceAlias(aIf) | ||
| if aliasedIf != "" && aliasedIf != aIf { | ||
|
Comment on lines
+235
to
+236
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: set -e
printf 'File size and relevant slices:\n'
wc -l test/pkg/metrics/metrics.go
sed -n '210,290p' test/pkg/metrics/metrics.go
printf '\nSearch for candidate/QuoteMeta/regexp usage in file:\n'
rg -n 'getIfaceAlias|QuoteMeta|MustCompile|candidate|ifCandidates' test/pkg/metrics/metrics.goRepository: openshift/ptp-operator Length of output: 4234 Escape 🤖 Prompt for AI AgentsSource: Path instructions |
||
| ifCandidates = append(ifCandidates, aliasedIf) | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: openshift/ptp-operator
Length of output: 11623
🏁 Script executed:
Repository: openshift/ptp-operator
Length of output: 50379
🏁 Script executed:
Repository: openshift/ptp-operator
Length of output: 236
🏁 Script executed:
Repository: openshift/ptp-operator
Length of output: 50379
🏁 Script executed:
Repository: openshift/ptp-operator
Length of output: 3220
🌐 Web query:
linuxptp-daemon cloud-event-proxy GetAlias interface alias ens2f0 ens2fx source code💡 Result:
The term GetAlias as referenced in the context of linuxptp-daemon and cloud-event-proxy is not a standard standalone API function, but rather refers to an internal mechanism used for mapping PTP network interfaces to their respective PHC (PTP Hardware Clock) identifiers [1]. In the linuxptp-daemon implementation, the alias store is used to match hardware interfaces (like ens2f0) to their PHC IDs [1]. This is critical in environments with multi-port NICs where different physical interfaces may share the same PHC, or where naming prefixes differ (e.g., comparing ens2f0 vs ens2fx) [1]. The daemon registers these interfaces in an alias store using the phcID and the network interface name, ensuring that the convergeConfig logic correctly associates PTP processes with the appropriate hardware [1]. Recent updates to the cloud-event-proxy (such as commit ceae33f) have explicitly improved the handling of these aliases by fetching them before the proxy begins listening to the event socket [2]. This ensures that alias mappings are correctly initialized if the cloud-event-proxy restarts while the linuxptp-daemon is already active, preventing defaults that might otherwise fall back to incorrect interface naming [2]. The GetAlias name itself is common in various software SDKs (such as AWS Lambda or other cloud management APIs) [3][4], but within the specific Red Hat/OpenShift PTP stack, it typically relates to the internal helper methods or storage management logic used by the ptp_operator_plugin and linuxptp-daemon to maintain the consistency of interface-to-PHC mapping [2][1].
Citations:
🌐 Web query:
site:github.com/openshift/linuxptp-daemon GetAlias ens2f0 ens2fx code💡 Result:
The term "GetAlias" in the context of
ens2f0andens2fxappears to be related to a specific internal mechanism within theopenshift/linuxptp-daemonproject, which manages PTP (Precision Time Protocol) configurations on Kubernetes clusters [1][2][3]. Thelinuxptp-daemonuses an alias management system to handle interface naming differences, particularly when multiple physical interfaces share the same PHC (PTP Hardware Clock) [1]. In the source code for this daemon,alias.AddInterface(phc, ifname)andalias.CalculateAliases()are used to register and map network interface names to their corresponding PHC IDs [1]. This ensures that PTP processes (likeptp4l) correctly associate network devices—such asens2f0—even if their hardware identifiers or naming conventions differ across nodes [1]. There is no standard Linux kernel command or general-purpose utility calledGetAliasfor network interface renaming. The pattern you provided likely refers to a function or method within a specialized application (like the OpenShift PTP operator's components) designed to abstract hardware interface naming for configuration consistency [1][3]. If you are encountering this in a codebase, it is part of the custom logic used to normalize interface names for PTP hardware clock synchronization [1]. If you are looking for how to handle or rename network interfaces in standard Linux, you should use tools likeip linkor systemd's predictable network interface naming policies instead.Citations:
🏁 Script executed:
Repository: openshift/ptp-operator
Length of output: 14751
🏁 Script executed:
Repository: openshift/ptp-operator
Length of output: 7318
Restrict PHC aliasing to the documented interface forms.
ifaceAliasPatternrewrites any numeric-suffixed name (eno1→enox,bond0→bondx,eth1.100→ethx.100), sogetMetriccan fall back to the wrong interface when the aliased metric exists. Narrow this to the PHC naming contract (ens2f0/ens2f0np0/ens1f0.100) and add negative cases for ordinary NIC, bridge, and VLAN names.🤖 Prompt for AI Agents
Source: Path instructions