Skip to content

Fix fibrechannel_linux for ppc64le - #3769

Open
hamzy wants to merge 1 commit into
prometheus:masterfrom
hamzy:fix-collector-fibrechannel_linux
Open

Fix fibrechannel_linux for ppc64le#3769
hamzy wants to merge 1 commit into
prometheus:masterfrom
hamzy:fix-collector-fibrechannel_linux

Conversation

@hamzy

@hamzy hamzy commented Aug 1, 2026

Copy link
Copy Markdown

Seen on a master node:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x106cefa4]
goroutine 81 [running]:
github.com/prometheus/node_exporter/collector.(*fibrechannelCollector).Update(0x7e28c1ae20f0, 0x7e28c1826770)
  /go/src/github.com/prometheus/node_exporter/collector/fibrechannel_linux.go:133 +0x604

sh-5.1# ls -l /host/sys/class/fc_host/
total 0
lrwxrwxrwx. 1 root root 0 Jul 30 20:42 host1 -> ../../devices/vio/30000003/host1/fc_host/host1
lrwxrwxrwx. 1 root root 0 Jul 30 20:42 host2 -> ../../devices/vio/30000005/host2/fc_host/host2
sh-5.1# ls -l /host/sys/class/fc_host/host1/
total 0
-rw-r--r--. 1 root root 65536 Jul 30 20:09 dev_loss_tmo
lrwxrwxrwx. 1 root root     0 Jul 30 20:42 device -> ../../../host1
-r--r--r--. 1 root root 65536 Jul 30 20:09 fabric_name
--w-------. 1 root root 65536 Jul 30 20:42 issue_lip
-r--r--r--. 1 root root 65536 Jul 30 20:42 maxframe_size
-r--r--r--. 1 root root 65536 Jul 30 20:09 node_name
-r--r--r--. 1 root root 65536 Jul 30 20:09 port_id
-r--r--r--. 1 root root 65536 Jul 30 20:42 port_name
-r--r--r--. 1 root root 65536 Jul 30 20:09 port_state
-r--r--r--. 1 root root 65536 Jul 30 20:09 port_type
drwxr-xr-x. 2 root root     0 Jul 30 20:42 power
-r--r--r--. 1 root root 65536 Jul 30 20:09 speed
lrwxrwxrwx. 1 root root     0 Jul 30 20:42 subsystem -> ../../../../../../class/fc_host
-r--r--r--. 1 root root 65536 Jul 30 20:09 supported_classes
-rw-r--r--. 1 root root 65536 Jul 30 20:42 tgtid_bind_type
-rw-r--r--. 1 root root 65536 Jul 30 20:42 uevent

Since many filenames for counters are not guaranteed to exist in VMs, allocate if not present.

// Note: `procfs` does not guarantee a safe dereference for these counters.
// A disabled host returns no statistics counters.
if host.PortState == nil || *host.PortState == "Unknown" {
// Note: These are not guaranteed to exist in the filesystem

@prb112 prb112 Aug 2, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This defense addition makes sense to me.

@prb112

prb112 commented Aug 2, 2026

Copy link
Copy Markdown

Related to a bug found at https://redhat.atlassian.net/browse/OCPBUGS-100376

@hamzy
hamzy force-pushed the fix-collector-fibrechannel_linux branch 3 times, most recently from e4442c4 to 597d541 Compare August 4, 2026 00:23
Comment thread collector/fibrechannel_linux_test.go
@hamzy
hamzy force-pushed the fix-collector-fibrechannel_linux branch from 597d541 to ae10239 Compare August 4, 2026 12:17
Comment thread collector/fixtures/e2e-64k-page-output.txt
@hamzy
hamzy force-pushed the fix-collector-fibrechannel_linux branch from ae10239 to 32870c9 Compare August 4, 2026 13:27
Seen on a master node:

```
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x106cefa4]
goroutine 81 [running]:
github.com/prometheus/node_exporter/collector.(*fibrechannelCollector).Update(0x7e28c1ae20f0, 0x7e28c1826770)
  /go/src/github.com/prometheus/node_exporter/collector/fibrechannel_linux.go:133 +0x604

sh-5.1# ls -l /host/sys/class/fc_host/
total 0
lrwxrwxrwx. 1 root root 0 Jul 30 20:42 host1 -> ../../devices/vio/30000003/host1/fc_host/host1
lrwxrwxrwx. 1 root root 0 Jul 30 20:42 host2 -> ../../devices/vio/30000005/host2/fc_host/host2
sh-5.1# ls -l /host/sys/class/fc_host/host1/
total 0
-rw-r--r--. 1 root root 65536 Jul 30 20:09 dev_loss_tmo
lrwxrwxrwx. 1 root root     0 Jul 30 20:42 device -> ../../../host1
-r--r--r--. 1 root root 65536 Jul 30 20:09 fabric_name
--w-------. 1 root root 65536 Jul 30 20:42 issue_lip
-r--r--r--. 1 root root 65536 Jul 30 20:42 maxframe_size
-r--r--r--. 1 root root 65536 Jul 30 20:09 node_name
-r--r--r--. 1 root root 65536 Jul 30 20:09 port_id
-r--r--r--. 1 root root 65536 Jul 30 20:42 port_name
-r--r--r--. 1 root root 65536 Jul 30 20:09 port_state
-r--r--r--. 1 root root 65536 Jul 30 20:09 port_type
drwxr-xr-x. 2 root root     0 Jul 30 20:42 power
-r--r--r--. 1 root root 65536 Jul 30 20:09 speed
lrwxrwxrwx. 1 root root     0 Jul 30 20:42 subsystem -> ../../../../../../class/fc_host
-r--r--r--. 1 root root 65536 Jul 30 20:09 supported_classes
-rw-r--r--. 1 root root 65536 Jul 30 20:42 tgtid_bind_type
-rw-r--r--. 1 root root 65536 Jul 30 20:42 uevent
```

Since many filenames for counters are not guaranteed to exist in VMs,
allocate if not present.

Signed-off-by: Mark Hamzy <hamzy@us.ibm.com>
@hamzy
hamzy force-pushed the fix-collector-fibrechannel_linux branch from 32870c9 to d00fb6f Compare August 4, 2026 15:47
# TYPE node_fibrechannel_info gauge
node_fibrechannel_info{dev_loss_tmo="",fabric_name="",fc_host="host1",port_id="",port_name="",port_state="Online",port_type="",speed="8 Gbit",supported_classes="",supported_speeds="",symbolic_name=""} 1
node_fibrechannel_info{dev_loss_tmo="30",fabric_name="0",fc_host="host0",port_id="000002",port_name="1000e0071bce95f2",port_state="Online",port_type="Point-To-Point (direct nport connection)",speed="16 Gbit",supported_classes="Class 3",supported_speeds="4 Gbit, 8 Gbit, 16 Gbit",symbolic_name="Emulex SN1100E2P FV12.4.270.3 DV12.4.0.0. HN:gotest. OS:Linux"} 1
node_fibrechannel_info{dev_loss_tmo="30",fabric_name="0",fc_host="host2",port_id="000003",port_name="4000e0071bce95f2",port_state="Online",port_type="Point-To-Point (direct nport connection)",speed="16 Gbit",supported_classes="Class 3",supported_speeds="4 Gbit, 8 Gbit, 16 Gbit",symbolic_name="Emulex SN1100E2P FV12.4.270.3 DV12.4.0.0. HN:gotest. OS:Linux"} 1

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this info metric isn't correct (most of the label values are empty)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Isn't that the whole point of this PR?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The expected output is

node_fibrechannel_info{dev_loss_tmo="",fabric_name="",fc_host="host1",port_id="",port_name="",port_state="Online",port_type="",speed="8 Gbit",supported_classes="",supported_speeds="",symbolic_name=""} 1                                                                                                                                                                                 
node_fibrechannel_info{dev_loss_tmo="",fabric_name="",fc_host="host2",port_id="",port_name="",port_state="Online",port_type="",speed="",supported_classes="",supported_speeds="",symbolic_name=""} 1                                                                                                                                                                                       
node_fibrechannel_info{dev_loss_tmo="30",fabric_name="0",fc_host="host0",port_id="000002",port_name="1000e0071bce95f2",port_state="Online",port_type="Point-To-Point (direct nport connection)",speed="16 Gbit",supported_classes="Class 3",supported_speeds="4 Gbit, 8 Gbit, 16 Gbit",symbolic_name="Emulex SN1100E2P FV12.4.270.3 DV12.4.0.0. HN:gotest. OS:Linux"} 1                    

instead of

node_fibrechannel_info{dev_loss_tmo="",fabric_name="",fc_host="host1",port_id="",port_name="",port_state="Online",port_type="",speed="8 Gbit",supported_classes="",supported_speeds="",symbolic_name=""} 1
node_fibrechannel_info{dev_loss_tmo="30",fabric_name="0",fc_host="host0",port_id="000002",port_name="1000e0071bce95f2",port_state="Online",port_type="Point-To-Point (direct nport connection)",speed="16 Gbit",supported_classes="Class 3",supported_speeds="4 Gbit, 8 Gbit, 16 Gbit",symbolic_name="Emulex SN1100E2P FV12.4.270.3 DV12.4.0.0. HN:gotest. OS:Linux"} 1
node_fibrechannel_info{dev_loss_tmo="30",fabric_name="0",fc_host="host2",port_id="000003",port_name="4000e0071bce95f2",port_state="Online",port_type="Point-To-Point (direct nport connection)",speed="16 Gbit",supported_classes="Class 3",supported_speeds="4 Gbit, 8 Gbit, 16 Gbit",symbolic_name="Emulex SN1100E2P FV12.4.270.3 DV12.4.0.0. HN:gotest. OS:Linux"} 1

Notice how the host2 line is between host1 and host0 and how most of its labels are empty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants