Skip to content

Commit 39619b9

Browse files
committed
chore: class_fibrechannel: support optional attributes
Signed-off-by: machine424 <[email protected]>
1 parent 4b77c68 commit 39619b9

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

sysfs/class_fibrechannel.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ func (fs FS) parseFibreChannelHost(name string) (*FibreChannelHost, error) {
9393
name := filepath.Join(path, f)
9494
value, err := util.SysReadFile(name)
9595
if err != nil {
96+
// drivers can choose not to expose some attributes to sysfs.
97+
// See: https://github.com/prometheus/node_exporter/issues/2919.
98+
if os.IsNotExist(err) {
99+
continue
100+
}
96101
return nil, fmt.Errorf("failed to read file %q: %w", name, err)
97102
}
98103

sysfs/class_fibrechannel_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ func TestFibreChannelClass(t *testing.T) {
6464
FCPPacketAborts: 0x13,
6565
},
6666
},
67+
"host1": FibreChannelHost{
68+
Name: "host1",
69+
},
6770
}
6871

6972
if diff := cmp.Diff(want, got); diff != "" {

testdata/fixtures.ttar

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5068,6 +5068,12 @@ Lines: 1
50685068
Emulex SN1100E2P FV12.4.270.3 DV12.4.0.0. HN:gotest. OS:Linux
50695069
Mode: 644
50705070
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
5071+
Directory: fixtures/sys/class/fc_host/host1
5072+
Mode: 755
5073+
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
5074+
Directory: fixtures/sys/class/fc_host/host1/statistics
5075+
Mode: 755
5076+
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
50715077
Directory: fixtures/sys/class/infiniband
50725078
Mode: 755
50735079
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

0 commit comments

Comments
 (0)