Skip to content

Commit

Permalink
chore: class_fibrechannel: support optional attributes
Browse files Browse the repository at this point in the history
Signed-off-by: machine424 <ayoubmrini424@gmail.com>
  • Loading branch information
machine424 committed Feb 19, 2024
1 parent 4b77c68 commit a8a2c6e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions sysfs/class_fibrechannel.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ func (fs FS) parseFibreChannelHost(name string) (*FibreChannelHost, error) {
name := filepath.Join(path, f)
value, err := util.SysReadFile(name)
if err != nil {
// drivers can choose not to expose some attributes to sysfs.
// See: https://github.com/prometheus/node_exporter/issues/2919.
if os.IsNotExist(err) {
continue
}
return nil, fmt.Errorf("failed to read file %q: %w", name, err)
}

Expand Down
4 changes: 4 additions & 0 deletions sysfs/class_fibrechannel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ func TestFibreChannelClass(t *testing.T) {
FCPPacketAborts: 0x13,
},
},
"host1": FibreChannelHost{
Name: "host1",
PortState: "Online",
},
}

if diff := cmp.Diff(want, got); diff != "" {
Expand Down
11 changes: 11 additions & 0 deletions testdata/fixtures.ttar
Original file line number Diff line number Diff line change
Expand Up @@ -5068,6 +5068,17 @@ Lines: 1
Emulex SN1100E2P FV12.4.270.3 DV12.4.0.0. HN:gotest. OS:Linux
Mode: 644
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Directory: fixtures/sys/class/fc_host/host1
Mode: 755
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Path: fixtures/sys/class/fc_host/host1/port_state
Lines: 1
Online
Mode: 644
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Directory: fixtures/sys/class/fc_host/host1/statistics
Mode: 755
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Directory: fixtures/sys/class/infiniband
Mode: 755
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Expand Down

0 comments on commit a8a2c6e

Please sign in to comment.