Skip to content

Sync from upstream (22-Jul-2026) - #718

Open
nocturnalastro wants to merge 2 commits into
openshift:mainfrom
nocturnalastro:upstream-sync-2026-07-21
Open

Sync from upstream (22-Jul-2026)#718
nocturnalastro wants to merge 2 commits into
openshift:mainfrom
nocturnalastro:upstream-sync-2026-07-21

Conversation

@nocturnalastro

@nocturnalastro nocturnalastro commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Upstream PRs included

  • #273 fix: resolve PHC iface aliases for np-suffixed NICs in metrics checks

nocturnalastro and others added 2 commits July 14, 2026 12:40
DualFollower and other multi-port NIC tests fail looking up openshift_ptp_clock_state by port name (ens2f0np0) while the daemon emits ens2fx. Align getMetric aliasing with linuxptp-daemon GetAliasValue.

Generated-by: Cursor
…e-alias-np-suffix

fix: resolve PHC iface aliases for np-suffixed NICs in metrics checks
@openshift-ci
openshift-ci Bot requested review from edcdavid and sebsoto July 21, 2026 12:24
@openshift-ci

openshift-ci Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: nocturnalastro

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 21, 2026
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Walkthrough

The metrics test helper now derives PHC interface aliases using compiled regex rules and updates metric lookup to try both the original interface and a distinct derived alias.

Changes

PHC metric aliasing

Layer / File(s) Summary
Alias helper and metric lookup
test/pkg/metrics/metrics.go
Adds regex-based PHC interface alias generation, handles empty and already-aliased names, and conditionally includes the derived alias when fetching metrics.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 14 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title is generic and only says this is an upstream sync, not the specific PHC interface alias metric fix. Rename it to describe the main change, e.g. "Fix PHC interface alias resolution in metrics checks".
✅ Passed checks (14 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed The PR only changes helper logic in test/pkg/metrics/metrics.go; no Ginkgo It/Describe/Context/When titles were added or modified.
Test Structure And Quality ✅ Passed No Ginkgo specs were changed; this PR only updates a test helper, so the structure/quality checklist is not applicable.
Microshift Test Compatibility ✅ Passed PASS: The PR only changes metrics helper code; no new Ginkgo It/Describe/Context/When tests were added, so there’s nothing MicroShift-specific to flag.
Single Node Openshift (Sno) Test Compatibility ✅ Passed No new Ginkgo e2e test was added; test/pkg/metrics/metrics.go only बदल helper logic and contains no multi-node/SNO-sensitive assumptions.
Topology-Aware Scheduling Compatibility ✅ Passed Only test/pkg/metrics/metrics.go changed, adding metric alias lookup; no manifests, controllers, or scheduling constraints were introduced.
Ote Binary Stdout Contract ✅ Passed PASS: The PR only changes metric aliasing logic in a helper file; no main/init/TestMain/BeforeSuite stdout writes were added, and the lone fmt.Printf is inside a helper.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed No new Ginkgo e2e tests were added; the patch only updates metric alias lookup logic in test helpers.
No-Weak-Crypto ✅ Passed Touched code only adds interface-alias regex logic in test/pkg/metrics/metrics.go; no weak crypto, custom crypto, or secret comparisons found.
Container-Privileges ✅ Passed Only test/pkg/metrics/metrics.go changed; no manifests or container security settings like privileged/hostPID/hostNetwork/allowPrivilegeEscalation were introduced.
No-Sensitive-Data-In-Logs ✅ Passed The PR only changes metric alias lookup; it adds no new logging and doesn’t log passwords, tokens, PII, or hostnames.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/pkg/metrics/metrics.go`:
- Around line 235-236: Escape each candidate alias with regexp.QuoteMeta before
interpolating it into regex patterns in all three branches of the alias-matching
logic around getIfaceAlias. Preserve the existing matching behavior while
preventing metacharacters in raw aliases from changing the regex, and add a
regression test covering a VLAN alias such as ens1fx.100.
- Around line 201-203: Restrict ifaceAliasPattern to matching only the
documented PHC interface forms, including ens2f0, ens2f0np0, and ens1f0.100,
while preserving the optional representor and VLAN suffix handling needed by
getMetric. Update the associated tests with negative cases for ordinary NIC,
bridge, and VLAN names so these names are never aliased.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 88fcb3d1-00c8-4750-8536-329487d0ed81

📥 Commits

Reviewing files that changed from the base of the PR and between c2d45fc and 3b3778c.

📒 Files selected for processing (1)
  • test/pkg/metrics/metrics.go

Comment on lines +201 to +203
var (
alreadyAliasedPattern = regexp.MustCompile(`^(.+?)x(\..+)?$`)
ifaceAliasPattern = regexp.MustCompile(`^(.+?)(\d+)(?:np\d+)?(\..+)?$`)

Copy link
Copy Markdown

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:

set -euo pipefail

git ls-files test/pkg/metrics/metrics.go
echo '--- outline ---'
ast-grep outline test/pkg/metrics/metrics.go --view expanded || true
echo '--- relevant lines ---'
sed -n '160,260p' test/pkg/metrics/metrics.go | cat -n
echo '--- searches ---'
rg -n "getIfaceAlias|ifaceAliasPattern|alreadyAliasedPattern|getMetric|PHC|alias" test/pkg/metrics/metrics.go test/pkg/metrics -S

Repository: openshift/ptp-operator

Length of output: 11623


🏁 Script executed:

set -euo pipefail

# Find any tests or docs describing the alias contract.
rg -n "enox|bondx|ifaceAliasPattern|getIfaceAlias|PHC|linuxptp|alias" . -S --glob '!**/vendor/**' --glob '!**/node_modules/**'

Repository: openshift/ptp-operator

Length of output: 50379


🏁 Script executed:

set -euo pipefail

# Check whether the candidate aliases are actually used by current tests.
sed -n '1,220p' test/pkg/metrics/metrics_test.go | cat -n

Repository: openshift/ptp-operator

Length of output: 236


🏁 Script executed:

set -euo pipefail

# If there is a README or fixture documenting metric interface naming, inspect it.
rg -n "interface.*metric|PHC|linuxptp|alias" test pkg README.md . -S --glob '!**/vendor/**' --glob '!**/node_modules/**'

Repository: openshift/ptp-operator

Length of output: 50379


🏁 Script executed:

set -euo pipefail

sed -n '180,250p' test/pkg/metrics/metrics.go | cat -n

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 ens2f0 and ens2fx appears to be related to a specific internal mechanism within the openshift/linuxptp-daemon project, which manages PTP (Precision Time Protocol) configurations on Kubernetes clusters [1][2][3]. The linuxptp-daemon uses 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) and alias.CalculateAliases() are used to register and map network interface names to their corresponding PHC IDs [1]. This ensures that PTP processes (like ptp4l) correctly associate network devices—such as ens2f0—even if their hardware identifiers or naming conventions differ across nodes [1]. There is no standard Linux kernel command or general-purpose utility called GetAlias for 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 like ip link or systemd's predictable network interface naming policies instead.

Citations:


🏁 Script executed:

set -euo pipefail

echo '--- package files ---'
git ls-files 'test/pkg/metrics/*' 'test/pkg/*' | sed -n '1,120p'

echo '--- interface-name mentions in metrics package ---'
rg -n "ens[0-9]|bond[0-9]|eth[0-9]|enp|np[0-9]|vlan|alias|GetAlias|getIfaceAlias|ifaceAliasPattern" test/pkg/metrics -S

echo '--- surrounding callers ---'
sed -n '100,380p' test/pkg/metrics/metrics.go | cat -n

Repository: openshift/ptp-operator

Length of output: 14751


🏁 Script executed:

set -euo pipefail

# Show just the call sites and helper behavior in a compact way.
python3 - <<'PY'
from pathlib import Path
p = Path('test/pkg/metrics/metrics.go')
text = p.read_text()
for i, line in enumerate(text.splitlines(), 1):
    if 179 <= i <= 250 or 300 <= i <= 380:
        print(f"{i:4d}: {line}")
PY

Repository: openshift/ptp-operator

Length of output: 7318


Restrict PHC aliasing to the documented interface forms.
ifaceAliasPattern rewrites any numeric-suffixed name (eno1enox, bond0bondx, eth1.100ethx.100), so getMetric can 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
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/pkg/metrics/metrics.go` around lines 201 - 203, Restrict
ifaceAliasPattern to matching only the documented PHC interface forms, including
ens2f0, ens2f0np0, and ens1f0.100, while preserving the optional representor and
VLAN suffix handling needed by getMetric. Update the associated tests with
negative cases for ordinary NIC, bridge, and VLAN names so these names are never
aliased.

Source: Path instructions

Comment on lines +235 to +236
aliasedIf := getIfaceAlias(aIf)
if aliasedIf != "" && aliasedIf != aIf {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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.go

Repository: openshift/ptp-operator

Length of output: 4234


Escape candidate before building the regex. test/pkg/metrics/metrics.go:240-249 Raw aliases like ens1fx.100 include regex metacharacters, so the unescaped interpolation can match the wrong metric. Use regexp.QuoteMeta(candidate) in all three branches and add a VLAN-alias regression test.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/pkg/metrics/metrics.go` around lines 235 - 236, Escape each candidate
alias with regexp.QuoteMeta before interpolating it into regex patterns in all
three branches of the alias-matching logic around getIfaceAlias. Preserve the
existing matching behavior while preventing metacharacters in raw aliases from
changing the regex, and add a regression test covering a VLAN alias such as
ens1fx.100.

Source: Path instructions

@openshift-ci

openshift-ci Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

@nocturnalastro: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/operator-e2e 3b3778c link true /test operator-e2e

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@nocturnalastro nocturnalastro changed the title Sync from upstream (21-Jul-2026) Sync from upstream (22-Jul-2026) Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants