Skip to content

fix some fc-hba are missing the statistics/*#664

Merged
SuperQ merged 12 commits into
prometheus:masterfrom
chijiajian:fixFibrechannel
Jun 18, 2026
Merged

fix some fc-hba are missing the statistics/*#664
SuperQ merged 12 commits into
prometheus:masterfrom
chijiajian:fixFibrechannel

Conversation

@chijiajian

Copy link
Copy Markdown
Contributor

Some FC-HBA cards are missing the /sys/class/fc_host//statistics/* directory and files, for example, the Huawei Technologies Co., Ltd. Hi1822 Family (2*16G FC) (rev 45) card with ID 3e:00.0. However, there are corresponding port_name, port_state, etc., under /sys/class/fc_host//. It is recommended to add a check in the parseFibreChannelStatistics function in the class_fibrechannel.

Signed-off-by: jiajian.chi <jiajian.chi@zstack.io>
 On branch fixFibrechannel
 Changes to be committed:
	modified:   sysfs/class_fibrechannel.go

Signed-off-by: jiajian.chi <jiajian.chi@zstack.io>
Comment thread sysfs/class_fibrechannel.go Outdated
delete Printf

Signed-off-by: chijiajian <33536362+chijiajian@users.noreply.github.com>
@chijiajian chijiajian requested a review from SuperQ September 24, 2024 07:51
Comment thread sysfs/class_fibrechannel.go
Refactor error handling for statistics directory check.

Signed-off-by: chijiajian <33536362+chijiajian@users.noreply.github.com>

@chijiajian chijiajian left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed — now explicitly checking for fs.ErrNotExist and returning other errors.

@chijiajian chijiajian left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fix: undefined: fs

@chijiajian chijiajian left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated to check errors.Is(err, os.ErrNotExist). Thanks!

Signed-off-by: chijiajian <33536362+chijiajian@users.noreply.github.com>
Signed-off-by: jiajian.chi <jiajian.chi@zstack.io>
@chijiajian

Copy link
Copy Markdown
Contributor Author

Fixed the code formatting issues via gofmt locally. Please take a look. Thanks!

@chijiajian

Copy link
Copy Markdown
Contributor Author

Thanks! Removed the redundant os.Stat call — os.ReadDir already returns os.ErrNotExist when the directory is missing, so we just handle it there directly.

ReadDir already returns os.ErrNotExist when the directory does not
exist, so no need to run Stat before ReadDir.

Signed-off-by: chijiajian <33536362+chijiajian@users.noreply.github.com>
@chijiajian

Copy link
Copy Markdown
Contributor Author

Hi @SuperQ @discordianfish, I addressed the last review comment in a3c8569 by removing the redundant os.Stat call and handling os.ErrNotExist directly from os.ReadDir.

The review threads are now resolved/outdated. Could you please re-run CI for the latest commit and take another look when you have a chance? Thanks!

Comment thread sysfs/class_fibrechannel.go Outdated
Co-authored-by: Ben Kochie <superq@gmail.com>
Signed-off-by: Ben Kochie <superq@gmail.com>
@SuperQ SuperQ merged commit 63e4d76 into prometheus:master Jun 18, 2026
7 checks passed
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.

4 participants